redis-2.8.12的安装与使用
redis的安装
#pwd
/home/ybtang/
#wget http://download.redis.io/releases/redis-2.8.12.tar.gz
#tar zxvf redis-2.8.12.tar.gz
#cd redis-2.8.12
#make
redis的配置
#vim redis.conf
修改daemonize no为daemonize yes,让其后台运行
修改logfile "" 为logfile "/home/ybtang/redis-2.8.12/log/redis.log",指定日志输出文件
redis的启动
#src/redis-server ./redis.conf
redis的日志查看
#cat log/redis.log
[25947] 16 Nov 14:47:10.010 # Warning: no config file specified, using the default config. In order to specify a
config file use src/redis-server /path/to/redis.conf
[25947] 16 Nov 14:47:10.011 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[25947] 16 Nov 14:47:10.011 # Redis can't set maximum open files to 10032 because of OS error: Operation not
permitted.
[25947] 16 Nov 14:47:10.011 # Current maximum open files is 1024. maxclients has been reduced to 992 to compensate
for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.12 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 25947
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[25947] 16 Nov 14:47:10.013 # Server started, Redis version 2.8.12
[25947] 16 Nov 14:47:10.014 # 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.
[25947] 16 Nov 14:47:10.014 * The server is now ready to accept connections on port 6379
redis启动成功,端口号为6379
redis的访问
在令一个终端中启动redis客户端
# src/redis-cli
127.0.0.1:6379> set name tang
127.0.0.1:6379> set sex f
127.0.0.1:6379> set age 20
127.0.0.1:6379> get name
"tang"
127.0.0.1:6379> get sex
"f"
127.0.0.1:6379> get age
"20"
redis的停止
# src/redis-cli
127.0.0.1:6379>shutdown