Drbd

如何查詢 DRBD 設備大小?

  • September 24, 2016

要編寫 Ansible 腳本來設置 DRBD 設備和文件系統,我面臨以下問題:

# blockdev --report /dev/drbd0
RO    RA   SSZ   BSZ   StartSec            Size   Device
blockdev: cannot open /dev/drbd0: Wrong medium type

我希望 DRBD 設備能夠像任何 md 設備一樣實現塊設備操作。

我用包執行 Debian Linux Jessie/stable

drbd-utils 8.9.2~rc1-2+deb8 amd64 RAID 1 over TCP/IP for Linux (user utilities)

有沒有辦法獲得可用的設備尺寸?

/dev/drbd0我的麻煩是在設備真正可用之前嘗試使用,也就是drbdadm cstate data確認它處於ConnectedSyncSource狀態時。

順便說一句,準備好後,blockdev操作就可以了/dev/drbd0,或者大小可以直接從/sys/block/drbd0/size

根據您的版本drbd utils,您可以使用:

drbdsetup status /dev/drbd0 --verbose --statistics

這將為您提供以下內容:

home node-id:1 role:Secondary suspended:no
   write-ordering:none
 volume:0 minor:0 disk:UpToDate
     size:1048412 read:0 written:1048412 al-writes:0 bm-writes:48 upper-pending:0 lower-pending:0 al-suspended:no blocked:no
 nina local:ipv4:10.9.9.111:7001 peer:ipv4:10.9.9.103:7010 node-id:0 connection:Connected role:Secondary
     congested:no
   volume:0 replication:Connected disk:UpToDate resync-suspended:no
       received:1048412 sent:0 out-of-sync:0 pending:0 unacked:0
 nino local:ipv4:10.9.9.111:7021 peer:ipv4:10.9.9.129:7012 node-id:2 connection:Connected role:Secondary
     congested:no
   volume:0 replication:Connected disk:UpToDate resync-suspended:no
       received:0 sent:0 out-of-sync:0 pending:0 unacked:0
 nono local:ipv4:10.9.9.111:7013 peer:ipv4:10.9.9.138:7031 node-id:3 connection:WFConnection

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