歡迎您光臨本站 註冊首頁

虛擬機(2*RHEL4U5)里搭建drbd環境(5樓是配置過程)

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

虛擬機(2*RHEL4U5)里搭建drbd環境(5樓是配置過程)

剛配置好drbd,使用drbdsetup /dev/drbd0 disk /dev/xvdb1命令的時候提示:

Missing argument 'meta_data_dev'
USAGE:
disk lower_dev meta_data_dev meta_data_index [{--size|-d} 0 ... 8587575296]
     [{--on-io-error|-e} {pass_on|call-local-io-error|detach}]
     [{--fencing|-f} {dont-care|resource-only|resource-and-stonith}] [{--use-bmbv|-b}]


不知道meta_data_dev這個參數應該怎麼寫?

我的/etc/drbd.conf文件:

global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
        protocol C;
        net {
        }
        on thost1 {
                device    /dev/drbd1;
                disk      /dev/xvdb1;
                address   192.168.64.65:7789;
                meta-disk  internal;
        }
        on thost2 {
                device    /dev/drbd1;
                disk      /dev/xvdb1;
                address   192.168.64.24:7789;
                meta-disk  internal;
        }
}


[ 本帖最後由 sailer_sh 於 2007-7-4 11:59 編輯 ]
《解決方案》

1 你有/dev/drbd0這個設備么?
2 你的配置文件中是/dev/drbd1

/dev/drbd0需要自己創建:
mknod –m 0660/dev/drb0 b 147 0
《解決方案》

原帖由 crackpot 於 2007-6-26 11:11 發表於 2樓  
1 你有/dev/drbd0這個設備么?
2 你的配置文件中是/dev/drbd1

/dev/drbd0需要自己創建:
mknod –m 0660/dev/drb0 b 147 0

我把配置文件中的/dev/drbd1全部改成/dev/drbd0,mknod了這個設備,然後再執行drbdsetup /dev/drbd0 disk /dev/xvdb1時依然提示Missing argument 'meta_data_dev'
《解決方案》

前面寫配置文件的時候犯了個低級錯誤,主機名都寫錯了。。。
修正了配置文件:

global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
        protocol C;
        net {
        }
        on rhel4_1 {
                device    /dev/drbd0;
                disk      /dev/xvdb1;
                address   192.168.64.65:7789;
                meta-disk  internal;
        }
        on rhel4_2 {
                device    /dev/drbd0;
                disk      /dev/xvdb1;
                address   192.168.64.24:7789;
                meta-disk  internal;
        }
}


先初始化meta-data area:

drbdadm create-md r0


未完待續。。。
《解決方案》

1. Xen下安裝兩個RHEL4U5,並各分配一塊500兆的硬碟(/dev/xvdb):
在宿主機上建立兩個塊文件:
dd if=/dev/zero of=rhel4_1_1 bs=1k seek=500k count=1
dd if=/dev/zero of=rhel4_2_1 bs=1k seek=500k count=1

在虛擬機的配置文件中加入對這兩個塊文件的描述部分,以下是兩個虛擬機的配置文件:
/etc/xen/rhel4_1:

# Automatically generated xen config file
name = "rhel4_1"
memory = "256"
disk = [ 'tap:aio:/xen/rhel4_1,xvda,w', 'tap:aio:/xen/rhel4_1_1,xvdb,w']
vif = [ 'mac=00:16:3e:19:27:06, bridge=xenbr0', ]

uuid = "8cc16a25-a982-e914-60a9-2eb01a5f3963"
bootloader="/usr/bin/pygrub"
vcpus=1
on_reboot   = 'restart'
on_crash    = 'restart'


/etc/xen/rhel4_2:

# Automatically generated xen config file
name = "rhel4_2"
memory = "256"
disk = [ 'tap:aio:/xen/rhel4_2,xvda,w', 'tap:aio:/xen/rhel4_2_1,xvdb,w']
vif = [ 'mac=00:16:3e:19:27:07, bridge=xenbr0', ]

bootloader="/usr/bin/pygrub"
vcpus=1
on_reboot   = 'restart'
on_crash    = 'restart'




2. 在兩個虛擬機里下載並安裝drbd軟體:
tar zxvf /root/drbd-8.0.3.tar.gz
make
make install

安裝生成一個drbd.ko的模塊文件,載入這個模塊:
modprobe drbd
可以查看這個模塊的信息:
# cat /proc/drbd
version: 8.0.3 (api:86/proto:86)
SVN Revision: 2881 build by root@localhost.localdomain, 2007-06-22 20:16:49

分別是兩個虛擬機里生成drbd的配置文件/etc/drbd.conf,文件內容是相同的:

global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
        protocol C;
        net {
        }
        on rhel4_1 {
                device    /dev/drbd0;
                disk      /dev/xvdb1;
                address   192.168.64.65:7789;
                meta-disk  internal;
        }
        on rhel4_2 {
                device    /dev/drbd0;
                disk      /dev/xvdb1;
                address   192.168.64.24:7789;
                meta-disk  internal;
        }
}



3. 建立drbd設備文件:
for i in $(seq 0 15) ; do mknod /dev/drbd$i b 147 $i ; done

初始化meta-data area:
drbdadm create-md r0


  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 1221th user to install this version

In the future drbdadm will only contact usage.drbd.org when you update
DRBD or when you use 'drbdadm create-md'. Of course it will continue
to ask you for confirmation as long as 'usage-count' is at its default
value of 'ask'.

Just press to continue:

v08 Magic number not found
v07 Magic number not found
About to create a new drbd meta data block
on /dev/xvdb1.

==> This might destroy existing data! <==

Do you want to proceed?
[ need to type 'yes' to confirm ]

Creating meta data...
initialising activity log
NOT initialized bitmap (16 KB)
New drbd meta data block sucessfully created.
success


在rhel4_1上啟動drbd服務:
# drbdadm up all
drbd0: No usable activity log found.
netstat -ant的輸出結果里有一行:
tcp        0      0 192.168.64.65:7789          0.0.0.0:*                   LISTEN

在rhel4_2上以同樣的命令啟動drbd服務,netstat -atn的輸出結果,說明兩台虛擬機的drbd服務已經連接上了:
tcp        0      0 192.168.64.24:7789          192.168.64.65:32845         ESTABLISHED
tcp        0      0 192.168.64.24:32770         192.168.64.65:7789          ESTABLISHED


4. 在rhel4_1上把drbd設備切換到 primary狀態,並載入drbd0設備到目錄/mnt/drbd0(在載入設備前必須先切換到primary狀態):
drbdadm primary all
mount /dev/drbd0 /mnt/drbd0
任意複製一些文件到/mnt/drbd0目錄,然後卸載drbd0設備,並把drbd設備切換到secondary狀態:
umount /dev/drbd0
drbdadm secondary all

在rhel4_2上把drbd設備切換到 primary狀態,並載入drbd0設備到目錄/mnt/drbd0,查看這個目錄的內容,可以看到在rhel4_1上複製的那些文件。


幾點注意的地方:
1. mount drbd設備以前必須把設備切換到primary狀態。
2. 兩個節點中,同一時刻只能有一台處於primary狀態,另一台處於secondary狀態。
3. 處於secondary狀態的伺服器上不能載入drbd設備。


---------------------------------
繼續考慮實時切換的問題。。。

[ 本帖最後由 sailer_sh 於 2007-7-4 11:59 編輯 ]

[火星人 ] 虛擬機(2*RHEL4U5)里搭建drbd環境(5樓是配置過程)已經有515次圍觀

http://coctec.com/docs/service/show-post-8222.html