One: Experimental environment
Node |
OS |
Ip |
Drbd_ip |
DRBD with HDD |
Vip |
Web1 |
centos5.10 |
192.168.10.11 |
172.16.1.1 |
/dev/sdb |
192.168.10.100 |
Web2 |
centos5.10 |
192.168.10.12 |
172.16.1.2 |
/dev/sdb |
1. Where the two-node IP address is set as above:
2. Two nodes have been configured with mutual SSH trust and have done time synchronization
Two: Install related software (both nodes 1 and 2 are installed)
1. Install Corosync, pacemaker
Download the corresponding RPM package at the address below
http://clusterlabs.org/rpm/epel-5/x86_64/
The RPM package for this download is:
cluster-glue-1.0.6-1.6.el5.x86_64.rpm
cluster-glue-libs-1.0.6-1.6.el5.x86_64.rpm
corosync-1.2.7-1.1.el5.x86_64.rpm
corosynclib-1.2.7-1.1.el5.x86_64.rpm
heartbeat-3.0.3-2.3.el5.x86_64.rpm
heartbeat-libs-3.0.3-2.3.el5.x86_64.rpm
LIBESMTP-1.0.4-5.EL5.X86_64.RPM//This package is downloaded from the Epel source
pacemaker-1.0.12-1.el5.centos.x86_64.rpm
pacemaker-libs-1.0.12-1.el5.centos.x86_64.rpm
resource-agents-1.0.4-1.1.el5.x86_64.rpm
Installation:
[Root@web1 ~]# for I in 1 2; Do ssh web$i yum-y--nogpgcheck localinstall/root/*.rpm; Done
3. Install Apache and set not to start randomly
[Root@web1 ~]# for I in 1 2; Do ssh web$i yum-y install httpd; Done
[Root@web1 ~]# for I in 1 2; Do ssh web$i chkconfig httpd off; Done
4. Install DRBD and set not to start randomly
[Root@web1 ~]# for I in 1 2; Do ssh web$i yum-y install drbd83 kmod-drbd83; Done
[Root@web1 ~]# for I in 1 2; Do ssh web$i chkconfig drbd off; Done
Three: Configure DRBD
1. [Root@web1 ~]# cp/usr/share/doc/drbd83-8.3.15/drbd.conf/etc/drbd.conf
2. [Root@web1 ~]# cd/etc/drbd.d/
3.[root@web1 drbd.d]# Cat global_common.conf//Only the Change section is listed here, not listed by default
Global {
Usage-count No;
}
Common {
Protocol C;
NET {
Cram-hmac-alg SHA1;
Shared-secret "WJCAIYF";
}
Syncer {
Rate 56M;
}
}
4. New Resource R0
[Root@web1 drbd.d]# Touch R0.res
[Root@web1 drbd.d]# Cat R0.res
Resource R0 {
device/dev/drbd0;
Disk/dev/sdb;
Meta-disk internal;
On web1 {
Address 172.16.1.1:7789;
}
On web2 {
Address 172.16.1.2:7789;
}
}
5. Copy the global_common.conf and r0.res to the web2 corresponding directory
[Root@web1 drbd.d]# SCP global_common.conf r0.res web2:/etc/drbd.d/
6. Create metadata for resource r0 (both nodes 1 and 2 are created)
[Root@web1 ~]# for I in 1 2; Do ssh web$i drbdadm create-md r0; Done
7. Start the DRBD service
[Root@web1 ~]#/ETC/INIT.D/DRBD start
[Root@web2 ~]#/ETC/INIT.D/DRBD start
8. Set Web1 to start synchronizing data for the primary node
[Root@web1 ~]# Drbdadm----Overwrite-data-of-peer primary r0
9. View the/PROC/DRBD to determine the synchronization status
[Root@web1 ~]# CAT/PROC/DRBD
version:8.3.15 (api:88/proto:86-97)
Git-hash:0ce4d235fc02b5c53c1c52c53433d11a694eab8cbuild by mockbuild@builder10.centos.org, 2013-03-27 16:01:26
0:cs:connected ro:primary/secondaryds:uptodate/uptodate C R-----
Ns:4 nr:8 dw:12 dr:17 al:0 bm:1 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
The above red font indicates that synchronization is complete.
10. Create a Ext3 file system
[Root@web1 ~]# mkfs.ext3/dev/drbd0
11. Mount the/dev/drbd0 to the/var/www/html directory and place a test page before uninstalling the Mount
[Root@web1 ~]# mount/dev/drbd0/var/www/html/
[Root@web1 ~]# echo "This is a Testpage" >/var/www/html/index.html
[Root@web1 ~]# umount/var/www/html/
12. Restore the DRBD status to Secondary/secondary and stop the DRBD service
[Root@web1 ~]# Drbdadm secondary R0
[Root@web1 ~]# for I in 1 2; do ssh WEB$I/ETC/INIT.D/DRBD stop; Done
Now that the DRBD configuration is complete
Four: Configuration Corosync
1.[root@web1 ~]# cd/etc/corosync/
2.[ROOT@WEB1 corosync]# CP corosync.conf.example corosync.conf
3. The completed configuration file is as follows:
[Root@web1 corosync]# Cat corosync.conf
# Please read the corosync.conf.5 manualpage
Compatibility:whitetank
Totem {
Version:2
Secauth:off