Redis日常運維-02主從複製
Redis日常運維-02主從複製
一 Redis安裝
二 Redis主從複製
三 Redis哨兵模式高可用架構
四 Redis-cluster群集高可用架構
五 常見問題
架構
主 192.168.2.222
從 192.168.2.187
從 192.168.2.188
從庫配置檔案新增:
從 192.168.2.187
從 192.168.2.188
[root@rac1 config]# pwd
/usr/local/redis/config
[root@rac1 config]# vim redis.conf
#新增
slaveof 192.168.2.222 6379
重啟資料庫
[root@rac1 config]# redis-cli -p 6379 shutdown
[root@rac1 config]# redis-server redis.conf
驗證資料同步
主庫2.222
[root@cjcos src]# redis-cli
127.0.0.1:6379> set station dba
OK
127.0.0.1:6379> get station
"dba"
從庫2.187
[root@rac1 config]# redis-cli
127.0.0.1:6379> get station
"dba"
從庫2.188
[root@rac2 config]# redis-cli
127.0.0.1:6379> get station
"dba"
主庫2.222檢視同步資訊
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.2.187,port=6379,state=online,offset=11208,lag=1
slave1:ip=192.168.2.188,port=6379,state=online,offset=11208,lag=1
master_replid:231ff9d15411b50038a43bb0726580f4dd788f80
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:11208
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:11208
同步日誌
主庫2.222
----redis.log
8511:M 23 Mar 2020 14:53:51.841 * Background saving terminated with success
8511:M 23 Mar 2020 14:53:51.842 * Synchronization with replica 192.168.2.187:6379 succeeded
8511:M 23 Mar 2020 14:53:57.272 * Replica 192.168.2.188:6379 asks for synchronization
8511:M 23 Mar 2020 14:53:57.272 * Full resync requested by replica 192.168.2.188:6379
8511:M 23 Mar 2020 14:53:57.272 * Starting BGSAVE for SYNC with target: disk
8511:M 23 Mar 2020 14:53:57.272 * Background saving started by pid 8528
8528:C 23 Mar 2020 14:53:57.326 * DB saved on disk
8528:C 23 Mar 2020 14:53:57.327 * RDB: 0 MB of memory used by copy-on-write
常見問題:
同步失敗,日誌如下:
----redis.log
29884:S 23 Mar 2020 14:50:29.152 * Connecting to MASTER 192.168.2.222:6379
29884:S 23 Mar 2020 14:50:29.152 * MASTER <-> REPLICA sync started
29884:S 23 Mar 2020 14:50:29.152 * Non blocking connect for SYNC fired the event.
29884:S 23 Mar 2020 14:50:29.153 # Error reply to PING from master: '-DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect '
解決方案:
---配置檔案 redis.conf新增:
bind 0.0.0.0
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2682150/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB日常運維-03主從複製搭建MongoDB運維
- MySQL運維2-主從複製MySql運維
- Redis - 主從複製Redis
- Redis:主從複製Redis
- Redis主從複製Redis
- Redis 主從複製原理Redis
- Redis 主從複製(Replication)Redis
- redis系列:主從複製Redis
- redis(14)主從複製Redis
- redis主從複製例子Redis
- redis系列--主從複製以及redis複製演進Redis
- 【Redis】Redis 主從複製之一Redis
- Redis系列(四):Redis的複製機制(主從複製)Redis
- Redis 主從複製與哨兵Redis
- redis 主從複製實現Redis
- redis-23.主從複製Redis
- Redis主從複製流程概述Redis
- Redis主從複製原理剖析Redis
- Redis-14-主從複製Redis
- Redis 4.0主從複製配置Redis
- Docker Redis映象 主從複製DockerRedis
- redis學習十四、Redis主從複製Redis
- Redis 主從複製技術原理Redis
- Redis主從複製那點事Redis
- redis-23.主從複製-概念Redis
- redis持久化和主從複製Redis持久化
- 詳談Redis主從複製原理Redis
- Redis主從複製原理總結Redis
- redis的主從複製的原理Redis
- redis 深入理解redis 主從複製原理Redis
- Redis 主從複製詳細解讀Redis
- Redis replication主從複製原理及配置Redis
- redis-24.主從複製-實操Redis
- redis建立主從複製的過程Redis
- 故障分析 | Redis 主從複製風暴Redis
- Redis搭建主從複製、哨兵叢集Redis
- redis主從複製幾種結構Redis
- 深入學習 Redis(3):主從複製Redis