Redis服务就不用多介绍,除了通过apt-get方式直接从软件源安装外,还可以通过源码包编译安装,本文以redis-2.8.7.tar.gz源码包为例。
1、安装:
上传redis-2.8.7.tar.gz包到/home/itrst/software目录
cd /home/itrst/software
tar -zxf redis-2.8.7.tar.gz
cd redis
make MALLOC=libc
2、配置文件:
cd /home/itrst/software/redis-2.8.7
vi redis.conf
daemonize no
pidfile /var/run/redis.pid
port 6379
bind 0.0.0.0
timeout 300
tcp-keepalive 0
loglevel verbose
logfile /home/itrst/software/redis-2.8.7/log/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /home/itrst/software/redis-2.8.7/data
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
maxmemory 3221225472
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
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
activerehashing yes
maxclients 12800
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
#requirepass 123456
3、创建日志和数据路径:
mkdir -p /home/itrst/software/redis-2.8.7/log
mkdir -p /home/itrst/software/redis-2.8.7/data
4、启动redis:
Support 用户
/home/itrst/software/redis-2.8.7/src/redis-server /home/itrst/software/redis-2.8.7/redis.conf
添加开机启动项:
echo “/home/itrst/software/redis-2.8.7/src/redis-server /home/itrst/software/redis-2.8.7/redis.conf
” >> /etc/rc.local
5、redis 主从同步配置:
redis从库配置文件redis.conf添加如下内容即可:
slaveof 200.31.147.211 6379
masterauth 123456
说明:上述IP以实际环境配置为准