Heartbeat and drbd test high availability

By | 2014年1月16日

Hosts:
192.168.1.101 ha1.lofyer.org, 2 hard drive disks, two ethernet ports
192.168.1.103 ha2.lofyer.org, almost same as ha1

Server host, this is the IP of heartbeat service:
192.168.1.100

Install

The repos you need in centos

Setup

1. Drbd configuration both hosts

Add following content to file: /etc/hosts

Disable selinux and iptables

Prepare the disk partion

Configuration for mysql
# mkdir db
# sed -i ‘s/datadir=\/var\/lib\/mysql/datadir=\/db/’ /etc/my.cnf
Configuration for drbd
file: /etc/drbd.conf

Chmod for drbd

Resource for drbd

Watch drbd status

You can see that both hosts are Secondary/Secondary.

2. Drbd configuration on one of hosts, like ha1

Make ha1 Primary

Then you should see Primary and wait for both hosts are UpToDate.
Initialization for Mysql
Make a

Now you should see what you have got in /db, then umount /db, stop mysql-server and make ha1 Secondary.

3. Heartbeat configuration on both hosts

cluster authkey

YOU SHOULD MODIFY THE IP IN THE FILE.
file: /etc/ha.d/ha.cf

The service will be serve on IP 192.168.1.100.
file: /etc/ha.d/haresources

If you just wanna a virtual ip, use this

Add mysql entry to heartbeat
file: /etc/ha.d/resource.d/mysql

Add excute permission to it.

Add heartbeat service to system

You may need modify order of drbd and heartbeat service.
In /etc/init.d/, the number 85 and 15 represent the order number which the script is to be
run at start up time and shutdown time.
# chkconfig: – 85 15

Test HA

发表评论

邮箱地址不会被公开。