发布网友 发布时间:2022-04-20 07:44
共1个回答
热心网友 时间:2022-04-07 19:10
还是先上规划图
1.首先进行资源的分析
1)Vip
2)Mysqld
3)Nfs
理清他们之间的启动先后顺序:nfs必须在Mysqld前启动
2.nfs的配置
Nfs共享目录上挂载的分区,最好做成lvm,实现自动扩展
2.1.安装
#yum -y install nfs-utils
2.2配置
#mkdir /share
#vim /etc/exports
172.16.98.3:/share 172.16.98.1(rw,no_root_squash) 172.16.98.2(rw,no_root_squash)
#service nfs start
#groupadd -g 186 mysql
#useradd -u 186 -g mysql -s /sbin/nologin -M mysql
#chown mysql:mysql /share
3.Mysql1结合nfs的安装测试
3.1挂载nfs
#mkdir /data
#chown mysql:mysql /data
#mount 172.16.98.3:/share /data
3.2使用mysql的解压缩包安装
#groupadd -g 186 mysql
#useradd -u 186 -g mysql -s /sbin/nologin -M mysql
*在三台机器上,创建的mysql组和用户的uid、gid要保持一致
# 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
#chowm -R root .
#cp support-files/my-large.cnf /etc/my.cnf
#cp cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod +x /etc/rc.d/init.d/mysqld
#vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
#export PATH=$PATH:/usr/local/mysql/bin
3.3编辑配置文件,启动服务
#vim /etc/my.cnf
[mysqld]
thread_concurrency = 2
datadir=/data
#service mysqld start
3.4另一台mysql的安装
参考前面的步骤
需要说明一点的是
Mysql的安装,这里不需要再初始化mysql
## 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
#chowm -R root .
#cp support-files/my-large.cnf /etc/my.cnf
#cp cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod +x /etc/rc.d/init.d/mysqld
#vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
#export PATH=$PATH:/usr/local/mysql/bin
#service mysqld start
#cd /data
#
3.5停止所有资源
1)关闭mysql服务
2)将nfs共享目录卸载
4.Corosync的安装
前期准备
1)ssh 双机互信,方便配置
2)时间保持一致
3)/etc/hosts ,主机名设置,互相解析
4.1corosync的安装,两台都安装上
## yum install -y cluster-glue-1.0.6-1.6.el5.i386.rpm cluster-glue-libs-1.0.6-1.6.el5.i386.rpm corosynclib-1.2.7-1.1.el5.i386.rpm corosync-1.2.7-1.1.el5.i386.rpm heartbeat-3.0.3-2.3.el5.i386.rpm heartbeat-libs-3.0.3-2.3.el5.i386.rpm libesmtp-1.0.4-5.el5.i386.rpm pacemaker-cts-1.1.5-1.1.el5.i386.rpm pacemaker-libs-1.1.5-1.1.el5.i386.rpm pacemaker-1.1.5-1.1.el5.i386.rpm perl-TimeDate-1.16-5.el5.noarch.rpm resource-agents-1.0.4-1.1.el5.i386.rpm
4.2corosync的配置
1)mysql1
#cd /etc/corosync
#cp corosync.conf.example corosync.conf
#vim corosync.conf
compatibility: whitetank
totem {
version: 2
secauth:on 开启身份验证
threads: 0
interface {
ringnumber: 0
bindnetaddr: 172.16.0.0
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
logging {
fileline: off
to_stderr: on
to_logfile: yes
# to_syslog: yes
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
service {
ver:0
name:pacemaker
}
#corosync-keygen 创建authkeys
#scp authkeys corosync.conf node2:/etc/corosync
两台mysql上分别创建用于日志的目录
#mkdir /var/log/cluster
4.3通过mysql1开启corosync,配置资源
1)开启
#service corosync start
#ssh node2 'service corosync start'
#crm_mon
============
Last updated: Thu Aug 9 22:12:22 2012
Stack: openais
Current DC: node1.7ing.com - partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
0 Resources configured.
============
Online: [ node2.7ing.com node1.7ing.com ]
2)资源的配置
#crm
crm(live)#configure
crm(live)configure# primitive vip ocf:heartbeat:IPaddr params ip=172.16.99.1
crm(live)configure# primitive mysqld lsb:mysqld
crm(live)configure# primitive nfs ocf:heartbeat:Filesystem params device=172.16.98.3:/share directory=/data fstype=nfs op start timeout=60 op stop timeout=60
*定义nfs资源,默认的超时时间是20s,是小于建议的时间60s的,所以手动配置
crm(live)configure# colocation vip_mysqld_nfs inf: mysqld nfs vip
crm(live)configure# order mysqld_after_nfs inf: nfs mysqld
crm(live)configure# property stonith-enabled=false
crm(live)configure# property no-quorum-policy=ignore
crm(live)configure# verify
crm(live)configure# commit
3)检测
#crm_mon
Last updated: Thu Aug 9 22:34:52 2012
Stack: openais
Current DC: node1.7ing.com - partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
3 Resources configured.
============
Online: [ node2.7ing.com node1.7ing.com ]
nfs (ocf::heartbeat:Filesystem): Started node1.7ing.com
vip (ocf::heartbeat:IPaddr): Started node1.7ing.com
mysqld (lsb:mysqld): Started node1.7ing.com
#crm node standy
#crm_mon
============
Last updated: Thu Aug 9 22:36:18 2012
Stack: openais
Current DC: node1.7ing.com - partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
3 Resources configured.
============
Node node1.7ing.com: standby
Online: [ node2.7ing.com ]
nfs (ocf::heartbeat:Filesystem): Started node2.7ing.com
vip (ocf::heartbeat:IPaddr): Started node2.7ing.com
mysqld (lsb:mysqld): Started node2.7ing.com