heartbeat v2
heartbeat v1的资源配置接口通过haresource配置文件来实现,而heartbeat v2的资源配置接口通过在各个节点运行的crmd进程的配置接口来实现,crmd的配置接口程序有crmsh,gui接口有hb_gui。
以下的配置是在heartbeat v1的基础上再次升级部署,要启动crmd,只需要在/etc/ha.d/ha.cf中增加配置选项crm on来实现,这样的heartbeat就不会读区haresource配置文件中的配置,而是启动crmd的进程来配置heartbeat v2的资源管理。
准备工作
节点配置:
nfs server
1~]# yum install -y nfs2~]# mkdir /mysqldata3~]# mkdir /www4~]# chown -R apache.apache /www5~]# chown -R mysql.mysql /mysqldata6~]# vim /etc/exports7/mysqldata 10.211.55.0/24(rw,sync,no_root_squash)8/www 10.211.55.0/24(rw,sync,no_root_squash)9~]# service nfs startnode1
1~]# yum install -y showmount httpd php mysql-server2~]# showmount -e 10.211.55.393Export list for 10.211.55.39:4/mysqldata 10.211.55.0/245/www 10.211.55.0/246~]# mkdir /mysqldata7~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata8~]# ll -d /mysqldata9~]# mysql_install_db --datadir=/mysqldata --user=mysql10~]# service mysqld start11~]# mount -t nfs 10.211.55.39:/www /var/www/html12~]# tar xf wordpress.tar.gz -C /var/www/html13~]# mysql14Welcome to the MySQL monitor. Commands end with ; or \g.15Your MySQL connection id is 216Server version: 5.1.73 Source distribution1718Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.1920Oracle is a registered trademark of Oracle Corporation and/or its21affiliates. Other names may be trademarks of their respective22owners.2324Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.2526mysql> create database wordpress;27Query OK, 1 row affected (0.04 sec)2829mysql> grant all on wordpress.* to wordpress@'10.211.55.63' identified by 'wordpress';30Query OK, 0 rows affected (0.00 sec)31~]# service httpd start3233web配置完wordpress的配置3435~]# service httpd stop36~]# service mysqld stopnode2
1~]# yum install -y showmount httpd php mysql-server2~]# mkdir /mysqldata3~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata4~]# ll -d /mysqldata5~]# service mysqld start6~]# mount -t nfs 10.211.55.39:/www /var/www/html7~]# service mysqld start8~]# service httpd start910web测试完成1112~]# service httpd stop13~]# service mysqld stop
heartbeat v2配置
node1
1~]# echo 'crm on' >> /etc/ha.d/ha.cf2~]# cd heartbeartv23~]# yum install -y pygtk2-libglade4~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpmnode2
1~]# echo 'crm on' >> /etc/ha.d/ha.cf2~]# cd heartbeartv23~]# yum install -y pygtk2-libglade4~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpmnode1
1~]# service heartbeat start;ssh node2 'service heartbeat start'2~]# crm_mon3Refresh in 8s...45============6Last updated: Thu May 11 10:11:37 20177Current DC: node1 (1624d37b-cd63-473c-945e-d01c871f1326)82 Nodes configured.90 Resources configured.10============1112Node: node2 (331d95eb-4cf5-42a3-b0c6-935890125f9a): online13Node: node1 (1624d37b-cd63-473c-945e-d01c871f1326): online
crm配置较麻烦,所以使用gui的配置界面配置
使用xshell可以直接使用hb_gui来配置,不是xshell那我们只能去linux桌面环境配置。
node1
1 | ~]# hb_gui |
2 | ~]# echo 'jusene' | passwd --stdin hacluster |

GUI界面配置,可以很容易看见前面我们所讲的概念在这里都必须使用了:
- with quorum:投票半数以上的集群,也是有效集群
- ping node:仲裁设备
- dc:选举的调解员
- resources:资源配置
- constraints:资源约束
- locations:位置约束
- orders:顺序约束
- colocations:排列约束

我们在这里主要是两种资源组:httpd资源组和mysql资源组
我们可以将两个组分别运行在不同的节点,这也就是为什么数据库连接的时候采用外网的方式:
规划:
httpd:
- vip:10.211.55.24
- 位置约束:node2
- 顺序约束:ip->文件系统->httpd
- 排列约束:ip 文件系统 httpd
mysql
- vip: 10.211.55.67
- 位置约束:node2
- 顺序约束:ip->文件系统->mysqld
- 排列约束:ip 文件系统 mysqld

配置完成