corosync v1 + pacemaker
Corosync: an open cluster engine project derived from the development of OpenAIS to Wilson, which provides heartbeat message detection and member management.
Pacemaker: cluster explorer. It uses the message and member management capabilities provided by the cluster infrastructure (OpenAIS, heartbeat or corosync) to detect and recover from node or resource level failures, so as to achieve the maximum availability of cluster services (also known as resources).
Corosync: for clustering, Pacemaker: for managing resources.
This experiment uses Linux 6.8 system, file system resource server, NA1 node 1, NA2 node 2, VIP192.168.94.222
Directory structure:
1. Basic configuration
2. Software installation (corosync, pacemaker)
3. corosync profile configuration
4. Start the corosync service
5. View log information
1. Basic configuration
1. Modify the hostname and set the hostname resolution
2. Establish SSH mutual trust
3. NTP time synchronization
No demonstration here, please refer to
HeartBeat basic configuration (realizing Web service hot standby)
2. Software installation (corosync, pacemaker)
Here I use the yum of epel6 to install. The installed versions are respectively
corosync-1.4.7-6.el6.x86_64 pacemaker-1.1.18-3.el6.x86_64
NA1&NA2
yum Install software
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 profile configuration
NA1
cd /etc/corosync/ There is no configuration file by default. Copy the configuration sample and cancel the comment grep -v '#' corosync.conf.example >> corosync.conf
1. Edit profile
vim /etc/corosync/corosync.conf
compatibility: whitetank totem { version: 2 secauth: off compatibility: whitetank totem { version: 2 # Is it certified? We enable secauth: on threads: 0 # Define cluster information transfer interface interface { ringnumber: 0 # Heartbeat network segment bindnetaddr: 192.168.94.0 # Multicast transmits heartbeat information mcastaddr: 239.255.1.1 mcastport: 5405 ttl: 1 } } # Log logging { fileline: off to_stderr: no to_logfile: yes # /The var/lib/log/cluster directory does not exist by default and needs to be created manually logfile: /var/log/cluster/corosync.log to_syslog: yes debug: off # Record timestamp timestamp: on # Subsystem related settings logger_subsys { subsys: AMF debug: off } } //Define services, using pacemaker service { ver:0 name:pacemaker } # Define the working user of corosync. We use the root user under the root group, administrator. aisexec{ user:root group:root }
2. Generate key file
corosync-keygen
corosync generate key File will be called by default/dev/random Random number device,It takes a long time to operate.
implement corosync-keygen After the command, open a new graphical window, tap the keyboard casually, input the content, and it will be ready soon.
[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.
The authkey key file is generated in the current directory.
[root@na1 corosync]# ls authkey corosync.conf.example service.d corosync.conf corosync.conf.example.udpu uidgid.d [root@na1 corosync]#
NA2
NA1 After configuration, the NA1 Copy the profile of to NA2 Up.
[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. Start the corosync service
NA1&NA2
[root@na1 corosync]# service corosync start Starting Corosync Cluster Engine (corosync): [determine] [root@na1 corosync]# ssh na2 'service corosync start' Starting Corosync Cluster Engine (corosync): [determine] [root@na1 corosync]#
5. View log information
Check whether the corosync engine starts normally
[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]#
Check whether the notification of initialization member node is issued normally
[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]#
Check whether there is any error during startup
[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]#
The error message here indicates that packmaker will not run as a plug-in of corosync in the near future, so it is recommended to use cman as the cluster infrastructure service; it can be safely ignored here.
Check whether pacemaker starts normally
[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]#
View cluster status
2 Nodes online, 0 resources
[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]#
The environment is configured here. In the next article, use pacemaker for resource management.
There is always one on the way to study and keep fit