高可用centos7 HA:corosync+packmaker+http\mysql

來源:互聯網
上載者:User

標籤:centos7   ha   高可用   corosync   pacemaker   http   

corosync+pacemaker:在配置corosync時最好具有三個以上的節點,並且節點個數 為奇數個,如果使用偶數個節點的話也沒關係,只是要關閉不具有法定票數的決策 策略功能

支援的服務在pacemaker目錄/usr/lib/ocf/resource.d/heartbeat

環境:

三台機器:centos7-docker-test1 10.1.1.170

                      centos7-docker-test2 10.1.1.169

                      centos7-docker-test3 10.1.1.171

叢集IP:10.1.1.207

 1.   配置這3台機器互相識別主機名稱:

例如在10.1.1.170機器上/etc/hosts檔案:

[[email protected] ~]# more /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.1.1.171  centos7-docker-test3

10.1.1.169  centos7-docker-test2

10.1.1.170  centos7-docker-test1

2.  三台機器關閉防火牆,setenforece為0,安裝ntp服務,保證兩台機器時間同步

#setenforce 0

#systemctl disable firewalld.service

#systemctl stop firewalld.service

#iptables --flush

 安裝時間服務:

yum install ntp

systemctl start ntpd

systemctl enable ntpd

ntpdate cn.pool.ntp.org

3. 在三台機器上安裝corosync和pacemaker安裝包:

yum install  -y pacemaker pcs psmisc policycoreutils-python

安裝完畢後,會產生一個系統使用者hacluster

4. 啟用pcs

#systemctl enable pcsd.service

#systemctl restart pcsd.service

#passwd hacluster(三台機器密碼保持一致)

5. 在一台機器上執行叢集認證:

pcs cluster auth -u hacluster -p futong-jw centos7-docker-test1 centos7-docker-test2 centos7-docker-test3

6 .   在一台機器上執行cluster同步配置

#pcs cluster setup --start --name mycluster 10.1.1.170 10.1.1.169

此命令會在三台機器的/etc/corosync目錄中增加corosync.conf設定檔

7 .  每次重啟自動啟動叢集:

#pcs cluster enable --all

兩個節點時,忽略quorum功能:

pcs property set no-quorum-policy=ignore

8. 檢驗:

#pcs status corosync

#pcs  status

 9.    配置共用資源

pcs property set stonith-enabled=false  禁用stonith裝置

 pcs resource create VIP ocf:heartbeat:IPaddr2 ip=10.1.1.207  cidr_netmask=24 op monitor  interval=30s            #配置共用IP

 #配置http服務HA,注意:所有節點上的http服務都必須先關閉,http HA才可以正常運行,因此安裝好httpd服務後,不要配置隨系統自動啟動功能

預設apache中沒有啟動status模組,所以先啟用status需要的模組  #所有節點上都要做這個設定

grep status_mod /etc/httpd/conf/httpd.conf

httpd -M | grep status

Vi httpd.conf

<Location /server-status>

     SetHandler server-status

     Order deny,allow

     allow from all

</Location>

http://blog.itpub.net/29620572/viewspace-1773071/  httpd.conf配置說明

pcs resource create web-server1 apache configfile="/etc/httpd/conf/httpd.conf"  statusurl="http://127.0.0.1/server-status"  

還要設定主機ClusterIP和web-server1應運行在統一節點上,這樣才能充分利用叢集IPde價值

pcs constraint colocation add Web ClusterIP INFINITY

還要設定這兩個啟動的先後次序

pcs constraint order ClusterIP then Web

配置mysql,系統中取消mysql自啟動,並停止mysql運行:

pcs resource create mysql-server mysql config="/etc/my.cnf" datadir="/var/lib/mysql" user="root"

pcs constraint colocation add mysql-server VIP1 INFINITY

pcs constraint order VIP1 then mysql-server

10. 查看目前叢集狀態

#pcs status

11. 可做如下兩個測試:

1)  關閉目前運行資源的節點,則資源轉移到其他節點上

2 )刪去目前運行資源節點上的httpd軟體,則VIP和web資源同時遷移到其他節點上

查看pcs cluster ip地址:

[[email protected] etc]# pcs resource show VIP

 Resource: VIP (class=ocf provider=heartbeat type=IPaddr2)

  Attributes: ip=10.1.1.207 cidr_netmask=24 

  Operations: start interval=0s timeout=20s (VIP-start-interval-0s)

              stop interval=0s timeout=20s (VIP-stop-interval-0s)

              monitor interval=30s (VIP-monitor-interval-30s)

http://blog.csdn.net/jemmy858585/article/details/43203375    pcs命令大全


本文出自 “老段的修鍊人生” 部落格,請務必保留此出處http://031028.blog.51cto.com/9866455/1837012

高可用centos7 HA:corosync+packmaker+http\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.