centos7环境下编译安装redis5.0.9
centos7环境下编译安装redis5.0.9
1.编译安装redis-5.0.9
# 安装redis6.0.8 出错,看提示是要升级gcc,于是作罢
yum install tcl -y
# 下载编译安装redis5.0.9
cd /usr/local
wget http://download.redis.io/releases/redis-5.0.9.tar.gz
tar xf redis-5.0.9.tar.gz
cd redis-5.0.9
make && make install
cd /usr/local
rm -f redis
ln -s redis-5.0.9 redis
# mkdir /usr/local/redis-5.0.9/logs
# mkdir /usr/local/redis-5.0.9/bin
cp /usr/local/redis-5.0.9/redis-server /usr/local/redis-5.0.9/bin
cp /usr/local/redis-5.0.9/redis-cli /usr/local/redis-5.0.9/bin
2.修改redis的配置
# 配置修改
[root@eus-image-design-api01:/usr/local/redis]# egrep -v '^#|^$' redis.conf
# 本机ip bind 172.30.0.111 protected-mode no # 监听端口 port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no loglevel notice logfile "/usr/local/redis-5.0.9/logs/redis.log" databases 16 always-show-logo yes save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /data/redis_data # 设置密码 masterauth pass requirepass pass rename-command FLUSHALL "" rename-command FLUSHDB "" rename-command shutdown "" rename-command CONFIG "configx" 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 6GB lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no slave-lazy-flush no 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 aof-use-rdb-preamble no 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-size -2 list-compress-depth 0 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
3.配置启动文件
# vim /usr/lib/systemd/system/redis.service
[Unit] Description=nginx scripts After=network.target remote-fs.target nss-lookup.target syslog.target [Service] Type=forking Password=pass PidPort=6379 ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf ExecStop=/usr/local/redis/bin/redis-cli -a ${Password} -p ${PidPort} shutdown [Install] WantedBy=multi-user.target
主从配置:
redis master配置: [/usr/local]# egrep -v '^#|^$' redis/redis.conf bind 10.94.166.84 protected-mode no port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no loglevel notice logfile "/usr/local/redis-5.0.9/logs/redis.log" databases 16 always-show-logo yes save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /data/redis_data masterauth redispass requirepass redispass rename-command FLUSHALL "" rename-command FLUSHDB "" rename-command shutdown "" rename-command CONFIG "configx" 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 4GB lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no slave-lazy-flush no 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 aof-use-rdb-preamble no 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-size -2 list-compress-depth 0 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 redis slave配置: bind 10.94.166.109 protected-mode no port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no loglevel notice logfile "/usr/local/redis-5.0.9/logs/redis.log" databases 16 always-show-logo yes save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /data/redis_data masterauth redispass requirepass redispass rename-command FLUSHALL "" rename-command FLUSHDB "" rename-command shutdown "" rename-command CONFIG "configx" # 主从的配置 replicaof eus.ibm.media_io.master.prod.redis 6379 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 4GB lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no slave-lazy-flush no 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 aof-use-rdb-preamble no 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-size -2 list-compress-depth 0 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