HeartBeat high availability for MySQL using NFS based on CRM

Source: Internet
Author: User

The experiment environment here is still used in the previous section.
Stop the node resource and delete it.

NFS shared storage node configuration:
# Mkdir/mydata
# Vim/etc/exports
/Mydata 192.168.100.0/24 (no_root_squash, rw)
# Service nfs restart
# Groupadd-g 3306 mysql
# Useradd-g 3306-u 3306-s/sbin/nologin-M mysql
# Chown-R/mydata
Note: The nfs shared resources must be set to no_root_squash. Otherwise, the mysql service cannot be started.

 

Node Configuration:
The configuration of node1 and node2 is the same here.

# Groupadd-g 3306 mysql
# Useradd-g 3306-u 3306-s/sbin/nologin-M mysql
# Mkdir/mydata
# Tar xvf mysql-5.5.22-linux2.6-i686.tar.gz-C/usr/local/
# Cd/usr/local/
# Ln-s mysql-5.5.22-linux2.6-i686/mysql
# Cd mysql
# Chown-R root: mysql.
# Mount-t nfs 192.168.100.9:/mydata
# Cd/usr/local/mysql/
# Scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data
# Ln-s/usr/local/mysql/bin/*/usr/bin/
# Cp support-files/my-large.cnf/etc/my. cnf
# Vim/etc/my. cnf
Datadir =/mydata/data
Innodb_file_per_table = 1
# Cp support-files/mysql. server/etc/init. d/mysqld
# Chkconfig -- add mysqld
# Chkconfig mysqld off
# Service mysqld start
# Scp/ect/my. cnf node2:/etc
# Scp/etc/init. d/mysqld node2:/etc/init. d
# Service mysqld start
# Mysql

Test whether mysql is normal
Mysql> create database mydb;
Mysql> grant all privileges on *. * to root @ '%' identified by 'asdasd ';
Mysql> flush privileges;
# Service mysqld stop
# Service heartbeat start
# Ssh node2 'service heartbeat start'
# Hb_gui
Note:
1. The above command must be connected and configured on the DC. Otherwise, the startup will fail. Check which node is DC. We can use the command crm_mon
2. After the test is complete, you must set the mysql of each node to be turned off and uninstall nfs shared storage.
To add a group and a resource, follow these steps:

Now, we can log on to our mysql high-availability cluster from any mysql client.


Test logging on to the mysql cluster on the nfs server to see if everything is normal:
[Root @ fs ~] # Mysql-uroot-h 192.168.100.10-p
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mydb |
| Mysql |
| Performance_schema |
| Test |
+ -------------------- +
5 rows in set (0.01 sec)

Mysql> use mydb;
Database changed
Mysql> create table test1 (
-> Id int not null auto_increment primary key,
-> Name varchar (20) not null
-> );
Query OK, 0 rows affected (0.11 sec)

Recommended reading:

Heartbeat for Linux high availability (HA) Cluster Based on crm

Heartbeat + httpd + NFS for highly available Web Servers

Heartbeat for Linux high availability (HA) CLUSTERS

Heartbeat CRM configuration for Linux high availability solution

High-availability cluster Heartbeat v1 instance

LVS + heartbeat + ldirectord high-availability server Load balancer cluster Solution

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.