通过Corosync实现MySQL高可用及LVS+ldirectord高可用并状态检测
通过Corosync实现Mysql高可用,以及LVS+ldirectord高可用并状态检测。
一、试验拓扑如下:
二、配置File Server
1、这里建立个LVM逻辑卷,为了方便以后扩展
# pvcreate /dev/sda5
# vgcreate vg01 /dev/sda5
# lvcreate -n mydata -L 10G vg01
# mke2fs -j /dev/vg01/mydata
2、设置开机自动挂载
# cat /etc/fstab
/dev/vg01/mydata /share ext3 defaults 0 0
# mkdir /share
# mount -a
3、添加mysql用户
(这里要注意的是node1,node2,File Server三台的mysql用户UID要一样)
# useradd -r -u 200 mysql
# chown -R mysql.mysql /share/
4、设置NFS共享
# cat /etc/exports
/share 172.16.15.20(rw,no_root_squash) 172.16.15.30(rw,no_root_squash)
# service nfs restart
三、配置node1和node2
1、修改主机名
# vim /etc/sysconfig/network
HOSTNAME=node1.peace.com
2、修改hosts
# vim /etc/hosts
172.16.15.20 node1.peace.com node1
172.16.15.30 node2.peace.com node2
4、配置mysql
# useradd -r -u 200 mysql # mkdir /data/mydata -p # mount -t nfs 172.16.15.60:/share /data/mydata/ # tar -xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/ # cd /usr/local/ # ln -s mysql-5.5.24-linux2.6-i686/ mysql # cd mysql # chown -R mysql.mysql . # scripts/mysql_install_db --user=mysql --datadir=/data/mydata/ # chown -R root . # cp support-files/my-large.cnf /etc/my.cnf # vim /etc/my.cnf thread_concurrency = 2 datadir = /data/mydata # cp support-files/mysql.server /etc/rc.d/init.d/mysqld # chmod +x /etc/rc.d/init.d/mysqld (这里可以启动服务测试下是否正常,之后一定要关闭服务并且卸载) # umount /data/mydata/ (注:node2配置和node1的配置一样不过不需要初始化的步骤,只需将/usr/local/下的权限改为如下,并且复制修配置改文件即可) # cd /usr/local/mysql/ # chown -R root.mysql .