Corosync pacemaker mysql replication for High Availability

Source: Internet
Author: User


The search algorithm for the Niang, as well as the bidding rankings, I just want to say that I bought a watch last year.

One, MySQL replication master configuration

Please refer to: MySQL replication master (master-slave) Sync http://www.111cn.net/database/mysql/83904.htm

Second, Corosync pacemaker installation configuration

Please refer to: Corosync pacemaker Nginx High-availability installation configuration
The above two blog/etc/hosts is the definition of different, to MySQL replication, that is, masters,slave2.
Notice here that after you have changed the name of the hosts, masters the node to regenerate the auth file.

[Root@masters corosync]# Corosync-keygen

[root@masters corosync]# Scp/etc/corosync/authkey corosync////If there are many nodes to copy


Each node restarts Corosync.

Third, masters node, configuring MySQL Crmsh

1, configure MySQL Crmsh

[root@masters tank]# crm   CRM (Live) # configure    CRM (Live) configure#   CRM (Live) configure# property stonith-enabled=false    CRM (Live) configure# property no-quorum-policy=ignore   CRM (Live) configure#  primitive mysqlip ocf:heartbeat:ipaddr params ip=192.168.10.231 op monitor  interval=30s timeout=20s on-fail=restart   CRM (Live) configure# primitive  mysqlserver lsb:mysqld   CRM (Live) configure# colocation mysql_col inf:  mysqlserver mysqlip   CRM (Live) configure# order mysql_after_ip mandatory:  mysqlip mysqlserver   CRM (Live) configure# verify   CRM (Live) Configure# commit    CRM (Live) Configure# show 
Here to find a problem, read some information on the Internet, about the monitor after the time configuration, there are several versions of the
monitor interval=30 timeout=20
monitor interval= "20" timeout= "
Monitor interval= "30s" timeout= "20s"
I did not verify the correctness of these formulations, but monitor interval=30s timeout=20s, this is certainly the correct wording, The system I use is CentOS 6.5 64 bits, and it's also written in the Help document.
Pacemaker corosync Time
writing Pacemaker Corosync Time Writing
This is after the configuration is complete, through show to view the
configuration succeeded, through the configure
of MySQL to a successful configuration after the Configure MySQL

2, detect the MySQL node state

[root@masters tank]# crm status   last updated: thu apr 23 

02:36:54 2015   last change: thu apr 23 02:36:06 2015   stack: classic openais  (with plugin)    current dc: slave2 -  partition with quorum   version: 1.1.11-97629de   5 Nodes  configured, 2 expected votes   3 resources configured       online: [ masters slave2 ]  //Two nodes must be online    offline: [  localhost.localdomain node1 node2 ]       webip  (ocf::heartbeat:i PADDR): started masters    nginx_res  (Lsb:nginx): started masters     mysqlip  (OCF::HEARTBEAT:IPADDR): started slave2    mysqlserver  ( Lsb:MYSQLD):  started slave2 
If online, the node is not full, offline the machine above, perform
[root@slave2 ~]# CRM node online

Four, test

[Tank@localhost ~]$ mysql-u test-p-H 192.168.10.231//If actual connection Masters

[root@masters ~]# CRM node standby//master s machine, suspend Masters

[Tank@localhost ~]$ mysql-u test-p-H 192.168.10.231//If successfully connected to Slave2, test success


There are three MySQL, one main two from, if the main server down machine, two from the server, can automatically turn into a main from, and to maintain the completion of data, MHA can help us solve this problem

Related Article

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.