slaveof.ip
指定 master 的 IP 地址, 但對(duì)于新版本(1.9.2+), 你可以通過(guò) slaveof.host
指定 master 的主機(jī)名(域名).#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 個(gè)實(shí)例的 SSDB 實(shí)例群中, 每一個(gè)實(shí)例必須 slaveof 其余的 n-1 個(gè)實(shí)例.
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
當(dāng)前實(shí)例的寫(xiě)操作狀態(tài).
replication
可以有多條 replication
記錄. 每一條表示一個(gè)連接進(jìn)來(lái)的 slave(client), 或者一個(gè)當(dāng)前服務(wù)器所連接的 master(slaveof).
sync|mirror
.DISCONNECTED|INIT|OUT_OF_SYNC|COPY|SYNC
.關(guān)于 status:
對(duì)于 master, binlogs.max_seq
是指當(dāng)前實(shí)例上的最新一次的寫(xiě)(寫(xiě)/更新/刪除)操作的序號(hào), replication.client.last_seq
是指已發(fā)送給 slave 的最新一條 binlog 的序號(hào).
所以, 如果你想判斷主從同步是否已經(jīng)同步到位(實(shí)時(shí)更新), 那么就判斷 binlogs.max_seq
和 replication.client.last_seq
是否相等.
更多建議: