- OS : Ubuntu Hardy Heron 8.04
- DRBD Version : 8.2.5
- Heartbeat Version : Heartbeat-2
I started with LAMP installation on Ubuntu Hardy so MySQL already installed as default.
1. Install DRBD on both server, please refer to link below for DRBD manual installation
Step by Step / HOWTO install DRBD 8.2.6 in Ubuntu 8.04 Hardy Heron
Change to root mode to make it easier.
# sudo -s2. Install Heartbeat on both server
# apt-get install heartbeat-23. Heartbeat configuration. There are 3 important files for heartbeat configuration inside /etc/ha.d/ folder. You'll not found this 3 files inside the folder, you must create or copy the files inside /etc/ha.d/ by your self.
- authkeysAfter finish with file configuration, copy those 3 files to slave box and move it to /etc/ha.d/auth 2Make this file unreadable for all other user except root.
#1 crc
2 sha1 yourpasswordhere
#3 md5 Hello!# chmod 600 authkeys
- haresourcesmasterdrbd.myhost.com 172.16.172.105 drbddisk::db Filesystem::/dev/drbd0::/mysql::ext3 mysql* masterdrbd.myhost.com : your hostname for master.
* 172.16.172.105 : your virtual ip for mysql service.
* /dev/drbd0 : your drbd disk .
* /mysql : your mounting point for drbd disk.
* ext3 : filesystem type for the disk.
* mysql : mysql service that you want to start when heartbeat start.
- ha.cf ( More detail refer to http://www.linux-ha.org/ha.cf )debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 699
bcast eth0
auto_failback on
node masterdrbd.myhost.com
node slavedrbd.myhost.com
ping 172.16.172.200
ping 172.16.172.1
apiauth ipfail gid=haclient uid=hacluster
4. Preparing mysql for clustering
I moved mysql data directory to /mysql, so i must change mysql and apparmor setting if i want to run mysql service in different data directory.
- Edit /etc/mysql/my.cnf
change this detail- Edit /etc/apparmor.d/usr.sbin.mysqld
datadir = /var/lib/mysql
to
datadir = /mysql
change this detail- Restart apparmor service
# /var/lib/mysql/ r,
# /var/lib/mysql/** rwk,
to
/mysql/ r,
/mysql/** rwk,
# /etc/init.d/apparmor restart- Move mysql data from /var/lib/mysql to /mysql
# mkdir /mysql- Try to restart your mysql service, make it sure it still can start the mysql service.
# cd /var/lib/mysql
# cp -r * /mysql
# chown -r mysql.mysql /mysql
- Copy /etc/mysql/my.cnf and /etc/mysql/debian.cnf to slave machine and replace mysql slave machine configuration with this copied files. [You must have the same setting for mysql for both server.]
master# scp /etc/mysql/*.cnf admin@slave.com:
move console to slave machine
slave# cp /home/admin/*.cnf /etc/mysql/
- Disable Mysql Service from startup on both server.
# sysv-rc-conf --level 012456S mysql off5. Start heartbeat service.
[ sysv-rc-conf has similar function with chkconfig ]
- Make sure drbd service on both server running and the status is correct. Master DRBD must role as Primary and Slave DRBD roles as Secondary.
master# /etc/init.d/drbd statusdrbd driver loaded OK; device status:
version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b *****
m:res cs st ds p mounted fstype
0:db Connected Primary/Secondary UpToDate/UpToDate C /mysql ext3
slave# /etc/init.d/drbd status- Start Heatbeat service on both server.drbd driver loaded OK; device status:
version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b *****
m:res cs st ds p mounted fstype
0:db Connected Secondary/Primary UpToDate/UpToDate C
[ There is no sync status in my drbd status because they already fully sync each other, in your status might be bit different, you will see sync status. ]
master# /etc/init.d/heartbeat start
[ Small part of my /var/log/ha-log when heartbeat successfully start. ]ResourceManager[6699]: 2008/08/28_10:01:01 info: Running /etc/ha.d/resource.d/IPaddr 172.16.172.105 start
IPaddr[6796]: 2008/08/28_10:01:01 INFO: Using calculated nic for 172.16.172.105: eth0
IPaddr[6796]: 2008/08/28_10:01:01 INFO: Using calculated netmask for 172.16.172.105: 255.255.255.0
IPaddr[6796]: 2008/08/28_10:01:01 INFO: eval ifconfig eth0:0 172.16.172.105 netmask 255.255.255.0 broadcast 172.16.172.255
IPaddr[6781]: 2008/08/28_10:01:01 INFO: Success
ResourceManager[6699]: 2008/08/28_10:01:01 info: Running /etc/ha.d/resource.d/drbddisk db start
Filesystem[6948]: 2008/08/28_10:01:01 INFO: Resource is stopped
ResourceManager[6699]: 2008/08/28_10:01:01 info: Running /etc/ha.d/resource.d/Filesystem /dev/drbd0 /mysql ext3 start
Filesystem[7024]: 2008/08/28_10:01:01 INFO: Running start for /dev/drbd0 on /mysql
Filesystem[7015]: 2008/08/28_10:01:01 INFO: Success
ResourceManager[6699]: 2008/08/28_10:01:01 info: Running /etc/init.d/mysql start
slave# /etc/init.d/heartbeat start
[ Small part of my /var/log/ha-log when heartbeat successfully start. ]heartbeat[8661]: 2008/07/06_04:38:56 info: local resource transition completed.
heartbeat[8661]: 2008/07/06_04:38:56 info: Initial resource acquisition complete (T_RESOURCES(us))
heartbeat[8710]: 2008/07/06_04:38:56 info: No local resources [/usr/share/heartbeat/ResourceManager listkeys slavedrbd.myhost.com] to acquire.
heartbeat[8661]: 2008/07/06_04:38:57 info: remote resource transition completed.





