HA_Cluster: corosnc+pacemaker+drbd+msql
本文主要讲述HA_Cluster: corosync+pacemaker+drbd+mysql 的CRM资源配置, 各个软件的安装配置不再介绍
CRM配置DRBD资源:
1.基本配置:
crm(live)configure# property stonith-enabled=false # 关闭stonithcrm(live)configure# property no-quorum-policy=ignore # 不具备法定票数时的行为: 忽略crm(live)configure# rsc_defaults resource-stickiness=100 # 默认资源粘性为100crm(live)configure# verifycrm(live)configure# commit
2.添加DRBD资源:
crm(live)configure# primitive drbd_data ocf:linbit:drbd params drbd_resource="data" op monitor role="Master" interval="50" timeout="30" op monitor role="Slave" intervalinterval-origin= interval= crm(live)configure# primitive drbd_data ocf:linbit:drbd params drbd_resource=data op monitor role=Master interval=50 timeout=30 op monitor role=Slave interval=60 timeout=30 op start timeout=240 op stop timeout=100crm(live)configure# verifycrm(live)configure# ms ms_drbd_data drbd_data meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=truecrm(live)configure# verifycrm(live)configure# commit
PS: heartbeat 和 linbit 都提供了drbd 的 RA ,本人实验时发现使用 heartbeat 提供的 RA 会出现无法选举 Master 节点的情况, 此处建议使用 linbit 提供的RA
如有人知道为什么 heartbeat 的 RA 选不出 Master 节点, 愿闻其详
测试DRBD服务:
root@drbd1:~# crm statusLast updated: Sun May 22 22:04:35 2016Last change: Mon May 23 06:02:13 2016 via cibadmin on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured2 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ]root@drbd1:~# crm node standby **# 离线drbd1**root@drbd1:~# crm statusLast updated: Mon May 23 06:07:22 2016Last change: Mon May 23 06:07:14 2016 via crm_attribute on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured2 Resources configuredNode drbd1 (168495249): standbyOnline: [ drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Stopped: [ drbd1 ]root@drbd1:~# crm node online **# 上线drbd1**root@drbd1:~# crm statusLast updated: Mon May 23 06:09:11 2016Last change: Mon May 23 06:09:09 2016 via crm_attribute on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured2 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ]root@drbd2:~# crm node standby # 离线drbd2root@drbd2:~# crm node online # 上线drbd2root@drbd2:~# crm statusLast updated: Sun May 22 22:11:47 2016Last change: Mon May 23 06:11:18 2016 via crm_attribute on drbd2Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured2 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ]-------------正常---------------
配置Filesystem资源:
crm(live)configure# primitive mount ocf:heartbeat:Filesystem params device=/dev/drbd0 directory=/var/lib/mysql fstype=ext3 op start timeout=60 op stop timeout=60crm(live)configure# verifycrm(live)configure# colocation mount_with_ms_drbd_data inf: mount ms_drbd_data:Mastercrm(live)configure# order mount_after_ms_drbd_data Mandatory: ms_drbd_data:promote mount:startcrm(live)configure# verifycrm(live)configure# commit
测试Filesystem资源:
root@drbd2:~# crm statusLast updated: Mon May 23 20:28:19 2016Last change: Mon May 23 20:27:37 2016 via crm_attribute on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured3 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ] mount (ocf::heartbeat:Filesystem): Started drbd2 # 现在drbd0挂载在drbd2上root@drbd2:~# crm node standbyroot@drbd2:~# crm node onlineroot@drbd2:~# crm statusLast updated: Mon May 23 20:28:31 2016Last change: Mon May 23 20:28:28 2016 via crm_attribute on drbd2Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured3 Resources configuredNode drbd2 (168495262): standbyOnline: [ drbd1 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Stopped: [ drbd2 ] mount (ocf::heartbeat:Filesystem): Started drbd1 # 成功转移到drbd1
配置mysql(此处直接使用apt-get安装)资源:
crm(live)configure# primitive mysqld lsb:mysqlcrm(live)configure# primitive mysql_ip ocf:heartbeat:IPaddr params ip=10.11.8.200 cidr_netmask=23crm(live)configure# verifycrm(live)configure# colocation mysql_ip_with_mount inf: mysql_ip mountcrm(live)configure# colocation mysqld_with_mount inf: mysqld mountcrm(live)configure# order mysqld_after_mount Mandatory: mount mysqldcrm(live)configure# verifycrm(live)configure# commit
查看CRM配置:
node $id="168495249" drbd1 \ attributes standby="off"node $id="168495262" drbd2 \ attributes standby="off"primitive drbd_data ocf:linbit:drbd \ params drbd_resource="data" \ op monitor role="Master" interval="50" timeout="30" \ op monitor role="Slave" interval="60" timeout="30" \ op start timeout="240" interval="0" \ op stop timeout="100" interval="0"primitive mount ocf:heartbeat:Filesystem \primitive mount ocf:heartbeat:Filesystem \ params device="/dev/drbd0" directory="/var/lib/mysql" fstype="ext3" \ op start timeout="60" interval="0" \ op stop timeout="60" interval="0" \ meta target-role="Started"primitive mysql_ip ocf:heartbeat:IPaddr \ params ip="10.11.8.200" cidr_netmask="23"primitive mysqld lsb:mysqlms ms_drbd_data drbd_data \ meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" target-role="Started"colocation mount_with_ms_drbd_data inf: mount ms_drbd_data:Mastercolocation mysql_ip_with_mount inf: mysql_ip mountcolocation mysqld_with_mount inf: mysqld mountorder mount_after_ms_drbd_data Mandatory: ms_drbd_data:promote mount:startorder mysqld_after_mount Mandatory: mount mysqldproperty $id="cib-bootstrap-options" \ dc-version="1.1.10-42f2063" \ cluster-infrastructure="corosync" \ stonith-enabled="false" \ no-quorum-policy="ignore" \ last-lrm-refresh="1464019270"rsc_defaults $id="rsc-options" \ resource-stickiness="100"
修改mysql监听所有地址:
root@drbd1:~# vim /etc/mysql/my.cnf# bind-address = 127.0.0.1 # 注释这一行
测试服务:
root@drbd1:~# crm statusLast updated: Tue May 24 00:55:04 2016Last change: Tue May 24 00:42:45 2016 via crmd on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured5 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd1 ] Slaves: [ drbd2 ] mount (ocf::heartbeat:Filesystem): Started drbd1 mysqld (lsb:mysql): Started drbd1 mysql_ip (ocf::heartbeat:IPaddr): Started drbd1
在drbd2上连接测试:
root@drbd2:~# mysql -h10.11.8.200 -ushiina -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 40Server version: 5.6.30-0ubuntu0.14.04.1 (Ubuntu)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+---------------------+| Database |+---------------------+| information_schema || # mysql50# lost+found || mysql || performance_schema |+---------------------+4 rows in set (0.01 sec)mysql> create database ha_test;Query OK, 1 row affected (0.00 sec)
离线drbd1后再drbd1上连接测试:
root@drbd1:~# crm statusLast updated: Mon May 23 21:13:24 2016Last change: Mon May 23 21:13:22 2016 via cibadmin on drbd1Stack: corosyncCurrent DC: drbd1 (168495249) - partition with quorumVersion: 1.1.10-42f20632 Nodes configured5 Resources configuredOnline: [ drbd1 drbd2 ]Master/Slave Set: ms_drbd_data [drbd_data] Masters: [ drbd2 ] Slaves: [ drbd1 ] mount (ocf::heartbeat:Filesystem): Started drbd2 mysql_ip (ocf::heartbeat:IPaddr): Started drbd2 mysqld (lsb:mysql): Started drbd2root@drbd1:~# mysql -h10.11.8.200 -ushiina -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 40Server version: 5.6.30-0ubuntu0.14.04.1 (Ubuntu)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || ha_test || lost+found || mysql || performance_schema |+--------------------+5 rows in set (0.00 sec)
关键字:ha, cluster, drbd, mysql
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!