Corosync achieves high availability of MariaDB Database Service

Source: Internet
Author: User
Tags time 0
Corosync enables High Availability of MariaDB database services. corosync + pacemaker provides HA solutions. Use the shared file system exported by the NFS Shared Server

Corosync enables High Availability of MariaDB database services. corosync + pacemaker provides HA solutions. Use the shared file system exported by the NFS Shared Server

Solution:

Corosync + pacemaker provides HA solutions.

Use the shared file system exported by the NFS Shared Server as the data directory;

The topology is as follows:

Install LAMP (Apache with MariaDB and PHP) in CentOS/RHEL/Scientific Linux 6)

Implementation of MariaDB Proxy read/write splitting

MySQL + Corosync + Pacemaker + DRBD build highly available MySQL

Build a high-availability MySQL Cluster Based on Corosync + DRBD

Use Corosync to configure high-availability clusters based on the NFS service and DRBD service.

Corosync for Linux high availability (HA) CLUSTERS

Set up a high-availability cluster using pacemaker + Corosync

Corosync + pacemaker + RA for high MySQL availability

1. Configure the host name communication between nodes in the HA high-availability cluster.

1. Set the Host Name

(1) set on host 192.168.60.128

Edit the/etc/sysconfig/network file to make the host name permanently valid.

[Root @ www ~] # Vim/etc/sysconfig/networkHOSTNAME = node2.linuxidc.com

Use the hostname command to set the host name to take effect immediately.

[Root @ www ~] # Hostname node2.linuxidc.com

(2) set on host 192.168.60.22

Edit the/etc/sysconfig/network file to make the host name permanently valid.

[Root @ stu13 ~] # Vim/etc/sysconfig/networkHOSTNAME = node1.linuxidc.com

Use the hostname command to set the host name so that it can be generated instantly

[Root @ stu13 ~] # Hostname node1.linuxidc.com

2. To facilitate the setting of key-based communication between nodes. That is, building a trusted host.

[Root @ node1 ~] # Ssh-keygen-t rsa [root @ node1 ~] # Ssh-copy-id-I/root/. ssh/id_rsa.pub 192.168.60.128 [root @ node2 ~] # Ssh-keygen-t rsa [root @ node2 ~] # Ssh-copy-id-I/root/. ssh/id_rsa.pub 192.168.60.22

3. The host name communication between nodes must be able to parse the host name. You can use either of the following methods to resolve a Host Name:

(1) Use the DNS address to resolve the server;

(2) Use the local hosts file for parsing

In terms of efficiency and security, the hosts file is used to parse the host name.

[Root @ node1 ~] # Vim/etc/hosts192.168.60.22 node1.linuxidc.com node11942560.128 node2.linuxidc.com node2

Copy the/etc/hosts file to node2.

[Root @ node1 ~] # Scp/etc/hosts node2:/etc/hosts 100% 78 0.1KB/s

4. Test whether two nodes can implement key-based communication and host name-based communication.

Root @ node2 ~] # Ssh node1 'hostname' node1 .linuxidc.com [root @ node1 ~] # Ssh node2 'hostname' node2 .linuxidc.com [root @ node1 ~] # Ssh node2 'Ping-c 1 node2.linuxidc.com 'ping node2.linuxidc.com (192.168.60.128) 56 (84) bytes of data.64 bytes from node2.linuxidc.com (192.168.60.128 ): icmp_seq = 1 ttl = 64 time = 0.061 ms --- node2.linuxidc.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0 msrtt min/avg/max/mdev = 0.061/0.061/0.061/0.000 MS [root @ node1 ~] # Ping-c 1 node1.linuxidc. comPING compute (192.168.60.22) 56 (84) bytes of data.64 bytes from node1.linuxidc.com (192.168.60.22): icmp_seq = 1 ttl = 64 time = 0.069 ms --- node1.linuxidc.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0 msrtt min/avg/max/mdev = 0.069/0.069/0.069/0.000 MS

Note:

From the above, we can see that the two nodes have been able to implement host name-based communication.

Ii. Configure the NFS server

Build an NFS Network File System server in Ubuntu

Heartbeat_ldirector + LB + NFS for HA, LB, and file sharing

How to Configure NFS server in CentOS 5.5

Install and use NFS in Ubuntu 12.10

1. Provides File Systems shared by NFS servers

Use the LVM logical volume as the data directory of the database and back up data using the snapshot function of the logical volume.

(1) create a partition

[Root @ nsf ~] # Fdisk-l/dev/sda | grep "/dev/sda3"/dev/sda3 7859 9164 10489446 8e Linux LVM

(2) Make the partition pv

[Root @ nsf ~] # Pvcreate/dev/sda3 Physical volume "/dev/sda3" successfully created

(3) create a logical volume group myvg and the PE size is 8E.

[Root @ nsf ~] # Vgcreate-s 8 M myvg/dev/sda3 Volume group "myvg" successfully created

(4) Create an lvm. The size is 2 GB.

[Root @ nsf ~] # Lvcreate-L 2G-n using dir myvg Logical volume "using dir" created [root @ nsf ~] # Mke2fs-t ext4/dev/myvg/export dir [root @ nsf ~] # Echo $? 0

(5) create a mount point

[Root @ nsf ~] # Mkdir/mydata

(6) edit the/etc/fstab file to automatically mount "/dev/myvg/1_dir" at startup"

[Root @ nsf ~] # Vim/etc/fstab/dev/mapper/myvg-export DIR/mydata ext4 defaults, acl 0 0

(7) Mounting

[Root @ nsf ~] # Mount-

Check whether mounting is enabled.

[Root @ nsf ~] # Mount | grep "mydata"/dev/mapper/myvg-export dir on/mydata type ext4 (rw, acl)

2. The database service process (mysql) in the client that configures to mount the file system shared by the NFS server has read and write permissions on the Shared File System (directory.

Use the file system exported from the NFS server as the data directory of the database. According to the working principle of the NFS server, the NFS client can export the File System (directory) to the NFS server) data Writing must meet two conditions:

(A) whether to grant the NFS client write (w) Permission during access control at the NFS server level;

(B) indicates whether the UID of the owner of the process that initiates the write (W) operation on the NFS client is the same as that of the host on the NFS server.

Corresponding user.

1) If yes, check whether the user has the write permission for the file system (directory) exported by the NFS server. If

If you have the write permission, the NFS client process can initiate a write operation to the file system exported by the NFS server. Otherwise

The NFS client has no permission to write data to the file system exported to the NFS server.

2) if not, check whether the nobody user has the write permission for the file system (directory) exported by the NFS server.

However, in Linux, the nobody user has the minimum permission.

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.