Redis:Install on RHEL5U10
Redis的官方网站:http://www.redis.io/
官方下载页:http://www.redis.io/download
这里我下载的版本是:3.0.2
URL:http://download.redis.io/releases/redis-3.0.2.tar.gz
解压:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
[root@CenterServer redis]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.10 (Tikanga) [root@CenterServer redis]# [root@CenterServer redis]# pwd /software/redis [root@CenterServer redis]# [root@CenterServer redis]# ls -ltr total 1336 -rw-r--r-- 1 root root 1360182 Jul 14 19:06 redis-3.0.2.tar.gz [root@CenterServer redis]# [root@CenterServer redis]# du -sh * 1.4M redis-3.0.2.tar.gz [root@CenterServer redis]# [root@CenterServer redis]# tar -xzf redis-3.0.2.tar.gz [root@CenterServer redis]# [root@CenterServer redis]# ls -ltr total 1340 drwxrwxr-x 6 root root 4096 Jun 4 02:35 redis-3.0.2 -rw-r--r-- 1 root root 1360182 Jul 14 19:06 redis-3.0.2.tar.gz [root@CenterServer redis]# [root@CenterServer redis]# cd redis-3.0.2 [root@CenterServer redis-3.0.2]# ls -ltr total 144 drwxrwxr-x 5 root root 4096 Jun 4 02:35 utils drwxrwxr-x 10 root root 4096 Jun 4 02:35 tests drwxrwxr-x 2 root root 4096 Jun 4 02:35 src -rw-rw-r-- 1 root root 7109 Jun 4 02:35 sentinel.conf -rwxrwxr-x 1 root root 281 Jun 4 02:35 runtest-sentinel -rwxrwxr-x 1 root root 280 Jun 4 02:35 runtest-cluster -rwxrwxr-x 1 root root 271 Jun 4 02:35 runtest -rw-rw-r-- 1 root root 41403 Jun 4 02:35 redis.conf -rw-rw-r-- 1 root root 5201 Jun 4 02:35 README -rw-rw-r-- 1 root root 4223 Jun 4 02:35 MANIFESTO -rw-rw-r-- 1 root root 151 Jun 4 02:35 Makefile -rw-rw-r-- 1 root root 11 Jun 4 02:35 INSTALL drwxrwxr-x 6 root root 4096 Jun 4 02:35 deps -rw-rw-r-- 1 root root 1487 Jun 4 02:35 COPYING -rw-rw-r-- 1 root root 1439 Jun 4 02:35 CONTRIBUTING -rw-rw-r-- 1 root root 53 Jun 4 02:35 BUGS -rw-rw-r-- 1 root root 26772 Jun 4 02:35 00-RELEASENOTES [root@CenterServer redis-3.0.2]# |
检查:make test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
[root@rhel-server redis-3.0.2]# make test (... ...等等) [32/37 done]: unit/basic (111 seconds) [ok]: Connect multiple slaves at the same time (issue #141), diskless=yes [ok]: Client output buffer soft limit is not enforced if time is not overreached [33/37 done]: integration/replication (121 seconds) [ok]: PFCOUNT multiple-keys merge returns cardinality of union [ok]: PFDEBUG GETREG returns the HyperLogLog raw registers [ok]: PFADD / PFCOUNT cache invalidation works [34/37 done]: unit/hyperloglog (75 seconds) [ok]: Client output buffer soft limit is enforced if time is overreached [35/37 done]: unit/obuf-limits (93 seconds) [ok]: MASTER and SLAVE consistency with EVALSHA replication [36/37 done]: integration/replication-3 (136 seconds) [ok]: Replication: commands with many arguments (issue #1221) [37/37 done]: integration/replication-4 (135 seconds) The End Execution time of different units: 1 seconds - unit/printver 1 seconds - unit/quit 2 seconds - unit/auth 3 seconds - unit/scan 3 seconds - unit/multi 5 seconds - unit/protocol 12 seconds - unit/expire 22 seconds - unit/type/list 11 seconds - integration/aof 36 seconds - unit/dump 4 seconds - integration/rdb 1 seconds - integration/logging 3 seconds - integration/convert-zipmap-hash-on-load 2 seconds - unit/pubsub 2 seconds - unit/slowlog 42 seconds - unit/type/list-2 1 seconds - unit/introspection 2 seconds - unit/limits 16 seconds - unit/scripting 59 seconds - unit/type/hash 60 seconds - unit/other 63 seconds - unit/aofrw 56 seconds - integration/replication-psync 77 seconds - unit/type/set 32 seconds - unit/bitops 91 seconds - unit/type/zset 53 seconds - unit/maxmemory 96 seconds - integration/replication-2 47 seconds - unit/memefficiency 110 seconds - unit/sort 111 seconds - unit/type/list-3 111 seconds - unit/basic 121 seconds - integration/replication 75 seconds - unit/hyperloglog 93 seconds - unit/obuf-limits 136 seconds - integration/replication-3 135 seconds - integration/replication-4 \o/ All tests passed without errors! Cleanup: may take some time... OK make[1]: Leaving directory `/software/redis-3.0.2/src' [root@rhel-server redis-3.0.2]# |
如上就是没有问题,否则,需要修复好问题后继续。
在这里,最容易出现的问题是要求tcl为8.5或者以上版本。
可以参考以下文档解决该问题:http://d-prototype.com/archives/3166
正式安装:
1. make
2. make install
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[root@rhel-server redis-3.0.2]# pwd /software/redis-3.0.2 [root@rhel-server redis-3.0.2]# ls 00-RELEASENOTES CONTRIBUTING deps Makefile README runtest runtest-sentinel src utils BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests [root@rhel-server redis-3.0.2]# [root@rhel-server redis-3.0.2]# make cd src && make all make[1]: Entering directory `/software/redis-3.0.2/src' INSTALL redis-sentinel CC redis-cli.o LINK redis-cli CC redis-benchmark.o LINK redis-benchmark CC redis-check-dump.o LINK redis-check-dump Hint: It's a good idea to run 'make test' ;) make[1]: Leaving directory `/software/redis-3.0.2/src' [root@rhel-server redis-3.0.2]# [root@rhel-server redis-3.0.2]# make install cd src && make install make[1]: Entering directory `/software/redis-3.0.2/src' Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: Leaving directory `/software/redis-3.0.2/src' [root@rhel-server redis-3.0.2]# |
安装完成后:
1 2 3 4 5 6 7 8 |
[root@rhel-server redis-3.0.2]# ls -ltr /usr/local/bin/ | grep --color redis -rwxr-xr-x 1 root root 6457322 Jul 15 02:22 redis-server -rwxr-xr-x 1 root root 4587102 Jul 15 02:22 redis-benchmark -rwxr-xr-x 1 root root 4690009 Jul 15 02:22 redis-cli -rwxr-xr-x 1 root root 45443 Jul 15 02:22 redis-check-dump -rwxr-xr-x 1 root root 22225 Jul 15 02:22 redis-check-aof lrwxrwxrwx 1 root root 12 Jul 15 02:22 redis-sentinel -> redis-server [root@rhel-server redis-3.0.2]# |
说明:
redis-server,服务器
redis-cli,命令行工具(客户端)
redis-benchmark,性能测试工具
redis-check-aof,AOF文件修复工具
redis-check-dump,RDB文件修复工具
启动Redis:
以默认方式启动:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@rhel-server ~]# redis-server 9084:C 15 Jul 02:31:23.135 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 9084:M 15 Jul 02:31:23.135 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.2 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 9084 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 9084:M 15 Jul 02:31:23.137 # Server started, Redis version 3.0.2 9084:M 15 Jul 02:31:23.137 # 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. 9084:M 15 Jul 02:31:23.137 # 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. 9084:M 15 Jul 02:31:23.137 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 9084:M 15 Jul 02:31:23.137 * The server is now ready to accept connections on port 6379 |
启动后:
1 2 3 4 |
[root@rhel-server ~]# netstat -tupln | grep --color redis tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 9084/redis-server * tcp 0 0 :::6379 :::* LISTEN 9084/redis-server * [root@rhel-server ~]# |
访问:
1 2 3 4 5 6 7 8 9 |
[root@rhel-server ~]# redis-cli PING PONG [root@rhel-server ~]# redis-cli 127.0.0.1:6379> INCR blog (integer) 1 127.0.0.1:6379> GET blog "1" 127.0.0.1:6379> exit [root@rhel-server ~]# |
停止Redis:
1 2 |
[root@rhel-server ~]# redis-cli SHUTDOWN [root@rhel-server ~]# |
当停止时,日志信息如下:
1 2 3 4 |
9084:M 15 Jul 02:37:56.895 # User requested shutdown... 9084:M 15 Jul 02:37:56.895 * Saving the final RDB snapshot before exiting. 9084:M 15 Jul 02:37:56.897 * DB saved on disk 9084:M 15 Jul 02:37:56.897 # Redis is now ready to exit, bye bye... |
——————————————————————————
Done。