Installation:
On machine1 and machine2 install Heartbeat and needed utilities. You may need to review the packages you have available using ‘yum list | grep drbd’. These are for CentOS 5.5. You may also need to reboot after this step.
# yum -y install gnutls*
# yum -y install ipvsadm*
# yum -y install heartbeat*
# yum -y install heartbeat.x86_64
Configuration:
Edit /etc/sysctl.conf and set net.ipv4.ip_forward = 1
# vi /etc/sysctl.conf
Controls IP packet forwarding net.ipv4.ip_forward = 1
# /sbin/chkconfig --level 2345 heartbeat on
# /sbin/chkconfig --del ldirectord
Configure HA:
You need to setup the following configuration files on both machines:
# vi /etc/ha.d/ha.cf
#/etc/ha.d/ha.cf content
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694 # If you have multiple HA setup in same network.. use different ports
bcast eth0 # Linux
auto_failback on # This will failback to machine1 after it comes back
ping 192.168.2.1 # The gateway
apiauth ipfail gid=haclient uid=hacluster
node db1.grennan.com
node db2.grennan.com
On both machines
NOTE: Assuming 192.168.2.15 is virtual IP for your MySQL resource and mysqld is the LSB resource agent. The host name (db2) should be the secondary server’s name.
# vi /etc/ha.d haresources
# /etc/ha.d/haresources content
db2.grennan.com LVSSyncDaemonSwap::master Paddr2::192.168.2.15/24/eth0 rbddisk::db Filesystem::/dev/drbd1::/data::ext3 mysqld
# vi /etc/ha.d/authkeys
#/etc/ha.d/authkeys content
auth 2
2 sha1 BigSecretKeyks9wjwlf9gskg905snvl
Now, make your authkeys secure:
# chmod 600 /etc/ha.d/authkeys
Check your work:
On both machines, one at a time, stop MySQL and make sure MySQL does not start when the system reboots (init 6).
If it does, you may need to remove it from the init process with:
# /sbin/chkconfig --level 2345 MySQL off
Start Heartbeat.
# service heartbeat start
These commands will give you status about this LVS setup:
# /etc/ha.d/resource.d/LVSSyncDaemonSwap master status
# ip addr sh
# service heartbeat status
# df
# service mysqld status
Access your HA-MySQL server like:
# mysql –h 192.168.2.15
Shutdown machine1 to see MySQL up on machine2. ‘shutdown now’
Start machine1 to see MySQL back on machine1.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment