发布于 2016-10-18 12:56:27 | 152 次阅读 | 评论: 0 | 来源: PHPERZ
slaveof.ip
指定 master 的 IP 地址, 但对于新版本(1.9.2+), 你可以通过 slaveof.host
指定 master 的主机名(域名).#server 1
replication:
slaveof:
#server 2
replication:
slaveof:
id: svc_1
# sync|mirror, default is sync
type: sync
# use ip for older version
#ip: 127.0.0.1
# use host since 1.9.2
host: localhost
port: 8888
#server 1
replication:
slaveof:
id: svc_2
# sync|mirror, default is sync
type: mirror
# use ip for older version
#ip: 127.0.0.1
# use host since 1.9.2
host: localhost
port: 8889
#server 2
replication:
slaveof:
id: svc_1
# sync|mirror, default is sync
type: mirror
# use ip for older version
#ip: 127.0.0.1
# use host since 1.9.2
host: localhost
port: 8888
在一组一共包含 n 个实例的 SSDB 实例群中, 每一个实例必须 slaveof 其余的 n-1 个实例.
replication:
slaveof:
id: svc_1
# sync|mirror, default is sync
type: mirror
# use ip for older version
#ip: 127.0.0.1
# use host since 1.9.2
host: localhost
port: 8888
slaveof:
id: svc_2
# sync|mirror, default is sync
type: mirror
# use ip for older version
#ip: 127.0.0.1
# use host since 1.9.2
host: localhost
port: 8889
# ... more slaveof
ssdb 127.0.0.1:8899> info
binlogs
capacity : 10000000
min_seq : 1
max_seq : 74
replication
client 127.0.0.1:55479
type : sync
status : SYNC
last_seq : 74
replication
slaveof 127.0.0.1:8888
id : svc_2
type : sync
status : SYNC
last_seq : 10023
copy_count : 0
sync_count : 44
binlogs
当前实例的写操作状态.
replication
可以有多条 replication
记录. 每一条表示一个连接进来的 slave(client), 或者一个当前服务器所连接的 master(slaveof).
sync|mirror
.DISCONNECTED|INIT|OUT_OF_SYNC|COPY|SYNC
.关于 status:
对于 master, binlogs.max_seq
是指当前实例上的最新一次的写(写/更新/删除)操作的序号, replication.client.last_seq
是指已发送给 slave 的最新一条 binlog 的序号.
所以, 如果你想判断主从同步是否已经同步到位(实时更新), 那么就判断 binlogs.max_seq
和 replication.client.last_seq
是否相等.