安装gcc: yum install gcc -y
上传redis软件包到 /home下
解压: tar xf redis-3.2.11.tar.gz
进入 redis 目录 : cd redis-3.2.11
编译: make
返回home下 : cd /home
创建目录:
mkdir redis-sentinel
mkdir redis-sentinel/6379
mkdir redis-sentinel/6380
创建redis-cli 软链接:
ln -s /home/redis-3.2.11/src/redis-cli /usr/bin/
编写redis配置文件(注意所有ip地址改成自己虚拟机的ip!!!)
vi /home/redis-sentinel/6379/redis.conf
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/var/run/redis_6379.pid"
loglevel notice
logfile ""
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/redis-sentinel/6379"
masterauth "juziyanfa"
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
requirepass "juziyanfa"
appendonly yes
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-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
slaveof 192.168.121.228 6380
———————————————————————————————
vi /home/redis-sentinel/6379/sentinel.conf
bind 0.0.0.0
protected-mode yes
port 26379
daemonize yes
logfile "./sentinel.log"
dir "/tmp"
sentinel myid cce0dc9a6db63e09900b4a655e5b37e114b5b6d7
sentinel monitor mymaster 192.168.121.228 6380 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000
sentinel auth-pass mymaster juziyanfa
sentinel config-epoch mymaster 919
sentinel leader-epoch mymaster 3260
sentinel known-slave mymaster 192.168.121.228 6379
sentinel known-sentinel mymaster 192.168.121.228 26380 dce0dc9a6db63e09900b4a655e5b37e114b5b6d7
sentinel current-epoch 3260
——————————————————————————————————————————————
vi /home/redis-sentinel/6380/redis.conf
bind 0.0.0.0
protected-mode yes
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/var/run/redis_6380.pid"
loglevel notice
logfile ""
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/redis-sentinel/6380"
masterauth "juziyanfa"
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
requirepass "juziyanfa"
appendonly yes
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-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
————————————————————————————————————
vi /home/redis-sentinel/6380/sentinel.conf
bind 0.0.0.0
protected-mode yes
port 26380
daemonize yes
logfile "./sentinel.log"
dir "/tmp"
sentinel myid dce0dc9a6db63e09900b4a655e5b37e114b5b6d7
sentinel monitor mymaster 192.168.121.228 6380 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000
sentinel auth-pass mymaster juziyanfa
sentinel config-epoch mymaster 919
sentinel leader-epoch mymaster 3260
sentinel known-slave mymaster 192.168.121.228 6379
sentinel known-slave mymaster 192.168.0.121 6379
sentinel known-sentinel mymaster 192.168.121.228 26379 cce0dc9a6db63e09900b4a655e5b37e114b5b6d7
sentinel current-epoch 3260
——————————————————————————————————————
启动redis:
cd /home/redis-3.2.11/src/
./redis-server /home/redis-sentinel/6379/redis.conf
./redis-sentinel /home/redis-sentinel/6379/sentinel.conf
./redis-server /home/redis-sentinel/6380/redis.conf
./redis-sentinel /home/redis-sentinel/6380/sentinel.conf
ps -ef |grep redis
关闭防火墙
ss -ln 找到6379 和 6380端口就可以
redis:192.168.121.38 6379 auth:juziyanfa
26379 和 26380 中的protected-mode:no