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 nfs
2
~]# mkdir /mysqldata
3
~]# mkdir /www
4
~]# chown -R apache.apache /www
5
~]# chown -R mysql.mysql /mysqldata
6
~]# vim /etc/exports
7
/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 start
node1
1
~]# yum install -y showmount httpd php mysql-server
2
~]# showmount -e 10.211.55.39
3
Export list for 10.211.55.39:
4
/mysqldata 10.211.55.0/24
5
/www 10.211.55.0/24
6
~]# mkdir /mysqldata
7
~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata
8
~]# ll -d /mysqldata
9
~]# mysql_install_db --datadir=/mysqldata --user=mysql
10
~]# service mysqld start
11
~]# mount -t nfs 10.211.55.39:/www /var/www/html
12
~]# tar xf wordpress.tar.gz -C /var/www/html
13
~]# mysql
14
Welcome to the MySQL monitor. Commands end with ; or \g.
15
Your MySQL connection id is 2
16
Server version: 5.1.73 Source distribution
17
18
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
19
20
Oracle is a registered trademark of Oracle Corporation and/or its
21
affiliates. Other names may be trademarks of their respective
22
owners.
23
24
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
25
26
mysql> create database wordpress;
27
Query OK, 1 row affected (0.04 sec)
28
29
mysql> grant all on wordpress.* to wordpress@'10.211.55.63' identified by 'wordpress';
30
Query OK, 0 rows affected (0.00 sec)
31
~]# service httpd start
32
33
web配置完wordpress的配置
34
35
~]# service httpd stop
36
~]# service mysqld stop
node2
1
~]# yum install -y showmount httpd php mysql-server
2
~]# mkdir /mysqldata
3
~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata
4
~]# ll -d /mysqldata
5
~]# service mysqld start
6
~]# mount -t nfs 10.211.55.39:/www /var/www/html
7
~]# service mysqld start
8
~]# service httpd start
9
10
web测试完成
11
12
~]# service httpd stop
13
~]# service mysqld stop
heartbeat v2配置
node1
1
~]# echo 'crm on' >> /etc/ha.d/ha.cf
2
~]# cd heartbeartv2
3
~]# yum install -y pygtk2-libglade
4
~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm
node2
1
~]# echo 'crm on' >> /etc/ha.d/ha.cf
2
~]# cd heartbeartv2
3
~]# yum install -y pygtk2-libglade
4
~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm
node1
1
~]# service heartbeat start;ssh node2 'service heartbeat start'
2
~]# crm_mon
3
Refresh in 8s...
4
5
============
6
Last updated: Thu May 11 10:11:37 2017
7
Current DC: node1 (1624d37b-cd63-473c-945e-d01c871f1326)
8
2 Nodes configured.
9
0 Resources configured.
10
============
11
12
Node: node2 (331d95eb-4cf5-42a3-b0c6-935890125f9a): online
13
Node: 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:排列约束
![](/image/34.png ‘组资源’)
我们在这里主要是两种资源组:httpd资源组和mysql资源组
我们可以将两个组分别运行在不同的节点,这也就是为什么数据库连接的时候采用外网的方式:
规划:
httpd:
- vip:10.211.55.24
- 位置约束:node2
- 顺序约束:ip->文件系统->httpd
- 排列约束:ip 文件系统 httpd
mysql
- vip: 10.211.55.67
- 位置约束:node2
- 顺序约束:ip->文件系统->mysqld
- 排列约束:ip 文件系统 mysqld
配置完成