2016年2月5日

離線延伸DRBD磁碟 - internal meta data & without LVM

由於internal meta data必須存放於磁區的最後面,按照官方的手冊說明需要手動處理metadata的延伸,但我照著做之後一啟動DRBD就會造成系統當機,後來參考 http://www.ogris.de/drbd/ 的流程才成功,若按照官網手冊有遇到問題的人, 不妨試試以下的方法。建議先在測試環境試過,別貿然在正式環境處理。

注意:以下的步驟是有一定風險的,請務必做好資料備份

實做環境
CentOS 6 x86_64
ESXi 6.0 U1
DRBD-8.3 (elrepo)
heartbeat
檔案系統格式: ext4
----------------------------------------------------------------------------

預設狀態
node1的DRBD狀態為primary
node2的DRBD狀態為secondary

 步驟一
通常DRBD會搭配heartbeat或crm等叢集套件使用,先將node2的開機啟動服務停掉
node2>#chkconfig drbd off
node2>#chkconfig heartbeat off

步驟二
將node2主機關機,然後透過ESXi的管理介面,並加大虛擬硬碟。請注意這個時候node1還在正常運作,且角色為 primary。
node2>#poweroff

步驟三
啟動node2的電源開機

步驟四
將node2的磁碟進行延伸。用parted可以看到/dev/sda已經由原本的32.2GB變成42.9GB。
 Model: VMware Virtual disk (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  8423MB  8422MB  primary  ext4            boot
 2      8423MB  9476MB  1053MB  primary  linux-swap(v1)
 3      9476MB  32.2GB  22.7GB  primary  ext4
將原本的/dev/sda3磁區刪除並重建。
node1&2>#  parted /dev/sda
parted> rm 3
parted> mkpart primary ext4 9476M 100%
parted> quit
node1&2># reboot

步驟五
手動啟動DRBD服務
node2># service drbd start
Starting DRBD resources: [ r0
Moving the internal meta data to its proper location
Internal drbd meta data successfully moved.
d(r0) s(r0) n(r0) ].

啟動後請確認 drbd 連線狀態是否已經正常
node2># cat /proc/drbd
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by mockbuild@builder10.centos.org, 2013-03-27 16:01:26
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:340 nr:8 dw:348 dr:33 al:5 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b
oos:0
手動啟動 heartbeat
node2># service heartbeat start
啟動後請確認heartbeat紀錄檔有以下資訊
info: Ping node count is balanced.

 步驟六
復原node2的開機啟動服務設定
node2>#chkconfig drbd on
node2>#chkconfig heartbeat on

 步驟七
再來處理node1,基本上就是重複之前在node2執行的動作
先關閉開機啟動服務。
node1>#chkconfig drbd off
node1>#chkconfig heartbeat off

 步驟八
 將node1關機,然後透過ESXi介面加大硬碟。注意這個時候 node2還在運作中,由於有啟動 heartbeat的關係,node2會被提昇為primary。

步驟九
啟動node1的電源開機

步驟十
 一樣用parted工具處理磁碟延伸,方式同步驟四。

步驟十一
手動啟動node1的DRBD服務
node1>#service drbd start
Starting DRBD resources: [ r0
Moving the internal meta data to its proper location
Internal drbd meta data successfully moved.
d(r0) s(r0) n(r0) ].

執行以下指令,你會發現DRBD在進行同步
node1>#cat /proc/drbd

查看/var/log/messages紀錄可發現以下訊息
kernel: block drbd0: drbd_bm_resize called with capacity == ......
手動啟動heartbeat,記得確認狀態,方法同步驟五
node1>#service heartbeat start

 步驟十二
 趁著還在同步,先復原node1的開機啟動設定
node1>#chkconfig drbd on
node2>#chkconifg heartbeat on

步驟十三
於同步完成後,在DRBD primary主機(node2)延伸檔案系統
node2>#umount /mnt
node2>#e2fsck -f /dev/drbd0
node2>#resize2fs /dev/drbd0

步驟十四
掛載磁區檢查磁碟大小是否延伸,且資料是否存在
node2>#mount -t ext4 /dev/drbd0 /mnt
node2>#df -h

沒有留言:

張貼留言