corosync v1 + pacemaker
Corosync: OpenAIS發(fā)展到Wilson版本后衍生出來的開放性集群引擎工程,提供心跳消息檢測及成員管理。
Pacemaker: 集群資源管理器。它利用集群基礎(chǔ)構(gòu)件(OpenAIS 、heartbeat或corosync)提供的消息和成員管理能力來探測并從節(jié)點或資源級別的故障中恢復(fù),以實現(xiàn)群集服務(wù)(亦稱資源)的最大可用性。
Corosync:用來做集群,Pacemaker:用來管理資源。
本實驗使用Linux6.8系統(tǒng),F(xiàn)ileSystem資源服務(wù)器,NA1節(jié)點1,NA2節(jié)點2,VIP192.168.94.222
目錄結(jié)構(gòu):
1、基礎(chǔ)配置
2、軟件安裝(corosync、pacemaker)
3、corosync配置文件配置
4、啟動corosync服務(wù)
5、查看日志信息
1、基礎(chǔ)配置
1、修改主機名,設(shè)置主機名解析
2、建立SSH互信
3、NTP時間同步
這里不做演示,參考
HeartBeat基礎(chǔ)配置(實現(xiàn)Web服務(wù)雙機熱備)
2、軟件安裝(corosync、pacemaker)
這里我使用epel6的yum進行安裝,安裝的版本分別是
corosync-1.4.7-6.el6.x86_64 pacemaker-1.1.18-3.el6.x86_64
NA1&NA2
yum安裝軟件
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm -y yum install -y corosync* yum install -y pacemaker*
3、corosync配置文件配置
NA1
cd /etc/corosync/ 默認沒有配置文件,拷貝配置樣例,并取消注釋 grep -v '#' corosync.conf.example >> corosync.conf
1、編輯配置文件
vim /etc/corosync/corosync.conf
compatibility: whitetank totem { version: 2 secauth: off compatibility: whitetank totem { version: 2 # 是否認證,我們啟用 secauth: on threads: 0 # 定義集群信息傳遞接口 interface { ringnumber: 0 # 心跳線網(wǎng)段 bindnetaddr: 192.168.94.0 # 組播傳播心跳信息 mcastaddr: 239.255.1.1 mcastport: 5405 ttl: 1 } } # 記錄日志 logging { fileline: off to_stderr: no to_logfile: yes # /var/lib/log/cluster 目錄默認不存在,需要手動創(chuàng)建 logfile: /var/log/cluster/corosync.log to_syslog: yes debug: off # 記錄時間戳 timestamp: on # 子系統(tǒng)相關(guān)設(shè)置 logger_subsys { subsys: AMF debug: off } } 定義服務(wù),使用pacemaker service { ver:0 name:pacemaker } # 定義corosync的工作用戶,我們使用root組下的root用戶,管理員。 aisexec{ user:root group:root }
2、生成秘鑰文件
corosync-keygen
corosync生成key文件會默認調(diào)用/dev/random隨機數(shù)設(shè)備,操作不夠多的花,會等待很長時間。
執(zhí)行corosync-keygen命令后,打開一個新的圖形化窗口,隨便敲擊鍵盤,輸入內(nèi)容,很快就好了。
[root@na1 corosync]# corosync-keygen Corosync Cluster Engine Authentication key generator. Gathering 1024 bits for key from /dev/random. Press keys on your keyboard to generate entropy. Press keys on your keyboard to generate entropy (bits = 48). Press keys on your keyboard to generate entropy (bits = 1008). Writing corosync key to /etc/corosync/authkey.會在當(dāng)前目錄生成authkey秘鑰文件。
[root@na1 corosync]# ls authkey corosync.conf.example service.d corosync.conf corosync.conf.example.udpu uidgid.d [root@na1 corosync]#
NA2
NA1配置完畢,將NA1的配置文件復(fù)制到NA2上。
[root@na1 corosync]# scp -p authkey corosync.conf na2:/etc/corosync/ authkey 100% 128 0.1KB/s 00:00 corosync.conf 100% 447 0.4KB/s 00:00
4、啟動corosync服務(wù)
NA1&NA2
[root@na1 corosync]# service corosync start Starting Corosync Cluster Engine (corosync): [確定] [root@na1 corosync]# ssh na2 'service corosync start' Starting Corosync Cluster Engine (corosync): [確定] [root@na1 corosync]#
5、查看日志信息
查看corosync引擎是否正常啟動
[root@na1 corosync]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/messages May 24 19:11:18 study corosync[5935]: [MAIN ] Corosync Cluster Engine ('1.4.7'): started and ready to provide service. May 24 19:11:18 study corosync[5935]: [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'. [root@na1 corosync]#
查看初始化成員節(jié)點通知是否正常發(fā)出
[root@na1 corosync]# grep TOTEM /var/log/messages May 24 19:11:18 study corosync[5935]: [TOTEM ] Initializing transport (UDP/IP Multicast). May 24 19:11:18 study corosync[5935]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0). May 24 19:11:18 study corosync[5935]: [TOTEM ] The network interface [192.168.94.129] is now up. May 24 19:11:18 study corosync[5935]: [TOTEM ] A processor joined or left the membership and a new membership was formed. May 24 19:11:40 study corosync[5935]: [TOTEM ] A processor joined or left the membership and a new membership was formed. [root@na1 corosync]#
檢查啟動過程中是否有錯誤產(chǎn)生
[root@na1 corosync]# grep ERROR: /var/log/cluster/corosync.log May 24 19:11:18 corosync [pcmk ] ERROR: process_ais_conf: You have configured a cluster using the Pacemaker plugin for Corosync. The plugin is not supported in this environment and will be removed very soon. May 24 19:11:18 corosync [pcmk ] ERROR: process_ais_conf: Please see Chapter 8 of 'Clusters from Scratch' (http://www.clusterlabs.org/doc) for details on using Pacemaker with CMAN [root@na1 corosync]#
這里的錯誤信息表示packmaker不久之后將不再作為corosync的插件運行,因此,建議使用cman作為集群基礎(chǔ)架構(gòu)服務(wù);此處可安全忽略。
查看pacemaker是否正常啟動
[root@na1 corosync]# grep pcmk_startup /var/log/messages May 24 19:11:18 study corosync[5935]: [pcmk ] info: pcmk_startup: CRM: Initialized May 24 19:11:18 study corosync[5935]: [pcmk ] Logging: Initialized pcmk_startup May 24 19:11:18 study corosync[5935]: [pcmk ] info: pcmk_startup: Maximum core file size is: 18446744073709551615 May 24 19:11:18 study corosync[5935]: [pcmk ] info: pcmk_startup: Service: 9 May 24 19:11:18 study corosync[5935]: [pcmk ] info: pcmk_startup: Local hostname: na1.server.com [root@na1 corosync]#
查看集群狀態(tài)
2個節(jié)點在線,0個資源
[root@na1 corosync]# crm_mon --one-shot Stack: classic openais (with plugin) Current DC: na1.server.com (version 1.1.18-3.el6-bfe4e80420) - partition with quorum Last updated: Sun May 24 19:24:13 2020 Last change: Sun May 24 19:07:27 2020 by hacluster via crmd on na1.server.com 2 nodes configured (2 expected votes) 0 resources configured Online: [ na1.server.com na2.server.com ] No active resources [root@na1 corosync]#
環(huán)境配置到這里,下一篇使用pacemaker進行資源管理。
讀書和健身總有一個在路上
聯(lián)系客服