wget -c http://download.redis.io/releases/redis-3.0.6.tar.gz tar xvf redis-version.tar.gz cd redis-version make && make install
> 注意:安装需要编译环境,例如gcc等必要工具的支持
2.提示缺少tcl,可以通过yum install tcl去安装
[root@redis redis-3.0.6]# make test cd src && make test make[1]: Entering directory `/root/redis-3.0.6/src' You need tcl 8.5 or newer inorder to run the Redis test make[1]: *** [test] Error 1 make[1]: Leaving directory `/root/redis-3.0.6/src' make: *** [test] Error 2
[root@redis redis-3.0.6]# redis-server redis.conf 4624:M 20 Dec 11:56:53.375 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.6 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 4624 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
4624:M 20 Dec 11:56:53.376 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 4624:M 20 Dec 11:56:53.376 # Server started, Redis version 3.0.6 4624:M 20 Dec 11:56:53.376 # 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. 4624:M 20 Dec 11:56:53.376 # 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. 4624:M 20 Dec 11:56:53.376 * The server is now ready to accept connections on port 6379
127.0.0.1:6379> help redis-cli 3.0.6 Type: "help @<group>"togetalist of commands in <group> "help <command>"forhelpon<command> "help <tab>"togetalist of possible help topics "quit"toexit
例如我们要查看String的相关参数可以使用help @String
127.0.0.1:6379> help @String
APPEND key value summary: Append avaluetoa key since: 2.0.0
127.0.0.1:6379> SELECT 1 OK 127.0.0.1:6379[1]> SELECT 2 OK
2.设置字符串
127.0.0.1:6379> help set
SET key value [EX seconds] [PX milliseconds] [NX|XX] summary: Set the string value of a key since: 1.0.0 group: string
3.设置key和value
127.0.0.1:6379> SET disto fedora OK 127.0.0.1:6379> GET disto "fedora"
4.键值在同一名称空间中必须唯一
127.0.0.1:6379> SET disto fedora OK 127.0.0.1:6379> GET disto "fedora" 127.0.0.1:6379> SET disto ubuntu OK 127.0.0.1:6379> GET disto "ubuntu" 127.0.0.1:6379>
5.设置自动增长的值
127.0.0.1:6379> SET count 0 OK 127.0.0.1:6379> INCR count (integer) 1 127.0.0.1:6379> INCR count (integer) 2 127.0.0.1:6379> INCR count (integer) 3