我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

redis创建sentinel参考-创新互联

1.redis主从创建(一主两从):
在从节点上执行:slaveof 192.168.56.201 6379  #master的ip地址和端口
也可以在配置文件中配置:
slaveof 192.168.56.201 6379

确认:
[root@db1 ~]# redis-cli
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.56.202,port=6379,state=online,offset=1344537,lag=0
slave1:ip=192.168.56.203,port=6379,state=online,offset=1344537,lag=0
master_replid:78461067504e80e7adf61bd14ea1a385c38ca20c
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1344688
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:10485760
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1344688
 

2.创建目录:
mkdir -p /data/redis-26379/logs/
mkdir -p /data/redis-26379/run

3.编辑哨兵参数(scp都其它两个机器):
vim /data/redis-26379/26379.conf

port  26379
daemonize yes
dir /data/redis-26379/
pidfile /data/redis-26379/redis_26379.pid
logfile /data/redis-26379/logs/26379.log
#bind填写本机ip地址和127.0.0.1
bind 192.168.56.201 127.0.0.1
sentinel monitor master-monitor1 192.168.56.201 6379 2
sentinel down-after-milliseconds master-monitor1 10000
sentinel parallel-syncs master-monitor1 1
sentinel failover-timeout master-monitor1 180000

4.启动哨兵节点:
redis-sentinel /data/redis-26379/26379.conf

登录查看信息:
redis-cli -p 26379

127.0.0.1:26379> info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=master-monitor1,status=ok,address=192.168.56.201:6379,slaves=2,sentinels=3

此时看到哨兵配置文件已经改变,自动发现slave:
[root@db1 redis-26379]# cat 26379.conf
port 26379
daemonize yes
dir "/data/redis-26379"
pidfile "/data/redis-26379/redis_26379.pid"
logfile "/data/redis-26379/logs/26379.log"
#bind 信息填写本机ip地址 和127.0.0.1
bind 192.168.56.201 127.0.0.1
sentinel myid 6ba1b2245916983baabaacf1be1eb0303a2a1b8b
sentinel deny-scripts-reconfig yes
sentinel monitor master-monitor1 192.168.56.202 6379 2
sentinel down-after-milliseconds master-monitor1 10000
# Generated by CONFIG REWRITE
sentinel config-epoch master-monitor1 2
sentinel leader-epoch master-monitor1 2
sentinel known-slave master-monitor1 192.168.56.201 6379
sentinel known-slave master-monitor1 192.168.56.203 6379
sentinel known-sentinel master-monitor1 192.168.56.203 26379 67202a457efa3d68e5ada2912375e40a0c9b5262
sentinel known-sentinel master-monitor1 192.168.56.202 26379 7a089d3c9e68851cc70c6c24c51df829a910195e

创新互联建站服务项目包括瓯海网站建设、瓯海网站制作、瓯海网页制作以及瓯海网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,瓯海网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到瓯海省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
网页名称:redis创建sentinel参考-创新互联
网页地址:http://shouzuofang.com/article/dcegji.html

其他资讯