redis文档:www.redis.net.cn/
一、下载解压
wget http://download.redis.io/releases/redis-4.0.6.tar.gz tar xf redis-4.0.6.tar.gz -C /data/app cd redis-4.0.6
二、编译
yum -y install gcc gcc-c++ make make PREFIX=/data/app/redis install mkdir /data/appData/redis /data/logs/redis
三、修改配置
配置文件中bind 监听地址改为实际主机IP
vim 6379.conf
daemonize yes pidfile /data/pid/6379.pid port 6379 tcp-backlog 1024 bind 127.0.0.1 10.0.0.11 timeout 0 tcp-keepalive 120 loglevel notice logfile "/data/logs/redis/6379.log" databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename 6379.rdb dir /data/appData/redis slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 maxmemory 2g maxmemory-policy allkeys-lru appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
四、启动
/data/app/redis/bin/redis-server /data/app/redis/6379.conf
登陆客户端
[root@steven /data/app/redis] # /data/app/redis/bin/redis-cli -p 6379 127.0.0.1:6379>
五、添加开机自启
mkdir /etc/redis cp /data/app//redis/redis.conf /etc/redis/6379.conf cp /data/app/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd
vim /etc/init.d/redisd # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database
添加开机自启
chkconfig redisd on
service redis start
service redis stop # 需要修改启动脚本中的pid目录