######在NOD2节点上安装Mysql
[root@nod2 ~]# scp nod1:/root/mysql-5.5.33-linux2.6-x86_64.tar.gz ./
[root@nod2 ~]# mkdir /mydata
[root@nod2 ~]# tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/
[root@nod2 ~]# cd /usr/local/
[root@nod2 local]# ln -s mysql-5.5.33-linux2.6-x86_64 mysql
[root@nod2 local]# cd mysql
[root@nod2 mysql]# cp support-files/my-large.cnf /etc/my.cnf
######修改配置文件添加如下配置
[root@nod2 mysql]# vim /etc/my.cnf
在[mysql]部分添加:
datadir = /data/mysql/
innodb_file_per_table = 1
[root@nod2 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@nod2 mysql]# chkconfig --add mysql
[root@nod2 mysql]# chkconfig mysql off
[root@nod2 mysql]# useradd -r -u 306 mysql
[root@nod2 mysql]# chown -R root.mysql *
2、卸载NOD1节点上的DRBD设备然后降级
[root@nod1 ~]# drbd-overview
0:mysql/0 Connected Primary/Secondary UpToDate/UpToDate C r-----
[root@nod1 ~]# umount /data/mysql/
[root@nod1 ~]# drbdadm secondary drbd
[root@nod1 ~]# drbd-overview
0:drbd/0 Connected Secondary/Secondary UpToDate/UpToDate C r-----
3、在NOD2节点升级DBRD为主然后挂载DRBD设备
[root@nod2 ~]# drbd-overview
0:drbd/0 Connected Secondary/Secondary UpToDate/UpToDate C r-----
[root@nod2 ~]# drbdadm primary mysql
[root@nod2 ~]# drbd-overview
0:mysql/0 Connected Primary/Secondary UpToDate/UpToDate C r-----
[root@nod2 ~]# mount /dev/drbd0 /data/mysql/
4、在NOD2节点上启动Mysql服务进行测试
[root@nod2 ~]# chown -R mysql.mysql /mydata
[root@nod2 ~]# service mysqld start
Starting MySQL.. [ OK ]
[root@nod2 ~]# service mysqld stop
Shutting down MySQL. [ OK ]
[root@nod2 ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
5、将DRBD服务都设置为备用节点如:
[root@node2 ~]# umount /data/mysql/
[root@node2 ~]# drbdadm secondary mysql
[root@node2 ~]# drbd-overview
0:mysql/0 Connected Secondary/Secondary UpToDate/UpToDate
6、卸载DRBD设备并停止NOD1与NOD2节点上的DRBD服务
[root@nod2 ~]# umount /data/mysql/
[root@nod2 ~]# service drbd stop
Stopping all DRBD resources: .
[root@nod1 ~]# service drbd stop
Stopping all DRBD resources:
四、安装Corosync+Pacemaker软件
1、所有节点均安装
# yum install corosync pacemaker -y
正在安装:
corosync x86_64 1.4.7-5.el6 base 216 k
pacemaker x86_64 1.1.14-8.el6 base 460 k
为依赖而安装:
clusterlib x86_64 3.0.12.1-78.el6 base 108 k
corosynclib x86_64 1.4.7-5.el6 base 194 k
libibverbs x86_64 1.1.8-4.el6 base 53 k
libqb x86_64 0.17.1-2.el6 base 71 k
(责任编辑:liangzh) |