Heartbeat高可用集群-mysql

时间:2022-05-25 03:12:32
192.168.1.210 node1
192.168.1.220 node2
192.168.1.200 nfs
1.200:
yum install -y nfs-utils
vim /etc/exports
/data/share 192.168.1.0/24(rw,sync,no_root_squash)
/etc/init.d/rpcbind restart;  /etc/init.d/nfs restart
210,220:
yum install -y nfs-utils
showmount -e 192.168.1.200
mkdir -p /data/mysql
mount -t nfs 192.168.1.200:/data/share/ /data/mysql/
wget mysql
tar zxvf mysql
mv mysql-.. /usr/local/mysql
cd /usr/local/mysql
groupadd -g 27 mysql; useradd -u 27 -g 27 mysql
cp support-files/mysql.server /etc/init.d/mysqld
 cp support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
skip-innodb
#server-id      = 1
vim /etc/init.d/mysqld
database=/usr/local/mysql
datadir=/data/mysql/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
/etc/init.d/mysqld start
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
 source /etc/profile
210:
mysql -uroot -p
create database db1;
service mysqld stop
220:
ls /data/mysql
service mysqld start

220:
service mysqld stop
安装heartbeat
node1&node2:
wget http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm 
 yum install -y heartbeat heartbeat-* libnet
cd /usr/share/doc/heartbeat-3.0.4
cp authkeys haresources ha.cf /etc/ha.d
cd /etc/ha.d/
node1:
vim authkeys
增加
auth 3
3 md5 Hello!
vim haresources
node1 192.168.1.222/24/eth0:0 mysqld
vim ha.cf
logfile /var/log/ha.log
#bcast eth1
ucast eth1 192.168.0.200对方ip
keepalive 2
warntime 10
deadtime 30
initdead 120
udpport 694
auto_failback on
node node1
node node2
ping 192.168.1.254
respawn hacluster /usr/lib/heartbeat/ipfail
debugfile /var/log/ha-debug.log

scp authkeys ha.cf haresources node2:/etc/ha.d/
node2:
vim ha.cf
ucast eth1 192.168.0.100对方ip
chmod 600 authkeys
 /etc/init.d/heartbeat  start
测试:
1.220:
mysql -uroot -p -h192.168.1.220 -P3306
 create database db2;
1.210:show databases;


本文出自 “Linux_Config” 博客,请务必保留此出处http://liang1026.blog.51cto.com/10119067/1633857