This article is actually a supplement to the section "high-availability NFS file server under production" in chapter 5 of "building a high-availability Linux server (version 2, in fact, software like drbd and heartbeat can be automatically installed through yum, such as the command to install drbd: yum-yinstalldrbd83kmod-drbd83DRBD configuration file/etc/drbd. conf:
This article is actually a supplement to the section "high-availability NFS file server under production" in chapter 5 of "building a high-availability Linux server (version 2, in fact, software such as drbd and heartbeat can be automatically installed through yum. for example, the command for installing drbd is as follows:
yum -y install drbd83 kmod-drbd83
The configuration file/etc/DRBD. conf of drbd is as follows:
Global {# minor-count dialog-refresh disable-ip-verification usage-count no; # count the usage of drbd} common {syncer {rate 30 M;} # synchronization rate, depends on bandwidth} resource r0 {# Create a resource named "r0" protocol C; # select the drbd C protocol (data synchronization protocol, C is returned after receiving the data and writing, confirm success) handlers {# default drbd library file pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo B>/proc/sysrq-trigger; reboot-f "; pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh;/usr/lib/drbd/notify-emergency-reboot.sh; echo B>/proc/sysrq-trigger; reboot-f "; local-io-error"/usr/lib/drbd/notify-io-error.sh;/usr/lib/drbd/notify-emergency-shutdown.sh; echo o>/proc/sysrq-trigger; halt-f "; # fence-peer"/usr/lib/drbd/crm-fence-peer.sh "; # split-brain"/usr/lib/drbd/notify-split-brain.sh root "; # out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root "; # before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh-p 15 ---c 16 k "; # after-resync-target/usr/lib/drbd/unsnapshot-resync-target-lvm.sh ;} startup {# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb wfc-timeout 120; degr-wfc-timeout 120 ;} disk {# on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes # no-disk-drain no-md-flushes max-bio-bvecs on- io-error detach ;} net {# sndbuf-size rcvbuf-size timeout connect-int ping-timeout max-buffers # max-epoch-size ko-count allow-two-primaries cram-hmac- alg shared-secret # after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork max-buffers 2048; cram-hmac-alg "sha1"; shared-secret "123456"; # allow-two-primaries;} syncer {rate 30 M; # rate after al-extents use-rle cpu-mask verify-alg csums-alg} on centos1.cn7788.com {# set a node and name it device/dev/drbd0 with their respective host names; # set the resource device/dev/drbd0 to point to the actual physical partition/dev/sdb1 disk/dev/sdb; address 192.168.11.32: 7788; # set the listening address and port meta-disk internal ;} on centos2.cn7788.com {# set a node and name it device/dev/drbd0 with their respective host names; # set the resource device/dev/drbd0 to point to the actual physical partition/dev/sdb1 disk/dev/sdb; address 192.168.11.33: 7788; # set the listening address and port meta-disk internal ;}}
The Heartbeat configuration file is as follows:
logfile /var/log/ha-log logfacility local0 keepalive 2 deadtime 15 ucast eth0 192.168.11.32 ucast eth1 10.0.0.2 auto_failback off node centos1.cn7788.com centos2.cn7788.com
Additional notes:
1. many friends prefer to deploy DRBD using independent partitions. this is also feasible. we only need to keep Free space when installing the system, and then perform fdisk when deploying DRBD, this does not need to be written into the/etc/fstab table, that is, it does not need to be mounted when the system is installed. during the test, I found it cumbersome to deploy DRBD using this method, this increases the complexity of the entire experiment and requires dd operations. I suggest using an independent hard disk as a DRBD block device; II. the hard disk or partition used by the Secondary host for DRBD can be different from that of the Primar host, but please do not be smaller than that of the Primary host. 3. I recommend the M series for server network cards and switches, during the test, we found that the synchronization speed is between 30%-M. We recommend that you set the rate with the minimum bandwidth. 4. DRBD has high requirements on the network environment, we recommend that you use a pair of twisted wires as the heartbeat line between two hosts. if conditions permit, you can use more than two heartbeat lines, basically, split-brain problems do not exist. In fact, the entire experiment can be implemented in the same network at the initial stage. it is also feasible to add a heartbeat line later. 5. install Heartbeat twice, that is, run the yum-y install heartbeat command twice. 6. the experiment of DRBD + Heartbeat + NFS was also very vigorous during the test, I often shut down the primary machine during the write test. writing data does not affect the data, and the user cannot feel that the machine has crashed. 7. we recommend that you do not use the root partition as the MySQL datadir, otherwise, when you show the database, you will find a database named # mysql50 # lost + found. 8. even if split-brain occurs, DRBD will not lose data; because DRBD is reliable, MySQL also recommends it as one of MySQL's high availability solutions, the specific operation see http://database.51cto.com/art/201209/355332.htm