最新下载
热门教程
- 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>
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20