MySQL on Azure High Availability Design DRBD-COROSYNC-PACEMAKER-CRM (ii)

Source: Internet
Author: User
Tags mysql client rpmbuild

In the previous article described the MySQL HA on azured design idea, this article will describe the specific deployment, installation and configuration of each component.

The overall design structure is as follows:

The following will be the installation configuration process for all components, all of which are CentOS 6.5 operating systems. The new virtual machines on Azure, the configuration of the vnet, etc. are no longer covered in this article. If necessary, please refer to the blog of Zhang Lei's classmates:

Http://www.cnblogs.com/threestone

  1. Configure Azure Internal Load balance and add hard drives

    This article uses the Xplate CLI to deploy the internal Load balancer, whose address is static 10.1.1.200,distribution mode with SOURCEIP.

      1. First create an ILB:

    Azure Service Internal-load-balancer add-a 10.1.1.200-t Subnet-2 mysql-ha mysql-ha-ilb

    Info:service internal-load-balancer Add Command OK

      1. Creating Endpoint and Loadbalanceset

    Azure VM Endpoint Create-n Mysql-o tcp-t 3306-r tcp-b mysql-ha-lbs-i mysql-ha-ilb-a sourceIP mysql-ha1 3306 3306

    INFO:VM Endpoint Create command OK

    Azure VM Endpoint Create-n Mysql-o tcp-t 3306-r tcp-b mysql-ha-lbs-i mysql-ha-ilb-a sourceIP mysql-ha2 3306 3306

    INFO:VM Endpoint Create command OK

      1. View ILB
      2. Fixed dip addresses for two VMS

    Azure VM Static-ip Set MYSQL-HA1 10.1.1.6

    Azure VM Static-ip Set MYSQL-HA2 10.1.1.7

      1. Add 20G of hard disk to each VM

    Azure VM Disk Attach-new MYSQL-HA1 https://portalvhds68sv75c8hs05m.blob.core.chinacloudapi.cn/hwmysqltest/ Mysqlha1sdc.vhd

    Azure VM Disk Attach-new MYSQL-HA2 https://portalvhds68sv75c8hs05m.blob.core.chinacloudapi.cn/hwmysqltest/ Mysqlha2sdc.vhd

?

  1. Installing the deployment DRBD on the server

    ?

      1. Install dependent packages

    Yum-y install gcc rpm-build kernel-devel kernel-headers Flex Ncurses-devel

      1. Download the DRBD installation package and install

    wget http://elrepo.org/linux/elrepo/el5/x86_64/RPMS/drbd84-utils-8.4.3-1.el5.elrepo.x86_64.rpm

    wget http://elrepo.org/linux/elrepo/el6/x86_64/RPMS/kmod-drbd84-8.4.3-1.el6_4.elrepo.x86_64.rpm

    Yum-y Install drbd84-utils-8.4.3-1.el5.elrepo.x86_64.rpm

    Yum Install-y kmod-drbd84-8.4.3-1.el6_4.elrepo.x86_64.rpm

      1. Turn off SELinux

    Setenforce 0

    or modify the configuration file/etc/sysconfig/selinux

    Selinux=disabled

      1. Modifying a configuration file

    Vim/etc/drbd.d/mysql.res

    Resource MySQL {

    Protocol C;

    device/dev/drbd0;

    DISK/DEV/SDC1;

    Meta-disk internal;

    On MYSQL-HA1 {

    Address 10.1.1.6:7789;

    }

    On MYSQL-HA2 {

    Address 10.1.1.7:7789;

    }

    }

      1. Modify the Hosts file

    To ensure that DRBD works properly, modify the Hosts file to add the DRBD cluster machine to the Hosts file

    Vim/etc/hosts

    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

    :: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

    10.1.1.6 MYSQL-HA1

    10.1.1.7 MYSQL-HA2

      1. to/DEV/SDC partition

    Note that you are not formatting at this time. The specific method is no longer described.

      1. Create a work disk for DRBD

    Run Drbdadm CREATE-MD MySQL on two VMs and create a work disk for DRBD, respectively

    Run on MYSQL-HA1: Drbdadm----Overwrite-data-of-peer primary MySQL, making this VM a primary for the DRBD group. When you view the status of DRBD by Drbd-overview, you can see that two disks are synchronizing at this time:

    0:mysql/0 syncsource primary/secondary uptodate/inconsistent C r-----

    ???? [A]. ..... ......... Sync ' ed:0.6% (20372/20476) M

    The format is now on the master node: mkfs.ext4/dev/drbd0

    ?

    At this point, the DRBD installation configuration is complete. At this point, you can only mount this DRBD disk on primary VMS, only see this disk on secondary VMS, but you cannot manipulate it.

    ?

  2. Installing Deployment Corosync, pacemaker, and CRM on the server

As mentioned earlier, corosync the entire cluster message layer,pacemaker is the brain of the cluster, and the CRM software is the editor of the cluster. The installation deployment process for the cluster is as follows:

    1. Add a Epel yum source

In the domestic visits abroad Epel source because is affected by the GFW, cannot visit. So choose the domestic Yahoo yum source. Here's how:

Vim/etc/yum.repos.d/epel.repo

[Epel]

Name=epel

baseurl=http://mirrors.sohu.com/fedora-epel/6/$basearch

Enabled=1

Gpgcheck=0

?

  1. Install in the following order

    Yum install-y Corosync pacemaker-y

    Yum Install Cluster-glue-y

    wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/src/crmsh-2.1-1.6.src.rpm

    wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/src/pssh-2.3.1-4.2.src.rpm

    Yum install python-devel python-setuptools gcc make gcc-c++ rpm-build python-lxml cluster-glue-libs-devel Pacemaker-libs-devel AsciiDoc autoconf Automake redhat-rpm-config-y

    Rpmbuild--rebuild crmsh-2.1-1.6.src.rpm

    Rpmbuild--rebuild pssh-2.3.1-4.2.src.rpm

    cd/root/rpmbuild/rpms/x86_64/

    Yum Install *-y

  2. Configuring the Corosync configuration file

    The member configuration and TRANSPORT:UDPU are specified with the UDP unicast (unicast) configuration.

    Make full mesh node configuration on all nodes:

    Vim/etc/corosync/corosync.conf

    Compatibility:whitetank

    Totem {

    Version:2

    Secauth:off

    threads:0

    interface {

    member{

    memberaddr:10.1.1.6

    }

    member{

    memberaddr:10.1.1.7

    }

    ringnumber:0

    bindnetaddr:10.1.1.0

    mcastport:5405

    Ttl:1

    }

    Transport:udpu

    }

    Logging {

    Fileline:off

    To_stderr:no

    To_logfile:yes

    LogFile:/var/log/cluster/corosync.log

    To_syslog:yes

    Debug:off

    Timestamp:on

    Logger_subsys {

    Subsys:amf

    Debug:off

    }

    }

    AMF {

    Mode:disabled

    }

    Service {

    Ver:1

    Name:pacemaker

    Use_mgmtd:no

    Use_logd:no

    }

    aisexec {

    User:root

    Group:root

    }

    ?

  3. Generate a Corosync key file

Mv/dev/random/dev/random.bak

Ln-s/dev/urandom/dev/random

Corosync-keygen

Scp/etc/corosync/authkey Mysql-ha2:/etc/corosync

    1. Start Corosync and Pacemaker services

Service Corosync Start

SSH mysql-ha2 ' service corosync start '

Service Pacemaker Start

SSH mysql-ha2 ' service pacemaker start '

    1. Install azure components, create a MDFILB service

To install the Azure CLI:

Yum Install Nodejs–y

Yum Install Npm–y

NPM Install Azure-cli–g

Create a file in/etc/init.d mdfilb

#!/bin/sh

Start ()

{

Echo-n $ "Starting Azure ILB Modify:"

/root/mdfilb.sh

Echo

}

Stop ()

{

Echo-n $ "Shutting down Azure ILB Modify:"

Echo

}

mdfilb= "/root/mdfilb.sh"

[-F $MDFILB] | | Exit 1

# See how we were called.

Case "$" in

Start

Start

;;

Stop

Stop

;;

Restart

Stop

Sleep 3

Start

;;

*)

echo $ "Usage: $ {Start|stop|restart}"

Exit 1

Esac

Exit 0

vim/root/mdfilb.sh

Azure VM Endpoint Delete mysql-ha2 MySQL

Azure VM Endpoint create-i mysql-ha-ilb-o tcp-t 3306-k 3306-b mysql-ha-lbs-r tcp-a sourceIP mysql-ha1 3306 3306

?

However, the VM is not stable to the ILB for the modified result.

    1. Orchestration of pacemaker through CRM

?

    1. The CRM configure enters the editing interface and adjusts the two global parameters:

Property Stonith-enabled=false

Property No-quorum-policy=ignore

    1. Choreography

Before the orchestration of the business, two VMS need to be restarted.

    1. DRBD Services

CRM Configure

Primitive MYSQLDRBD OCF:LINBIT:DRBD params drbd_resource= "MySQL" Op start timeout=240 op stop timeout=240

Ms MYDRBD MYSQLDRBD Meta master-max= "1" master-node-max= "1" clone-max= "2" clone-node-max= "1" notify= "true"

Verify

Commit

    1. File Mount Service

Primitive Mystore ocf:heartbeat:Filesystem params device=/dev/drbd0 directory=/mydata fstype=ext4 op start timeout=60 op Stop timeout=60

Verify

Commit

Guaranteed file mount and DRBD on a single machine with guaranteed boot sequence

colocation MYSTORE_WITH_MYSQLDRBD Inf:mystore Mydrbd:master

Order MYSTORE_AFTER_MS_MYDRBD Mandatory:mydrbd:promote Mystore:start

Verify

Commit

    1. Change the service of an ILB

Primitive Mdfilb LSB:MDFILB

Ensure that the file is mounted on a server with a boot sequence

colocation mdfilb_with_mystore inf:mdfilb Mystore

Order Mdfilb_after_mystore Mandatory:mystore Mdfilb

Verify

Commit

    1. MySQL Service

Primitive Mysqld Lsb:mysqld

Ensure that the file is mounted on a server with a boot sequence

colocation mysqld_with_mystore inf:mysqld Mystore

Order Mysqld_after_mdfilb Mandatory:mdfilb Mysqld

Verify

Commit

?

At this point, all configurations are configured to complete. In the test, the VM controls the portion of the ILB that is not stable and can be deployed as appropriate.

You can view the status:

?

On the MYSQL-HA1:

[[email protected]/]# CRM status

Last Updated:sun Dec 6 03:33:21 2015

Last Change:sun Dec 6 02:57:11 2015

Stack:classic Openais (with plugin)

Current dc:mysql-ha2-partition with Quorum

Version:1.1.11-97629de

2 Nodes configured, 2 expected votes

5 Resources configured

?

?

Online: [Mysql-ha1 MYSQL-HA2]

?

Master/slave SET:MYDRBD [MYSQLDRBD]

Masters: [MYSQL-HA2]

Slaves: [MYSQL-HA1]

Mystore???? (Ocf::heartbeat:filesystem):???? Started MYSQL-HA2

MDFILB???? (LSB:MDFILB):???? Started MYSQL-HA2

MYSQLD???? (LSB:MYSQLD):???? Started MYSQL-HA2

?

?

[Email protected]/]# Drbd-overview

0:mysql/0 Connected secondary/primary uptodate/uptodate C r-----

?

[Email protected]/]# df-h

Filesystem Size used Avail use% mounted on

/DEV/SDA1 29G 3.3G 24G 13%/

Tmpfs 1.7G 30M 1.7G 2%/DEV/SHM

/DEV/SDB1 50G 180M 47G 1%/mnt/resource

?

[[Email protected]/]# service mysqld status

Mysqld is stopped

?

On the MYSQL-HA2:

[[email protected] ~]# CRM status

Last Updated:sun Dec 6 03:36:30 2015

Last Change:sun Dec 6 02:57:11 2015

Stack:classic Openais (with plugin)

Current dc:mysql-ha2-partition with Quorum

Version:1.1.11-97629de

2 Nodes configured, 2 expected votes

5 Resources configured

?

?

Online: [Mysql-ha1 MYSQL-HA2]

?

Master/slave SET:MYDRBD [MYSQLDRBD]

Masters: [MYSQL-HA2]

Slaves: [MYSQL-HA1]

Mystore???? (Ocf::heartbeat:filesystem):???? Started MYSQL-HA2

MDFILB???? (LSB:MDFILB):???? Started MYSQL-HA2

MYSQLD???? (LSB:MYSQLD):???? Started MYSQL-HA2

?

[Email protected] ~]# Drbd-overview

0:mysql/0 Connected primary/secondary uptodate/uptodate C r-----/mydata ext4 20G 193M 19G 2%

?

[Email protected] ~]# df-h

Filesystem Size used Avail use% mounted on

/DEV/SDA1 29G 3.2G 24G 12%/

Tmpfs 1.7G 45M 1.7G 3%/DEV/SHM

/DEV/SDB1 50G 180M 47G 1%/mnt/resource

/dev/drbd0 20G 193M 19G 2%/mydata

?

[[Email protected] ~]# service mysqld status

MYSQLD (PID 2367) is running ...

?

[Email protected] ~]# cd/mydata/

[[email protected] mydata]# ls

Hengwei ibdata1 ib_logfile0 ib_logfile1 lost+found mysql test

?

?

At this time, the front end through the MySQL client access to the 10.1.1.200 3306 port, the two machines at random shut down the situation, can quickly restore the connection, maintain business continuity!

MySQL on Azure High Availability Design Drbd-corosync-pacemaker-crm (ii)

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.