HAクラスタの構築

●事前準備

# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 135.84 GB
PE Size 32.00 MB
Total PE 4347
Alloc PE / Size 4315 / 134.84 GB
Free PE / Size 32 / 1.00 GB
VG UUID DSisQg-OCiD-0dqt-eMLR-RAZe-m6xn-xtHGPq

# lvcreate -L 1024M /dev/VolGroup00
Logical volume "lvol0" created

# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID aWwT4l-4fGx-V8je-iWPA-XvVM-SCXu-W6NJ2C
LV Write Access read/write
LV Status available
# open 1
LV Size 130.91 GB
Current LE 4189
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID 229j2o-uy0J-F3dZ-CfT1-VPOX-4gkC-Lgpxlk
LV Write Access read/write
LV Status available
# open 1
LV Size 3.94 GB
Current LE 126
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Name /dev/VolGroup00/lvol0
VG Name VolGroup00
LV UUID 1sRHZJ-TGIq-V1yX-CckB-xubE-HBnZ-tVmWV1
LV Write Access read/write
LV Status available
# open 0
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.91G
LogVol01 VolGroup00 -wi-ao 3.94G
lvol0 VolGroup00 -wi-a- 1.00G

●インストール

# yum -y install drbd82 kmod-drbd82

●設定

# vi /etc/drbd.conf

#
# please have a a look at the example configuration file in
# /usr/share/doc/drbd82/drbd.conf
#
global { usage-count no; }
common { syncer { rate 10M; } }
resource r0 {
protocol C;
startup {
degr-wfc-timeout 120;
}
net {
cram-hmac-alg sha1;
shared-secret "FooFunFactory";
}
on bssv1.back-slash.com {
device /dev/drbd0;
disk /dev/VolGroup00/lvol0;
address 192.168.20.201:7789;
flexible-meta-disk internal;
}
on bssv2.back-slash.com {
device /dev/drbd0;
disk /dev/VolGroup00/lvol0;
address 192.168.20.202:7789;
meta-disk internal;
}

# drbdadm create-md r0
md_offset 1073737728
al_offset 1073704960
bm_offset 1073672192

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

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

v07 Magic number not found
v07 Magic number not found
You want me to create a v08 style flexible-size internal meta data block.
There apears to be a v08 flexible-size internal meta data block
already in place on /dev/VolGroup00/lvol0 at byte offset 1073737728
Do you really want to overwrite the existing v08 meta-data?
[need to type 'yes' to confirm] yes

Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block sucessfully created.

# /etc/rc.d/init.d/drbd start
Starting DRBD resources: [ d(r0) s(r0) n(r0) ].
..........
***************************************************************
DRBD's startup script waits for the peer node(s) to appear.
- In case this node was already a degraded cluster before the
reboot the timeout is 120 seconds. [degr-wfc-timeout]
- If the peer was available before the reboot the timeout will
expire after 0 seconds. [wfc-timeout]
(These values are for resource 'r0'; 0 sec -> wait forever)
To abort waiting enter 'yes' [ 20]:yes

ノード2も実施

初期同期
# drbdadm -- --overwrite-data-of-peer primary all

状態確認
# /etc/rc.d/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
m:res cs st ds p mounted fstype
0:r0 SyncSource Primary/Secondary UpToDate/Inconsistent C
... sync'ed: 6.7% (980924/1048508)K

# /etc/rc.d/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
m:res cs st ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate C

# mkfs -t ext3 /dev/drbd0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262127 blocks
13106 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

■heartbeatのインストール
# yum -y install heartbeat
  :
useradd: ユーザ hacluster は存在します
error: %pre(heartbeat-2.1.3-3.el5.centos.i386) scriptlet failed, exit status 9
error: install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos
  :

エラーの為、再度インストール
# yum -y install heartbeat

# cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/

# vi /etc/ha.d/ha.cf

logfile /var/log/ha-log ← コメント解除
keepalive 2 ← コメント解除(ノード間死活監視時間(秒))
deadtime 30 ← コメント解除(ノードダウン検知時間(秒))
initdead 120 ← コメント解除
udpport 694 ← コメント解除(ブロードキャスト使用ポート番号)
baud 19200 ← コメント解除
serial /dev/ttyS0 # Linux ← コメント解除
watchdog /dev/watchdog ← コメント解除
node bssv1.back-slash.com ← 追加
node bssv2.back-slash.com ← 追加

# cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/

# vi /etc/ha.d/authkeys

auth 2
#1 crc
#2 sha1 HI!
2 sha1 ********
#3 md5 Hello!

# chmod 600 /etc/ha.d/authkeys

# mkdir /data

# vi /etc/ha.d/haresources
bssv1.back-slash.com \
IPaddr2::192.168.24.200/24/eth0/ \
MailTo::maint@back-slash.co.jp::heartbeat_fail_over drbddisk::r0 \
Filesystem::/dev/drbd0::/data::ext3 \
mysql \
pgsql

# rm -rf /var/lib/heartbeat/crm/cib.xml
# /usr/lib/heartbeat/haresources2cib.py /etc/ha.d/haresources

# vi /var/lib/heartbeat/crm/cib.xml

 :
<nvpair id="IPaddr_192_168_24_200_attr_1" name="nic" value="24"/>
  ↓
<nvpair id="IPaddr_192_168_24_200_attr_1" name="nic" value="eth0"/>
<nvpair id="IPaddr_192_168_24_200_attr_2" name="cidr_netmask" value=""/>
  ↓
<nvpair id="IPaddr_192_168_24_200_attr_2" name="cidr_netmask" value="24"/>
  :

# chkconfig heartbeat on
# chkconfig --list heartbeat
heartbeat 0:off 1:off 2:on 3:on 4:on 5:on 6:off

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です