最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Redis主从复制简单配置教程详解
时间:2022-06-29 10:48:18 编辑:袖梨 来源:一聚教程网
主从复制
192.168.1.106 master机器
mkdir -p /data/redis
cp /etc/redis/redis.conf /etc/redis/redis-6379.conf
vim /etc/redis/redis-6379.conf
daemonize yes
pidfile /var/run/redis-6379.pid
port 6379
logfile "6379.log"
dbfilename "dump-6379.rdb"
dir "/data/redis"
appendonly yes
appendfilename "appendonly-6379.aof"
192.168.1.107 slave机器
mkdir -p /data/redis
cp /etc/redis/redis.conf /etc/redis/redis-6381.conf
vim /etc/redis/redis-6381.conf
daemonize yes
pidfile /var/run/redis-6381.pid
port 6381
logfile "6381.log"
dbfilename "dump-6381.rdb"
dir "/data/redis"
appendonly yes
appendfilename "appendonly-6381.aof"
连从服务器
[root@Slave redis]# redis-cli -p 6381
127.0.0.1:6381>
127.0.0.1:6381> dbsize
(integer) 0
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> get hello
"world"
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:192.168.1.106
master_port:6379
master_link_status:up
master_last_io_seconds_ago:9
master_sync_in_progress:0
slave_repl_offset:773
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
[root@Slave redis]# redis-cli -p 6381
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> config rewrite
再配置一个从服务器
[root@Slave redis]# cd /etc/redis/
[root@Slave redis]# ls
redis-6379.conf redis-6381.conf
[root@Slave redis]# sed 's/6381/6382/g' redis-6381.conf > redis-6382.conf
[root@Slave redis]# redis-server /etc/redis/redis-6382.conf
[root@Slave redis]# redis-cli -p 6382
127.0.0.1:6382> get hello
"world"
127.0.0.1:6382> info replication
# Replication
role:slave
master_host:192.168.1.106
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:3026
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6382>
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21