corosync和pacemaker实现httpd和mysql双集群
一、環境介紹:
三臺均為雙網卡:
openstack-control.example.com openstack-control
?? eth0:172.16.171.100
?? eth1:10.1.1.100
openstack-nova.example.com openstack-nova
?? eth0:172.16.171.110
?? eth1:10.1.1.110
openstack-neutron.example.com openstack-neutron
?? eth0:172.16.171.120
?? eth1:10.1.1.120
二、corosync和pacemaker配置步驟如下:
1、? 配置時區及同步時間
2、配置集群節點間通過主機名互相通信
3、配置集群主機能使root用戶基于無密碼ssh秘鑰方式進行通信
4、 關閉selinux和iptables
5、安裝corosync和pacemaker包
6、? 修改corosync.conf配置文件
compatibility: whitetank
totem {
??????? version: 2
??????? secauth: on
??????? threads: 2
??????? rrp_mode: passive
??????? interface {
??????????????? ringnumber: 0
??????????????? bindnetaddr: 10.1.1.0
??????????????? mcastaddr: 239.255.1.1
??????????????? mcastport: 5405
??????????????? ttl: 1
??????? }
??????? interface {
??????????????? ringnumber: 1
??????????????? bindnetaddr: 172.16.171.0
??????????????? mcastaddr: 238.255.1.1
??????????????? mcastport: 5406
??????????????? ttl: 1
??????? }
}
logging {
??????? fileline: off
??????? to_stderr: no
??????? to_logfile: yes
??????? logfile: /var/log/cluster/corosync.log
??????? to_syslog: no
??????? debug: off
??????? timestamp: on
??????? logger_subsys {
??????????????? subsys: AMF
??????????????? debug: off
??????? }
}
service {
??????? ver: 0
??????? name: pacemaker
}
7、生成認證文件:authkey 并傳給其他集群服務器
8、啟動corosync服務,并查看日志
9、安裝crmsh
http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/
[network_ha-clustering_Stable]
name=Stable High Availability/Clustering packages (CentOS_CentOS-6) type=rpm-md
baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/repodata/repomd.xml.key
enabled=1
10、使用crmsh工具配置全局屬性
crm(live)#configure
crm(live)configure#property stonith-enabled=false
crm(live)configure#property no-quorum-policy=ignore
crm(live)configure#property default-resource-stickiness=100
11、使用crmsh工具配置ip資源、nfs資源和mysql資源和配置這兩個資源的協同約束(排列約束)、順序約束
mysql:
crm(live)configure#primitive mysqlvip ocf:heartbeat:IPaddr? params? ip='10.1.1.200' nic='eth1' cidr_netmask='24' broadcast='10.1.1.0' op monitor interval=30s(啟動延遲時間) timeout=20s(監控超時時間)
crm(live)configure#primitive mysqlnfs ocf:heartbeat:Filesystem params device='10.1.1.100:/mysqldata' directory='/mydata' fstype='nfs' op monitor interval=20s timeout=40s
crm(live)configure#verify
crm(live)configure#primitive mysqlserver lsb:mysqld op monitor interval=30s timeout=15s
crm(live)configure#colocation? myserver inf: mysqlvip mysqlnfs mysqlserver
crm(live)configure#order mysqlnfs_before_mysqlserver mandatory: mysqlnfs mysqlserver
httpd:
crm(live)configure#primitive httpdvip ocf:heartbeat:IPaddr? params? ip='172.16.171.200' nic='eth0' cidr_netmask='24' broadcast='172.16.171.0' op monitor interval=30s(啟動延遲時間) timeout=20s(監控超時時間)
crm(live)configure#primitive httpdnfs ocf:heartbeat:Filesystem params device='172.16.171.100:/myhttpd' directory='/var/www/html' fstype='nfs' op monitor interval=20s timeout=40s
crm(live)configure#verify
crm(live)configure#primitive httpdserver lsb:httpd op monitor interval=30s timeout=15s
crm(live)configure#colocation? myapacheserver inf: httpdvip httpdnfs httpdserver
crm(live)configure#order httpdnfs_before_httpdserver mandatory: httpdnfs httpdserver
具體查看如下圖:
12、查看節點情況
crm(live)# status
Last updated: Wed Sep 23 00:08:39 2015
Last change: Wed Sep 23 00:08:33 2015
Stack: classic openais (with plugin)
Current DC: openstack-control.example.com - partition with quorum
Version: 1.1.11-97629de
3 Nodes configured, 3 expected votes
6 Resources configured
Online: [ openstack-control.example.com openstack-neutron.example.com openstack-nova.example.com ]
?mysqlnfs?????? (ocf::heartbeat:Filesystem):??? Started openstack-control.example.com
?mysqlvip?????? (ocf::heartbeat:IPaddr):??????? Started openstack-control.example.com
?mysqlserver??? (lsb:mysqld):?? Started openstack-control.example.com
?httpdvip?????? (ocf::heartbeat:IPaddr):??????? Started openstack-control.example.com
?httpdnfs?????? (ocf::heartbeat:Filesystem):??? Started openstack-control.example.com
?httpdserver??? (lsb:httpd):??? Started openstack-control.example.com
通過如下進行主備切換:
??? node online openstack-neutron.example.com
??? node standby openstack-neutron.example.com
轉載于:https://blog.51cto.com/wushank/1697290
總結
以上是生活随笔為你收集整理的corosync和pacemaker实现httpd和mysql双集群的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android百度地图开发01之初体验
- 下一篇: Android MediaScanner