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參考
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
QuickRedis 是一款 永久免費 的 Redis 可視化管理工具
zhoudian2010
2022-03-25 16:55:09
Redis主從複製以及主從複製原理
LoyaltyLu
2019-02-24 23:12:38
Redis | 001能做什麼?
Java貓說
2019-02-24 21:03:51
數據工程師妹子養成手記——數據庫篇
青南
2019-02-23 16:33:37
redis數據庫隨筆
simuls
2019-02-23 13:34:47
redis慢查詢日誌,php安裝redis擴展,redis存儲session,redis主從配置
13011150876
2019-02-23 00:41:11
redis慢查詢日誌,php安裝redis擴展,redis存儲session,redis主從配置
13011150876
2019-02-23 00:41:10
Redis 學習筆記
jasonhow
2019-02-23 00:39:36
Jedis連接池的使用
殺神之瘋子
2019-02-23 00:35:12
python 實現類似tweproxy 和codes的功能的redis代理功能
tianshuai369
2019-02-23 00:34:58
關於Mac安裝PHP相關擴展出現Zend/zend_config.h缺失的問題記錄
乄尐
2019-02-23 00:34:32
安裝redis支持php擴展
yfshare
2019-02-23 00:31:38
又一次redis被刪庫跑路,索要0.6比特幣
冷暖己知
2019-02-23 00:29:40
在Windows系統上安裝Redis
飛魚之戀
2019-02-23 00:27:22
關於創建SWAP示例
llb988
2019-02-23 00:42:04