Corosync/pacemaker for high-availability mariadb

Source: Internet
Author: User

Lab Environment:

Two MARIADB servers 172.16.10.20 172.16.10.21

fip:172.16.10.28

MARIADB file storage share: 172.16.10.22

Experiment Preparation:

1, two node host name and corresponding IP address resolution service can work, and the host name of each node needs to be consistent with the results of the "uname-n" command

Vim/etc/hosts 172.16.10.20 21.xuphoto.com 20xu 172.16.10.21 22.xuphoto.com 21xu Node1: # sed-i ' [email p Rotected]\ (hostname=\). *@\[email protected] ' # HOSTNAME 21.xuphoto.com Node2: # sed-i ' [Email protected]\ (HOS tname=\). *@\[email protected] ' # hostname 22.xuphoto.com

2, each node time consistency can add unified NTP Server Synchronization task:

CRONTAB-E */3 * * * */usr/sbin/ntpdate 172.16.0.1 &>/dev/null



3, between the nodes can be based on the key to verify SSH without password

ssh-keygen-t RSA Ssh-copy-id-i [email protected] # node1 node ssh-keygen-t RSA Ssh-copy-id -I [email protected] # Node1 Node

Configuring the Installation Corosync/pacemaker


Yum Install Corosync pacemaker-y
[Email protected]~]# rpm-ql corosync #查看 corosync file location/etc/corosync/etc/corosync/corosync.conf.example




1. Configure Corosync configuration file, multicast address, key verification, etc.

vim /etc/corosync/corosync.conf            compatibility:whitetank  #是否兼容whitetank版本   Keep it by default            totem defines the underlying communication layer:  multicast address, thread, security authentication and so on;           secauth:on    #安全认证          threads:0     #线程数  0 indicates that it is not based on threading mode and is based on process mode;interface:             ringnumber:0 #  keep 0  similar to TTL values            bindnetaddr:172.16.0.0  #监听的网络地址             mcasaddr:239.255.x.x   #多播地址           mcastport :5405        #多播端口            ttl:1                #TTL值默认logging:         to_logfile: yestimestamp: on               #是否记录时间戳, opening can affect performance, depending on system performance         logger_subsys {                 subsys:  Amf                debug:  off        }}


Configure Pacemake to run as plug-ins Insert the following code in corosync.conf

Service {ver:0 Name:pacemaker # use_mgmtd:yes}aisexec {user:root Group:root}




Generate a validation key using Corosync-keygen

2. using Corosync-kegen

Run the command directly, but he needs to read 1024 random numbers from the random number entropy pool/dev/random If I am not enough to do I/O operations

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/EC/wKiom1Vu8o-j_zFGAASH7RYFSak572.jpg "title=" image 0531.jpg "alt=" Wkiom1vu8o-j_zfgaash7ryfsak572.jpg "/>

3. Copy authkey corosync.conf file to another node

Scp-p Authkey corosync.conf 20xu:/etc/corosync

4. Start the service

# service Corosync start;ssh 20xu ' service corosync start '


5404 The port is in listening state;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/EC/wKiom1Vu82yCbB2NAAHpAaHSOVU097.jpg "title=" image 0531 (2). jpg "alt=" wkiom1vu82ycbb2naahpaahsovu097.jpg "/>



#tail-F/var/log/cluster/corosync.log #监控 log system to see if there is an abnormal state;


Install Crmsh (can be installed on DC, or every installation)

Download the Crmsh pssh and then use the Yum installation to resolve the dependency without checking the GPG information,

#yum--nogpgcheck Localinstall crmsh-2.1-1.6.x86_64.rpm pssh-2.3.1-2.el6.x86_64.rpm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/E8/wKioL1Vu9XTg92b3AAMS1oV7WAs443.jpg "title=" image 0531 (3). jpg "alt=" wkiol1vu9xtg92b3aams1ov7was443.jpg "/>



Installation Complete:

Use CRM to enter sub-command mode;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/E8/wKioL1Vu9gvQUKW5AAExWY_0etY729.jpg "title=" image 0603.jpg "alt=" Wkiol1vu9gvqukw5aaexwy_0ety729.jpg "/>

Configuring Global Properties

CRM (live) Configure#property Stonith-enabled=false

# if no stonith devices need to be banned

CRM (Live) Configure#property no-quorum-policy=Ignore

CRM (Live) configure#verify # check Syntax:

Commit : #保存


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/EC/wKiom1Vu9UaCxmI2AAG1pHHNqBA345.jpg "title=" image 0531 (one). jpg "alt=" wkiom1vu9uacxmi2aag1phhnqba345.jpg "/>



Define fip:172.16.10.28

CRM (Live) configure#primitive mysqlip ocf:heartbeat:IPaddr params ip=172.16.10.28 nic=eth0cidr_netmask=16 op Monitor Interval=10s timeout=20s


Define Mysqlnfs

CRM (Live) configure#primitive mysqlnfs ocf:heartbeat:Filesystem paramsdevice= "172.16.10.22:/mysql" directory= "/ MySQL "Fstype=" NFS "OP monitor timeout=40 interval=20 op start timeout=60 opstop timeout=60


Define MySQL:

CRM (Live) Configure#primitive mysqld lsb:mysqld op monitor timeout=40 interval=2


To define a group:

CRM (Live) Configure#group mysqlgroup mysqlip Mysqlnfs mysqld


definition sort:

CRM (Live) Configure#order Mysqlip_before_mysqlnfs mandatory:mysqlip Mysqlnfscrm (live) Configure#order Mysqlnfs_ Before_mysqld Mandatory:mysqlnfs mysqld

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/EC/wKiom1Vu9gSDfcV4AAKA5PBIXzw594.jpg "title=" image 0531 (+). jpg "alt=" wkiom1vu9gsdfcv4aaka5pbixzw594.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/EC/wKiom1Vu9iSCpOOaAAKcxzhp-H4542.jpg "title=" image 0531 (+). jpg "alt=" wkiom1vu9iscpooaaakcxzhp-h4542.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/EC/wKiom1Vu9kaj-pq8AAIpt6Db5J4839.jpg "title=" image 0531 (). jpg "alt=" wkiom1vu9kaj-pq8aaipt6db5j4839.jpg "/>


Data is normal after switching nodes.


Corosync/pacemaker for high-availability mariadb

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.