初见Redis
无意中看到一篇博文讲Spark+Redis结合后,查询效率比spark缓存的速度快了45倍【不是45%】,再加上之前跟对面组做运维的交流的时候,知道他们也在使用Redis,好奇心之下,看完blog后,去官网下载了最新版的redis-3.0.7。没想到的是,这神奇的东东原来只有1.5M,更加对其有好奇心了。
安装手顺
很简单,用过linux系统的,应该觉得这是最简单的安装。
事前准备
- 确认你的虚拟机是否已安装了gcc。笔者第一次安装的时候,就出问题了,查看了控制台上的message信息后,发信该虚拟机没有安装gcc,瞬间石化了。
- 下载物件。直接去官网,很方便。github上托管的源码:https://github.com/antirez/redis-doc
安装
- 解压物件。
tar -zxf redis-3.0.7.tar.gz
- 编译redis源码
cd redis-3.0.7 make
- 以demon形式启动服务端
src/redis-server
- 当你看到如下所示的东西时,证明启动成功
[root@sv004 redis-3.0.7]# src/redis-server 5478:C 31 Mar 23:21:27.448 # Warning: no config file specified,using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.7 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ',.-` | `,) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 5478 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 5478:M 31 Mar 23:21:27.450 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 5478:M 31 Mar 23:21:27.450 # Server started,Redis version 3.0.7 5478:M 31 Mar 23:21:27.450 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 5478:M 31 Mar 23:21:27.450 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 5478:M 31 Mar 23:21:27.450 * The server is now ready to accept connections on port 6379 5478:M 31 Mar 23:36:03.254 * DB saved on disk 5478:M 01 Apr 00:36:04.033 * 1 changes in 3600 seconds. Saving... 5478:M 01 Apr 00:36:04.034 * Background saving started by pid 5750 5750:C 01 Apr 00:36:04.043 * DB saved on disk 5750:C 01 Apr 00:36:04.044 * RDB: 6 MB of memory used by copy-on-write 5478:M 01 Apr 00:36:04.134 * Background saving terminated with success
- 启动cli
src/redis-cli
这会,你就可以命令行的形式,使用redis了。
PS:为了更易区分,可以优化一下文件分布。创建bin目录来存储执行文件
mkdir bin cp -p redis-server bin/ cp -p redis-cli bin/原文链接:https://www.f2er.com/nosql/203711.html