Redis 4.0主從複製配置
Master: 192.168.174.201
Slave: 192.168.174.202
在兩臺伺服器上面安裝Redis,參考
http://blog.itpub.net/26506993/viewspace-2146826/
在主節點上,編輯配置檔案
[root@MySQL01 redis-4.0.2]# vim redis.conf
# 指定埠
port 6379
# 配置密碼
requirepass abc
# 監聽來自網路的所有連線
# bind 127.0.0.1
在從節點上,編輯配置檔案
[root@localhost redis-4.0.2]# vim redis.conf
# 配置主節點的IP和埠
slaveof 192.168.174.201 6379
# 配置連線到主庫所使用的密碼
masterauth abc
# 配置密碼
requirepass abc
# 監聽來自網路的所有連線
# bind 127.0.0.1
# 指定埠
port 6380
在主節點上,啟動redis
[root@MySQL01 redis-4.0.2]# src/redis-server redis.conf
51173:C 04 Nov 07:12:09.019 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
51173:C 04 Nov 07:12:09.019 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=51173, just started
51173:C 04 Nov 07:12:09.019 # Configuration loaded
在從節點上,啟動redis
[root@localhost redis-4.0.2]# src/redis-server /opt/redis-4.0.2/redis.conf
61391:C 04 Nov 07:14:10.695 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
61391:C 04 Nov 07:14:10.695 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=61391, just started
61391:C 04 Nov 07:14:10.695 # Configuration loaded
驗證複製
在主節點上面插入連結串列資料
[root@MySQL01 redis-4.0.2]# src/redis-cli -a abc
127.0.0.1:6379> rpush list-key item1
(integer) 1
127.0.0.1:6379> rpush list-key item2
(integer) 2
127.0.0.1:6379> rpush list-key item3
(integer) 3
127.0.0.1:6379> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
檢視複製狀態
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.174.202,port=6380,state=online,offset=1785,lag=0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1785
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1785
192.168.174.202:6380> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
檢視複製狀態
192.168.174.202:6380> info replication
# Replication
role:slave
master_host:192.168.174.201
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:1771
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1771
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1771
Slave: 192.168.174.202
在兩臺伺服器上面安裝Redis,參考
http://blog.itpub.net/26506993/viewspace-2146826/
在主節點上,編輯配置檔案
[root@MySQL01 redis-4.0.2]# vim redis.conf
# 指定埠
port 6379
# 配置密碼
requirepass abc
# 監聽來自網路的所有連線
# bind 127.0.0.1
[root@localhost redis-4.0.2]# vim redis.conf
# 配置主節點的IP和埠
slaveof 192.168.174.201 6379
# 配置連線到主庫所使用的密碼
masterauth abc
# 配置密碼
requirepass abc
# 監聽來自網路的所有連線
# bind 127.0.0.1
# 指定埠
port 6380
[root@MySQL01 redis-4.0.2]# src/redis-server redis.conf
51173:C 04 Nov 07:12:09.019 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
51173:C 04 Nov 07:12:09.019 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=51173, just started
51173:C 04 Nov 07:12:09.019 # Configuration loaded
[root@localhost redis-4.0.2]# src/redis-server /opt/redis-4.0.2/redis.conf
61391:C 04 Nov 07:14:10.695 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
61391:C 04 Nov 07:14:10.695 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=61391, just started
61391:C 04 Nov 07:14:10.695 # Configuration loaded
在主節點上面插入連結串列資料
[root@MySQL01 redis-4.0.2]# src/redis-cli -a abc
127.0.0.1:6379> rpush list-key item1
(integer) 1
127.0.0.1:6379> rpush list-key item2
(integer) 2
127.0.0.1:6379> rpush list-key item3
(integer) 3
127.0.0.1:6379> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
檢視複製狀態
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.174.202,port=6380,state=online,offset=1785,lag=0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1785
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1785
在從節點上面檢視連結串列資料
[root@localhost redis-4.0.2]# src/redis-cli -h 192.168.174.202 -p 6380 -a abc192.168.174.202:6380> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
檢視複製狀態
192.168.174.202:6380> info replication
# Replication
role:slave
master_host:192.168.174.201
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:1771
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1771
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1771
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2146831/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Redis replication主從複製原理及配置Redis
- Redis - 主從複製Redis
- Redis:主從複製Redis
- Redis主從複製Redis
- Dcoker教程之九配置Redis主從複製Redis
- Redis 主從複製原理Redis
- Redis 主從複製(Replication)Redis
- redis系列:主從複製Redis
- redis(14)主從複製Redis
- redis主從複製例子Redis
- mysql複製--主從複製配置MySql
- redis系列--主從複製以及redis複製演進Redis
- 【Redis】Redis 主從複製之一Redis
- 配置mysql5.5主從複製、半同步複製、主主複製MySql
- Redis系列(四):Redis的複製機制(主從複製)Redis
- Redis 主從複製與哨兵Redis
- redis 主從複製實現Redis
- redis-23.主從複製Redis
- Redis主從複製流程概述Redis
- Redis主從複製原理剖析Redis
- Redis-14-主從複製Redis
- Docker Redis映象 主從複製DockerRedis
- MySql 主從複製配置MySql
- MySQL主從複製配置MySql
- redis學習十四、Redis主從複製Redis
- 基於配置檔案的redis的主從複製Redis
- Redis 主從複製技術原理Redis
- Redis主從複製那點事Redis
- redis-23.主從複製-概念Redis
- redis持久化和主從複製Redis持久化
- 詳談Redis主從複製原理Redis
- Redis主從複製原理總結Redis
- redis的主從複製的原理Redis
- redis 深入理解redis 主從複製原理Redis
- MYSQL主從複製配置(整理)MySql
- MYSQL主從複製製作配置方案MySql
- Redis日常運維-02主從複製Redis運維
- Redis 主從複製詳細解讀Redis