MySQL HA 集群配置

1. 下载软件包
heartbeat-2.0.8.tar.gz
libnet-1.1.2.1-2.1.i386.rpm

2.安装heartbeat
# groupadd haclient
# useradd -g haclient hacluster
# rpm -ivh libnet-1.1.2.1-2.1.i386.rpm
# tar zxvf heartbeat-2.0.8.tar.gz
# cd heartbeat-2.0.8
# ./ConfigureMe configure --prefix=/usr/local/heartbeat
# make
# make install

3. 配置heartbeat

# cd /usr/local/hearbeat/
# cp share/doc/heartbeat-2.0.8/haresources   share/doc/heartbeat-2.0.8/ha.cf share/doc/heartbeat-2.0.8/authkeys   /etc/ha.d/
# cd /etc/ha.d
# vim ha.cf 注释或修改以下内容
logfile /var/log/ha-log
keepalive 2
deadtime 30
warntime 10
initdead 120
ucast eth0 10.0.2.51
auto_failback on
watchdog /dev/watchdog
node    node1.com
node    node2.com
ping 10.0.2.1
respawn hacluster /usr/local/heartbeat/lib/heartbeat/ipfail
# vim haresource
node1.com  IPaddr::10.0.2.62/8/eth0:0  Filesystem::10.0.2.48:/data::/var/lib/mysql::nfs mysqld
# vim authkeys
auth 3
3 md5 Hello!
# chmod 600 authkeys

4. 在从服务器上同样执行以上操作,在第三步时,把ha.cf haresouce和authkeys 三个配置文件scp到从服务器上,但是要改一个文件ha.cf的一处:ucast eth0 10.0.2.50

5. 先启动主服务器上的heartbeat服务再启动从服务器上的heartbeat服务
# service heartbeat start

添加新评论 »