redis教程

redis 命令,redis入门指南,redis 安装,redis教程,redis视频教程,redis pdf电子书下载,redis免费视频教程,redis视频教程下载

redis主从从架构搭建-redis集群管理

2016-07-18| 发布: | 浏览: 1108 |保存PDF

主从从架构


[root@master redis-master-slave]# vim 6382/redis.conf

slaveof 127.0.0.1 6381


分别启动三台redis-server
[root@master redis-master-slave]# /usr/local/bin/redis-server /opt/redis/redis-master-slave/6380/redis.conf
[root@master redis-master-slave]# /usr/local/bin/redis-server /opt/redis/redis-master-slave/6381/redis.conf
[root@master redis-master-slave]# /usr/local/bin/redis-server /opt/redis/redis-master-slave/6382/redis.conf


查看主节点的主从信息

127.0.0.1:6380> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=477,lag=1
master_repl_offset:477
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:476


查看从节点的主从信息

127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6380
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_repl_offset:477
slave_priority:100
slave_read_only:1
connected_slaves:1
slave0:ip=127.0.0.1,port=6382,state=online,offset=477,lag=1
master_repl_offset:477
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:476


查看从从节点的主从信息

127.0.0.1:6382> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6381
master_link_status:up
master_last_io_seconds_ago:5
master_sync_in_progress:0
slave_repl_offset:491
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


测试主从

主库设置一个key
127.0.0.1:6380> set k2 xxx
OK
127.0.0.1:6380> get k2
"xxx"
从库和从从库分别获取
127.0.0.1:6381> get k2
"xxx"
127.0.0.1:6382> get k2
"xxx"


书生学习整理


系列教程

大家都在看

热门访问