corosync和pacemaker實現httpd和mysql雙叢集

來源:互聯網
上載者:User

標籤:corosync pacemaker


一、環境介紹:


三台均為雙網卡:

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


具體查看如:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/73/95/wKioL1YBf1-TpZ9EAAOqpvAua-Y334.jpg" title="aa.png" alt="wKioL1YBf1-TpZ9EAAOqpvAua-Y334.jpg" />


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


本文出自 “秋天的童話” 部落格,請務必保留此出處http://wushank.blog.51cto.com/3489095/1697290

corosync和pacemaker實現httpd和mysql雙叢集

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.