drbd+corosync+mysql实现高可用群集

实验环境:

操作系统:linux-rhel-server-5.4

系统内核版本:2.6.18-164.el5

地址规划:

node1    node1.a.com 192.168.2.10

node2   node2.a.com 192.168.2.20

vip :   192.168.2.100

实验所需安装包:

cluster-glue-1.0.6-1.6.el5.i386.rpm 为了在群集中增加对更多节点的支持

cluster-glue-libs-1.0.6-1.6.el5.i386.rpm

corosync-1.2.7-1.1.el5.i386.rpmcorosync  的主配置文件
corosynclib-1.2.7-1.1.el5.i386.rpm   corosync  的库文件

heartbeat-3.0.3-2.3.el5.i386.rpm  我们的heartbeat 在这里是做四层的资源代理用的

heartbeat-libs-3.0.3-2.3.el5.i386.rpm heartbeat  的库文件

libesmtp-1.0.4-5.el5.i386.rpm
openais-1.1.3-1.6.el5.i386.rpm 做丰富pacemake  的内容使用

openaislib-1.1.3-1.6.el5.i386.rpm   openais 的库文件

pacemaker-1.1.5-1.1.el5.i386.rpm pacemake  的主配置文档

pacemaker-libs-1.1.5-1.1.el5.i386.rpm pacemaker  的库文件

pacemaker-cts-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 开启资源代理用的

mysql-5.5.15-linux2.6-i686.tar.gz mysql  的绿色软件

实验步骤:

node1:

修改地址和主机名:

[root@localhost ~]# vim /etc/sysconfig/network

clip_image002

[root@localhost ~]# hostname node1.a.com

[root@node1 ~]# setup

clip_image004

[root@node1 ~]# service network restart

编辑hosts文件:

[root@node1 ~]# vim /etc/hosts

clip_image006

node2:

修改地址和主机名:

[root@mail ~]# vim /etc/sysconfig/network

clip_image008

[root@mail ~]# hostname node2.a.com

[root@node2 ~]# setup

clip_image010

[root@node2 ~]# service network restart

编辑hosts文件:

[root@node2 ~]# vim /etc/hosts

clip_image012

node1

两个主机时间同步:

[root@node1 ~]# hwclock -s

[root@node2 ~]# hwclock –s

两个主机上产生密钥实现无密码的通讯:

[root@node1 ~]# ssh-keygen -t rsa

[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub node2

clip_image014

[root@node2 ~]# ssh-keygen -t rsa

[root@node2 ~]# ssh-copy-id -i .ssh/id_rsa.pub node1

clip_image016

导入安装所需包:

[root@node1 ~]# ll

drwxr-xr-x 2 root root 4096 Feb 17 21:19 Desktop

-rw-r--r-- 1 root root 100168525 Feb 17 21:21 VMwareTools-6.5.0-118166.tar.gz

-rw------- 1 root root 1330 Feb 8 01:27 anaconda-ks.cfg

-rw-rw-rw- 1 root root 8316839 Mar 6 13:09 bind-9.7.4.tar.gz

-rw-r--r-- 1 root root 271360 May 13 15:01 cluster-glue-1.0.6-1.6.el5.i386.rpm

-rw-r--r-- 1 root root 133254 May 13 15:01 cluster-glue-libs-1.0.6-1.6.el5.i386.rpm

-rw-r--r-- 1 root root 170052 May 13 15:01 corosync-1.2.7-1.1.el5.i386.rpm

-rw-r--r-- 1 root root 158502 May 13 15:01 corosynclib-1.2.7-1.1.el5.i386.rpm

-rwxr-xr-x 1 root root 907 Feb 18 21:13 disk.sh

-rw-r--r-- 1 root root 221868 May 13 15:01 drbd83-8.3.8-1.el5.centos.i386.rpm

-rw-r--r-- 1 root root 165591 May 13 15:01 heartbeat-3.0.3-2.3.el5.i386.rpm

-rw-r--r-- 1 root root 289600 May 13 15:01 heartbeat-libs-3.0.3-2.3.el5.i386.rpm

-rw-r--r-- 1 root root 1666 Feb 18 22:34 inittab

-rw-r--r-- 1 root root 35236 Feb 8 01:27 install.log

-rw-r--r-- 1 root root 3995 Feb 8 01:26 install.log.syslog

-rw-r--r-- 1 root root 125974 May 13 15:01 kmod-drbd83-8.3.8-1.el5.centos.i686.rpm

-rw-r--r-- 1 root root 44377 May 13 15:01 ldirectord-1.0.1-1.el5.i386.rpm

-rw-r--r-- 1 root root 60458 May 13 15:01 libesmtp-1.0.4-5.el5.i386.rpm

-rw-r--r-- 1 root root 37158912 May 13 15:01 mysql-5.5.15-linux2.6-i686.tar.gz

-rw-r--r-- 1 root root 207085 May 13 15:01 openais-1.1.3-1.6.el5.i386.rpm

-rw-r--r-- 1 root root 94614 May 13 15:01 openaislib-1.1.3-1.6.el5.i386.rpm

-rw-r--r-- 1 root root 796813 May 13 15:01 pacemaker-1.1.5-1.1.el5.i386.rpm

-rw-r--r-- 1 root root 207925 May 13 15:01 pacemaker-cts-1.1.5-1.1.el5.i386.rpm

-rw-r--r-- 1 root root 332026 May 13 15:01 pacemaker-libs-1.1.5-1.1.el5.i386.rpm

-rw-r--r-- 1 root root 1640 Feb 18 22:33 passwd

-rw-r--r-- 1 root root 32818 May 13 15:01 perl-TimeDate-1.16-5.el5.noarch.rpm

-rw-r--r-- 1 root root 388632 May 13 15:01 resource-agents-1.0.4-1.1.el5.i386.rpm

drwxr-xr-x 7 root root 4096 Sep 19 2008 vmware-tools-distrib

drbd的安装:

解压安装所依赖的包:

[root@node1 ~]# mount /dev/cdrom /mnt/cdrom/

[root@node1 ~]# yum localinstall -y *.rpm –nogpgcheck

[root@node1 ~]# scp /root/*rpm node2:/root/

[root@node2 ~]# mount /dev/cdrom /mnt/cdrom/

[root@node2 ~]# yum localinstall -y *.rpm –nogpgcheck

在各主机上增加一个大小类型都相关的drbd 设备(sda4):

[root@node1 ~]# fdisk /dev/sda

clip_image018

[root@node1 ~]# partprobe /dev/sda

[root@node1 ~]# cat /proc/partitions

clip_image020

[root@node2 ~]# fdisk /dev/sda

clip_image022

[root@node2 ~]# partprobe /dev/sda

[root@node2 ~]# cat /proc/partitions

clip_image024

编辑drbd配置文件:

[root@node1 ~]# cp /usr/share/doc/drbd83-8.3.8/drbd.conf /etc/

[root@node1 ~]# cd /etc/drbd.d/

[root@node1 drbd.d]# cp global_common.conf global_common.conf.bak

[root@node1 drbd.d]# vim global_common.conf

global {

usage-count yes;

}

common {

protocol C;

handlers {

pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";

local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o >; /proc/sysrq-trigger ; halt -f";

}

startup {

wfc-timeout 120;

degr-wfc-timeout 120;

}

disk {

on-io-error detach;

}

net {

cram-hmac-alg "sha1";

shared-secret "mydrbdlab";

}

syncer {

rate 100M;

}

}

定义mysql 的资源:

[root@node1 drbd.d]# vim mysql.res

resource mysql{

on node1.a.com {

device /dev/drbd0;

disk /dev/sda4;

address 192.168.2.10:7789;

meta-disk internal;

}

on node2.a.com {

device /dev/drbd0;

disk /dev/sda4;

address 192.168.2.20:7789;

meta-disk internal;

}

}

将主机node1上的文件拷到node2上:

[root@node1 drbd.d]# scp -r /etc/drbd.* node2:/etc/

初始化定义的mysql 的资源并启动相应的服务:

[root@node1 drbd.d]# drbdadm create-md mysql

clip_image026

[root@node2 drbd.d]# drbdadm create-md mysql

clip_image028

[root@node1 ~]# service drbd start

将node1设为主节点:

[root@node1 ~]# drbdadm -- --overwrite-data-of-peer primary mysql

查看两个主机的角色:

[root@node1 ~]# drbd-overview

clip_image030

[root@node2 ~]# drbd-overview

clip_image032

格式化磁盘:

[root@node1 ~]# mkfs -t ext3 /dev/drbd0

创建挂载点并挂载:

[root@node1 ~]# mkdir /mysqldata

[root@node1 ~]# mount /dev/drbd0 /mysqldata/

[root@node1 ~]# cd /mysqldata/

在挂载磁盘上创建两个文件:

[root@node1 mysqldata]# touch f1 f2

[root@node1 mysqldata]# ll /mysqldata/

clip_image034

将node1和node2的主,副模式进行切换:

[root@node1 ~]# umount /mysqldata/

[root@node1 ~]# drbdadm secondary mysql

clip_image036

[root@node2 ~]# drbdadm primary mysql

clip_image038

node2上创建挂载点,并查看node1上信息是否同步过来:

[root@node2 ~]# mkdir /mysqldata

[root@node2 ~]# mount /dev/drbd0 /mysqldata/

[root@node2 ~]# ll /mysqldata/

clip_image040

[root@node2 ~]# cd /mysqldata/

node2上创建一个文件:

[root@node2 mysqldata]# touch f3

clip_image042

[root@node2 ~]# umount /mysqldata/

进行模式切换,查看node2上信息是否同步到node1上:

[root@node2 ~]# drbdadm secondary mysql

[root@node1 ~]# drbdadm primary mysql

[root@node1 ~]# mount /dev/drbd0 /mysqldata/

clip_image044

mysql的安装:

创建mysql组和账户:

[root@node1 ~]# groupadd -r mysql

[root@node1 ~]# useradd -g mysql -r mysql

[root@node1 ~]# mkdir /mysqldata/data

data  目录要用存放mysql 的数据,故改变其属主属组:

[root@node1 ~]# chown -R mysql.mysql /mysqldata/data/

[root@node1 ~]# tar zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/

[root@node1 ~]# cd /usr/local/

创建mysql链接:

[root@node1 local]# ln -sv mysql-5.5.15-linux2.6-i686/ mysql

[root@node1 local]# cd mysql

[root@node1 mysql]# chown -R mysql.mysql .

初始化mysql 数据库:

[root@node1 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mysqldata/data

[root@node1 mysql]# chown -R root .

为mysql 提供主配置文件:

[root@node1 mysql]# cp support-files/my-large.cnf /etc/my.cnf

[root@node1 mysql]# vim /etc/my.cnf

clip_image046

clip_image048

修改mysql启动服务:

[root@node1 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@node1 mysql]# scp /etc/my.cnf node2:/etc/

[root@node1 mysql]# scp /etc/rc.d/init.d/mysqld node2:/etc/rc.d/init.d/

[root@node1 mysql]# chkconfig --add mysqld

确保开机不能自动启动,我们要用CRM 控制:

[root@node1 mysql]# chkconfig mysqld off

[root@node1 mysql]# service mysqld start

[root@node1 mysql]# service mysqld stop

[root@node1 mysql]# ls /mysqldata/data/

clip_image050

输出mysql 的man 手册至man 命令的查找路径:

[root@node1 mysql]# vim /etc/man.config

clip_image052

[root@node1 mysql]# ln -sv /usr/local/mysql/include /usr/include/mysql

输出mysql 的库文件给系统库查找路径:

[root@node1 mysql]# echo '/usr/local/mysql/lib/' >/etc/ld.so.conf.d/mysql.conf

让系统重新载入系统库:

[root@node1 mysql]# ldconfig

[root@node1 mysql]# vim /etc/profile

clip_image054

重新读取环境变量:

[root@node1 mysql]# . /etc/profile

[root@node1 mysql]# echo $PATH

clip_image056

node2上mysql的安装,和node1上大致相同:

[root@node1 mysql]# umount /mysqldata/

[root@node1 ~]# drbdadm secondary mysql

[root@node2 ~]# drbdadm primary mysql

[root@node2 ~]# groupadd -r mysql

[root@node2 ~]# useradd -g mysql -r mysql

[root@node2 ~]# mount /dev/drbd0 /mysqldata/

[root@node2 ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/

[root@node2 ~]# cd /usr/local/

[root@node2 local]# chown -R root:mysql .

[root@node2 local]# ln -sv mysql-5.5.15-linux2.6-i686/ mysql

[root@node2 local]# cd mysql

[root@node2 mysql]# chown -R root .

[root@node2 mysql]# chown -R mysql.mysql .

[root@node2 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mysqldata/data

[root@node2 mysql]# service mysqld start

[root@node2 mysql]# service mysqld stop

[root@node2 mysql]# ls /mysqldata/data/

clip_image058

[root@node2 mysql]# umount /dev/drbd0

corosync的配置:

切换到主配置文件的目录:

[root@node1 ~]# cd /etc/corosync/

[root@node1 corosync]# cp corosync.conf.example corosync.conf

[root@node1 corosync]# vim corosync.conf

clip_image060

需要补充的一些东西:

clip_image062

创建cluster目录:

[root@node1 corosync]# mkdir /var/log/cluster

为了便面其他主机加入该集群,需要认证,生成一authkey:

[root@node1 corosync]# corosync-keygen

clip_image064

将node1 上的文件拷贝到node2 上面:

[root@node1 corosync]# scp -p authkey corosync.conf node2:/etc/corosync/

[root@node1 corosync]# ssh node2 'mkdir /var/log/cluster'

启动 corosync的服务:

[root@node1 corosync]# service corosync start

[root@node2 ~]# service corosync start

验证corosync  引擎是否正常启动:

[root@node1 corosync]# grep -i -e "corosync cluster engine" -e "configuration file" /var/log/messages

clip_image066

查看初始化成员节点通知是否发出:

[root@node1 corosync]# grep -i totem /var/log/messages

clip_image068

检查过程中是否有错误产生:

[root@node1 corosync]# grep -i error: /var/log/messages |grep -v unpack_resources

检查pacemaker 时候已经启动了

[root@node1 corosync]# grep -i pcmk_startup /var/log/messages

clip_image070

node2上面做同样的检测:

[root@node2 ~]# grep -i -e "corosync cluster engine" -e "configuration file" /var/log/messages

clip_image072

[root@node2 ~]# grep -i totem /var/log/messages

clip_image074

[root@node2 ~]# grep -i error: /var/log/messages |grep -v unpack_resources

[root@node2 ~]# grep -i pcmk_startup /var/log/messages

clip_image078

在node1 上查看群集的状态:

[root@node1 corosync]# crm status

clip_image080

进行测试:

禁用stonith:

[root@node1 ~]# crm configure property stonith-enabled=false

对于双节点的集群来说,我们要配置此选项来忽略quorum,即这时候票数不起作用,一个

节点也能正常运行:

[root@node1 ~]# crm configure property no-quorum-policy=ignore

为资源指定默认黏性值:

[root@node1 ~]# crm configure rsc_defaults resource-stickiness=100

查看当前集群的配置信息:

[root@node1 ~]# crm configure show

clip_image082

将已经配置好的DRBD 设备/dev/drbd0  定义为集群服务;

[root@node1 ~]# service drbd stop

[root@node1 ~]# chkconfig drbd off

[root@node1 ~]# ssh node2 "service drbd stop"

[root@node1 ~]# ssh node2 "chkconfig drbd off"

提供drbd 的RA,并查看:

[root@node1 ~]# crm ra classes

clip_image084

[root@node1 ~]# crm ra info ocf:linbit:drbd

clip_image086

[root@node1 ~]# crm

crm(live)# configure

crm(live)configure# primitive mysqldrbd ocf:heartbeat:drbd params drbd_resource="mysql" op monitor role="Master" interval="30s" op monitor role="Slave" interval="31s" op start timeout="240s" op stop timeout="100s"

crm(live)configure# ms MS_mysqldrbd mysqldrbd meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify="true"

crm(live)configure# show mysqldrbd

clip_image088

crm(live)configure# show MS_mysqldrbd

crm(live)configure# verify

crm(live)configure# commit

crm(live)configure# exit

[root@node1 ~]# crm status

image

验正当前主机是否已经成为mysql 资源的Primary 节点:

[root@node1 ~]# drbdadm role mysql

image

clip_image094

clip_image096

[root@node1 ~]# crm

crm(live)# configure

crm(live)configure# primitive MysqlFS ocf:heartbeat:Filesystem params device="/dev/drbd0" directory="/mydata" fstype="ext3" op start timeout=60s op stop timeout=60s

crm(live)configure# commit

crm(live)configure# exit

开始测试

mysql 资源的定义(node1 上操作)

先为mysql 集群创建一个IP 地址资源,通过集群提供服务时使用,这个地址就是客户端访

问mysql 服务器使用的ip 地址;

[root@node1 ~]# crm configure primitive myip ocf:heartbeat:IPaddr params ip=192.168.2.100

配置mysqld 服务为高可用资源:

[root@node1 ~]# crm configure primitive mysqlserver lsb:mysqld

[root@node1 ~]# crm status

============

Last updated: Sat May 12 15:40:57 2012
Stack: openais

Current DC: node1.a.com - partition with quorum

Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f

2 Nodes  configured, 2 expected votes

4 Resources configured.
============

Online: [ node1.a.com node2.a.com ]

Master/Slave Set: MS_mysqldrbd   [mysqldrbd]
      Masters: [ node1.a.com ]

     Slaves: [ node2.a.com ]

MysqlFS (ocf::heartbeat:Filesystem): Started node1.a.com

myip    (ocf::heartbeat:IPaddr):  Started node2.a.com

定义如下的约束:

[root@node1 ~]# crm

crm(live)# configure

crm(live)configure# colocation MysqlFS_with_mysqldrbd inf: MysqlFS MS_mysqldrbd:Master myip mysqlserver

crm(live)configure# order MysqlFS_after_mysqldrbd inf: MS_mysqldrbd:promote MysqlFS:start

crm(live)configure# order myip_after_MysqlFS mandatory: MysqlFS myip

crm(live)configure# order mysqlserver_after_myip mandatory: myip mysqlserver

验证是否有错:

crm(live)configure# verify

crm(live)configure# commit

crm(live)configure# exit

查看配置信息:

[root@node1 ~]# crm configure show

node node1.a.com

node node2.a.com

primitive MysqlFS ocf:heartbeat:Filesystem \

params device="/dev/drbd0" directory="/mydata" fstype="ext3" \

op start interval="0" timeout="60s" \

op stop interval="0" timeout="60s"

primitive myip ocf:heartbeat:IPaddr \

params ip="192.168.2.100"

primitive mysqldrbd ocf:heartbeat:drbd \

params drbd_resource="mysql" \

op monitor interval="30s" role="Master" \

op monitor interval="31s" role="Slave" \

op start interval="0" timeout="240s" \

op stop interval="0" timeout="100s"

primitive mysqlserver lsb:mysqld

ms MS_mysqldrbd mysqldrbd \

meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"

colocation MysqlFS_with_mysqldrbd inf: MysqlFS MS_mysqldrbd:Master myip mysqlserver

order MysqlFS_after_mysqldrbd inf: MS_mysqldrbd:promote MysqlFS:start

order myip_after_MysqlFS inf: MysqlFS myip

order mysqlserver_after_myip inf: myip mysqlserver

property $id="cib-bootstrap-options" \

dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \

cluster-infrastructure="openais" \

expected-quorum-votes="2" \

stonith-enabled="false" \

no-quorum-policy="ignore"

rsc_defaults $id="rsc-options" \

resource-stickiness="100"

查看运行状态:
[root@node1 ~]# crm status

·

============

Last updated: Sat May 12 15:49:26 2012

Stack: openais

Current DC: node1.a.com - partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f

2 Nodes  configured, 2 expected votes

4 Resources configured.

============

Online: [ node1.a.com node2.a.com ]

  Master/Slave Set: MS_mysqldrbd   [mysqldrbd]

       Masters: [ node1.a.com ]

       Slaves: [ node2.a.com ]
  MysqlFS (ocf::heartbeat:Filesystem):    Started node1.a.com

myip      (ocf::heartbeat:IPaddr):  Started node1.a.com

mysqlserver    (lsb:mysqld):  Started node1.a.com

可见,服务现在在node1 上正常运行:

在node1 上的操作,查看mysql 的运行状态:
[root@node1 ~]# service mysqld status

MySQL running   (6578)                                                    [   OK   ]

查看是否自动挂载

[root@node1 ~]# mount

/dev/hdc   on /mnt/cdrom type iso9660   (ro)
/dev/drbd0   on /mysqldata type ext3 (rw)

查看目录

[root@node1 ~]# ls /mysqldata/

data   f1   f2   lost+found

查看vip  的状态
[root@node1 ~]# ifconfig

----------------------- Page 21-----------------------

eth0         Link encap:Ethernet     HWaddr 00:0C:29:1D:88:6F

             inet addr:192.168.2.10     Bcast:192.168.2.255      Mask:255.255.255.0

             inet6 addr: fe80::20c:29ff:fe1d:886f/64 Scope:Link
             UP BROADCAST RUNNING MULTICAST              MTU:1500      Metric:1

             RX packets:117137 errors:0 dropped:0 overruns:0   frame:0

             TX packets:813068 errors:0 dropped:0 overruns:0   carrier:0

             collisions:0   txqueuelen:1000

             RX bytes:12124664 (11.5 MiB)       TX bytes:1147189896   (1.0 GiB)
             Interrupt:67 Base address:0x2000

eth0:0      Link encap:Ethernet     HWaddr 00:0C:29:1D:88:6F

             inet addr:192.168.2.100      Bcast:192.168.2.255     Mask:255.255.255.0

             UP BROADCAST RUNNING MULTICAST              MTU:1500     Metric:1
             Interrupt:67 Base address:0x2000

lo           Link encap:Local Loopback

             inet addr:127.0.0.1    Mask:255.0.0.0

             inet6 addr: ::1/128 Scope:Host
             UP LOOPBACK RUNNING          MTU:16436       Metric:1

             RX packets:6067 errors:0 dropped:0   overruns:0 frame:0

             TX packets:6067 errors:0 dropped:0 overruns:0   carrier:0

             collisions:0   txqueuelen:0

             RX bytes:8873981 (8.4 MiB)       TX bytes:8873981 (8.4 MiB)
继续测试:

在node1 上操作,让node1 下线:

[root@node1 ~]# crm node standby

查看集群运行的状态:

[root@node1 ~]# crm status
============

Last updated: Sat May 12 15:56:11 2012

Stack: openais

Current DC: node1.a.com - partition with quorum

Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes  configured, 2 expected votes

4 Resources configured.

============

Node node1.a.com: standby
Online: [ node2.a.com ]

Master/Slave Set: MS_mysqldrbd   [mysqldrbd]

       Masters: [ node2.a.com ]

       Stopped: [ mysqldrbd:0   ]
MysqlFS (ocf::heartbeat:Filesystem):     Started node2.a.com

----------------------- Page 22-----------------------

myip      (ocf::heartbeat:IPaddr):  Started node2.a.com

mysqlserver    (lsb:mysqld):  Started node2.a.com

可见我们的资源已经都切换到了node2 上:

查看node2 的运行状态:

[root@node2 ~]# service mysqld status

MySQL running   (7805)                                                     [  OK    ]

查看目录
[root@node2 ~]# ls /mysqldata/

data   f1   f2  f3  lost+found

ok,现在一切正常,我们可以验证mysql 服务是否能被正常访问:

我们定义的是通过VIP:192.168.2.100 来访问mysql 服务,现在node2 上建立一个可以让某个

网段主机能访问的账户(这个内容会同步drbd 设备同步到node1 上):
[root@node2 ~]# mysql

Welcome   to the MySQL monitor.      Commands   end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.15-log MySQL Community  Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation  and/or its

affiliates. Other names may be trademarks of their respective

owners.
Type 'help;' or '\h'   for help. Type '\c' to clear the current input   statement.

mysql>; grant all on *.* to test@'192.168.%.%' identified  by '123456';

Query OK, 0 rows affected (0.01 sec)

mysql>; flush  privileges;

Query OK, 0 rows affected (0.06 sec)
mysql>; exit

Bye

然后我们通过另一台主机进行访问:

[root@node1 ~]# mysql -u test -h 192.168.2.100

[root@node1 ~]# mysql -u test -h 192.168.2.100
Welcome   to the MySQL monitor.      Commands   end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.15-log MySQL Community  Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation  and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h'   for help. Type '\c' to clear the current input   statement.

----------------------- Page 23-----------------------

mysql>;

这样我们的mysql 的高可用性的群集就实现成功啦。

你可能感兴趣的:(安装,操作系统)