Linux

DRBD 在我的節點之間不同步

  • August 28, 2015

一些版本資訊:

Operating system is Ubuntu 11.10, on EC2, kernel is 3.0.0-16-virtual and the application info is:

Version: 8.3.11 (api:88)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by buildd@allspice, 2011-07-05 19:51:07

在 dmesg 中也出現了一些奇怪的錯誤(見下文),沒有複製發生。我已將我的第一個節點設為主要節點及其顯示:

drbd driver loaded OK; device status:
version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2 
m:res  cs          ro               ds                 p       mounted  fstype
0:r0   StandAlone  Primary/Unknown  UpToDate/DUnknown  r----s  ext3

我的輔助節點顯示:

drbd driver loaded OK; device status:
version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2 
m:res  cs          ro                 ds                     p       mounted  fstype
0:r0   StandAlone  Secondary/Unknown  Inconsistent/DUnknown  r----s

在 master 上顯示 /proc/drbd 顯示:

version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2 
0: cs:StandAlone ro:Primary/Unknown ds:UpToDate/DUnknown   r----s
   ns:0 nr:0 dw:4 dr:1073 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:262135964

在從站上顯示 /proc/drbd 表明沒有任何內容被傳輸…

version: 8.3.11 (api:88/proto:86-96)
srcversion: DA5A13F16DE6553FC7CE9B2 
0: cs:StandAlone ro:Secondary/Unknown ds:Inconsistent/DUnknown   r----s
   ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:262135964

這是我的配置…

resource r0 {
   protocol C;
   startup {
       wfc-timeout  15;
       degr-wfc-timeout 60;
   }
   net {
       cram-hmac-alg sha1;
       shared-secret "test123;
   }
   on drbd01 {
       device /dev/drbd0;
       disk /dev/xvdm;
       address 23.XX.XX.XX:7788; # blocked out ip
       meta-disk internal;
   }
   on drbd02 {
       device /dev/drbd0;
       disk /dev/xvdm;
       address 184.XX.XX.XX:7788; #blocked out ip
       meta-disk internal;
   }
} 

我在主人身上執行了以下內容:

sudo drbdadm -- --overwrite-data-of-peer primary all

系統之間沒有防火牆。

這是有一些錯誤的 dmesg:

[2285172.969955] drbd: initialized. Version: 8.3.11 (api:88/proto:86-96)
[2285172.969960] drbd: srcversion: DA5A13F16DE6553FC7CE9B2 
[2285172.969962] drbd: registered as block device major 147
[2285172.969965] drbd: minor_table @ 0xffff88000276ea00
[2285173.000952] block drbd0: Starting worker thread (from drbdsetup [1300])
[2285173.003971] block drbd0: disk( Diskless -> Attaching ) 
[2285173.006150] block drbd0: No usable activity log found.
[2285173.006154] block drbd0: Method to ensure write ordering: flush
[2285173.006158] block drbd0: max BIO size = 4096
[2285173.006165] block drbd0: drbd_bm_resize called with capacity == 524271928
[2285173.008512] block drbd0: resync bitmap: bits=65533991 words=1023969 pages=2000
[2285173.008518] block drbd0: size = 250 GB (262135964 KB)
[2285173.079566] block drbd0: bitmap READ of 2000 pages took 17 jiffies
[2285173.081189] block drbd0: recounting of set bits took additional 1 jiffies
[2285173.081194] block drbd0: 250 GB (65533991 bits) marked out-of-sync by on disk bit-map.
[2285173.081203] block drbd0: Suspended AL updates
[2285173.081210] block drbd0: disk( Attaching -> UpToDate ) 
[2285173.081214] block drbd0: attached to UUIDs 1C1291D39584C1D1:0000000000000004:0000000000000000:0000000000000000
[2285173.095016] block drbd0: conn( StandAlone -> Unconnected ) 
[2285173.095046] block drbd0: Starting receiver thread (from drbd0_worker [1301])
[2285173.099297] block drbd0: receiver (re)started
[2285173.099304] block drbd0: conn( Unconnected -> WFConnection ) 
[2285173.099330] block drbd0: bind before connect failed, err = -99
[2285173.099346] block drbd0: conn( WFConnection -> Disconnecting ) 
[2285173.295788] block drbd0: Discarding network configuration.
[2285173.295815] block drbd0: Connection closed
[2285173.295826] block drbd0: conn( Disconnecting -> StandAlone ) 
[2285173.295840] block drbd0: receiver terminated
[2285173.295844] block drbd0: Terminating drbd0_receiver

編輯:

閱讀了一些其他類似的問題,建議做一個’drbdadm dump all’,所以我認為它不會受到傷害。

ubuntu@drbd01:~$ drbdadm dump all
/etc/drbd.conf:19: in resource r0, on drbd01:
   IP 23.XX.XX.XX not found on this host.

在奴隸上:

root@drbd02:~# drbdadm dump all
/etc/drbd.conf:25: in resource r0, on drbd02:
   IP 184.XX.XX.XX not found on this host.

奇怪的是它沒有找到自己的 ip,但是,這是一個使用彈性 IP 的 Amazon EC2 系統……這是我的 ipconfigs ……

掌握:

ubuntu@drbd01:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 22:00:0a:1c:27:11  
         inet addr:10.28.39.17  Bcast:10.28.39.63  Mask:255.255.255.192
         inet6 addr: fe80::2000:aff:fe1c:2711/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:1569 errors:0 dropped:0 overruns:0 frame:0
         TX packets:1169 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000 
         RX bytes:124409 (124.4 KB)  TX bytes:213601 (213.6 KB)
         Interrupt:26 

lo        Link encap:Local Loopback  
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0 
         RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

奴隸:

root@drbd02:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 12:31:3f:00:14:9d  
         inet addr:10.160.27.107  Bcast:10.160.27.255  Mask:255.255.254.0
         inet6 addr: fe80::1031:3fff:fe00:149d/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:915 errors:0 dropped:0 overruns:0 frame:0
         TX packets:774 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000 
         RX bytes:75381 (75.3 KB)  TX bytes:109673 (109.6 KB)
         Interrupt:26 

lo        Link encap:Local Loopback  
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0 
         RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

你實際上不需要執行sudo drbdadm -- --overwrite-data-of-peer primary all

只要 /dev/drbd 你應該已經做了以下

Step01)sudo service mysql stop在 DRBD Primary 上,因此不會堆積額外的更改以供 DRBD 同步

Step02)sudo drbdadm connect all在 DRBD Secondary 上

Step03)sudo cat /proc/drbd在 DRBD Secondary 上確保連接統計資訊是WFConnection

Step04)sudo drbdadm connect all在 DRBD Primary 上

Step05)sudo cat /proc/drbd在 DRBD Primary 上確保連接狀態為SyncTarget.

Step06)sudo service mysql stop在 DRBD Primary 上,以便 MySQL 可以備份。同步將繼續。您不必在步驟 05 中等待 DRBD 完全同步。

警告

DRBD 不應該在地理距離上使用。我使用通過 192.168.xx 上的交叉電纜連接 DRBD 對的設置。

引用自:https://serverfault.com/questions/371813