码迷,mamicode.com
首页 > 其他好文 > 详细

redis2.8哨兵部署

时间:2020-12-05 10:46:39      阅读:5      评论:0      收藏:0      [点我收藏+]

标签:incr   end   parse   sshd   UNC   ref   databases   auto   monit   

[root@www_test ~]# cd /root/redis2
[root@www_test redis2]# tar -xf redis-2.8.18.tar.gz
[root@www_test redis2]# cd redis-2.8.18
[root@www_test redis-2.8.18]# make
[root@www_test redis-2.8.18]# cd src && make install PREFIX=/opt/redis
[root@www_test src]# mkdir /opt/redis/etc
[root@www_test redis]# cp -r /root/redis2/redis-2.8.18/redis.conf /opt/redis/etc/
[root@www_test redis]# egrep "^bind|^daemon" /opt/redis/etc/redis.conf
daemonize yes
bind 192.168.19.157
[root@www_test redis]#
[root@www_test redis]# egrep -v "#|^$" /opt/redis/etc/redis.conf
daemonize yes
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
bind 192.168.19.157
timeout 0
tcp-keepalive 0
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 ./
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
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
[root@www_test redis]# /opt/redis/bin/redis-server /opt/redis/etc/redis.conf
[root@www_test redis]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.19.157:6379 0.0.0.0:* LISTEN 16069/redis-server
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6557/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6757/master
tcp6 0 0 :::22 :::* LISTEN 6557/sshd
tcp6 0 0 ::1:25 :::* LISTEN 6757/master
[root@www_test redis]#


配置从库,只需要在主库基础上最后一行添加一条命令。
slaveof 192.168.19.157 6379

[root@www opt]# /opt/redis/bin/redis-cli -h 192.168.19.157 -p 6379 info Replication
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.19.154,port=6379,state=online,offset=85,lag=1

22
配置哨兵信息。
[root@www_test opt]# cp -r /root/redis2/redis-2.8.18/sentinel.conf /opt/redis/etc/
创建哨兵临时目录,可以是空目录。
[root@www_test opt]# mkdir -p /opt/redis/sentinel-tmp
[root@www_test opt]#
[root@www_test opt]# cat /opt/redis/etc/sentinel.conf
daemonize yes
#protected-mode no
port 26379
dir "/opt/redis/sentinel-tmp"
sentinel monitor my-shaobin-test 192.168.19.157 6379 2
sentinel auth-pass my-shaobin-test sunny123
sentinel down-after-milliseconds my-shaobin-test 30000
sentinel parallel-syncs my-shaobin-test 1
sentinel failover-timeout my-shaobin-test 180000
[root@www_test opt]#

注意,哨兵配置一模一样的。
[root@www opt]# /opt/redis/bin/redis-cli -h 192.168.19.157 -p 26379 info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=my-shaobin-test,status=ok,address=192.168.19.157:6379,slaves=1,sentinels=2
[root@www opt]#
[root@www opt]# /opt/redis/bin/redis-cli -h 192.168.19.154 -p 26379 info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=my-shaobin-test,status=ok,address=192.168.19.157:6379,slaves=1,sentinels=2

 


22222222


11

 

 

 

 

22

redis2.8哨兵部署

标签:incr   end   parse   sshd   UNC   ref   databases   auto   monit   

原文地址:https://www.cnblogs.com/sunnyyangwang/p/14065598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!