Implementation of HA high availability cluster based on NFS shared MySQL

Source: Internet
Author: User
Tags uuid


192.168.139.8 as Nfs-server, 192.168.139.2 and 192.168.13.4 are used to install MySQL

___________________________________________________________________________________________ the following operations on 192.168.139.8


[[email protected] ~]# fdisk-l//First to prepare a disk for the partition, to do the LV, then the LV format and then mount and//share with NFS, let the other nodes as a MySQL data storage directory

Device Boot Start End Blocks Id System

/DEV/SDB1 1 1060258+ Linux

/DEV/SDB2 133 394 2104515-Up Linux

/DEV/SDB3 395 787 3156772+-up Linux

[[email protected] ~]# PVCREATE/DEV/SDB1/DEV/SDB2//Create a PV

Physical volume "/DEV/SDB1" successfully created

Physical volume "/DEV/SDB2" successfully created

[[email protected] ~]# vgcreate MYVG/DEV/SDB1/DEV/SDB2//Create a VG named MYVG

Volume Group "MYVG" successfully created

[[email protected] ~]# Vgdisplay//View VG

---Volume Group---

VG Name MYVG

System ID

Format lvm2

Metadata Areas 2

Metadata Sequence No 1

VG Access Read/write

VG Status resizable

MAX LV 0

Cur LV 0

Open LV 0

Max PV 0

Cur PV 2

ACT PV 2

VG Size 3.01 GiB

PE Size 4.00 MiB

Total PE 771

Alloc pe/size 0/0

Free Pe/size 771/3.01 GiB

VG UUID V4jclc-viq1-31rq-vdhb-ir1u-vf0y-zmhkkx

[[email protected] ~]# lvcreate-l 3g-n mylv MYVG//Create a MYVG on MYLV with a size of 3G

Logical volume "Mylv" created.

[[email protected] ~]# Lvdisplay//view LV

---Logical volume---

LV PATH/DEV/MYVG/MYLV

LV Name Mylv

VG Name MYVG

LV UUID 6fkufw-r7ni-iawz-zcgu-tuby-f5uf-fqnm8w

LV Write Access Read/write

LV Creation Host, Time www.zxl.com, 2016-11-10 05:39:52 +0800

LV Status Available

# Open 0

LV Size 3.00 GiB

Current LE 768

Segments 2

Allocation inherit

Read ahead Sectors Auto

-Currently set to 256

Block Device 253:2

[Email protected] ~]# mke2fs-j/DEV/MYVG/MYLV//formatted as EXT3

[[email protected] ~]# groupadd-g 3306 mysql//create MySQL Group

[[email protected] ~]# useradd-u 3306-g mysql-s/sbin/nologin-m mysql//create MySQL user, group//m Ysql, unable to log on to the system, and no specified login directory

[Email protected] ~]# Mkdir/mydata

[[email protected] ~]# vim/etc/fstab//Let boot automatically mount

/dev/myvg/mylv/mydata ext3 defaults 0 0

[[email protected] ~]# mount-a//re-mount Mount in/etc/fstab

[[email protected] ~]# mount//already mounted

/dev/mapper/myvg-mylv on/mydata type ext3 (rw)

[Email protected] ~]# Mkdir/mydata/data

[[email protected] ~]# chown-r mysql.mysql/mydata/data//Change data directory belongs to group and owner is MySQL

[[email protected] ~]# vim/etc/exports//Do NFS sharing

/mydata 192.168.139.0/24 (NO_ROOT_SQUASH,RW)//If there is no No_root_squash, the MySQL system is initialized with the//root identity, and Root accesses NFS be mapped to Guest account, no permissions

[[Email protected] ~] #service rpcbind start//Initiate RPC

[[Email protected] ~] #service NFS Start//Start NFS

[[Email protected] ~] #showmount-e 192.168.139.2//See if NFS is shared

___________________________________________________________________________________________

192.168.139.2


[[email protected] mnt]# groupadd-g 3306 MySQL

[Email protected] mnt]# useradd-u3306-g 3306-s/sbin/nologin-m MySQL

[Email protected] mnt]# Mkdir/mydata

[email protected]/]# Mount 192.168.139.8:/mydata/mydata

[Email protected]/]# cd/mydata/

[email protected] mydata]# LL

Total 20

Drwxr-xr-x. 2 Nobody nobody 4096 Nov data

DRWX------. 2 Nobody nobody 16384 Nov Lost+found

[[email protected] mydata]# usermod-s/bin/bash mysql//test MySQL user can write in the data directory

[Email protected] mydata]# Su-mysql

Su:warning:cannot Change directory to/home/mysql:no such file or directory//as Created MySQL user specified-M

-bash-4.1$ cd/mydata/data/

-bash-4.1$ Touch A

-bash-4.1$ LL

Total 0

-rw-rw-r--. 1 Nobody nobody 0 Nov A//description can be written

-bash-4.1$ RM A

-bash-4.1$ exit

[[email protected] mydata]# usermod-s/sbin/nologin MySQL

[Email protected]/]# umount/mydata/


__________________________________________________________________________________________


Repeat above steps on 192.18.139.4


___________________________________________________________________________________________


192.168.139.2 installing MySQL


Http://mirrors.sohu.com/mysql/MySQL-5.5/mysql

[Email protected] tool]# TAR-XF mysql-5.5.53.tar.gz-c/usr/local

[Email protected] tool]# cd/usr/local/

[email protected] local]# LL

Drwxr-xr-x. 7161 31415 4096 Sep 23:05 mysql-5.5.53

[[email protected] local]# ln-sv mysql-5.5.53 MySQL

' MySQL ', ' mysql-5.5.53 '

[[Email protected] local]# CD MySQL

[Email protected] mysql]# chown-r root:mysql./*

[email protected] mysql]# LL

Total 248

Drwxr-xr-x. 2 root mysql 4096 Sep 23:05 BUILD

-rw-r--r--. 1 root mysql 8528 Sep 23:01 build-cmake

......

[email protected] mysql]# Mount 192.168.139.8:/mydata/mydata/

[Email protected] mysql]# script/mysql_install_db--user=mysql--datadir=/mydata/data

MySQL initialization, specifies to run as MySQL, the data directory is/mydata/data, where the/mydata directory is mounted 192.168.139.8_nfs shared/mydata directory.

___________________________________________________________________________________________


Initialization error occurred. Find out on the Internet very do not know why (^_^)

[Email protected] mysql]# scripts/mysql_install_db--user=mysql--datadir=/mydata/data

-bash:scripts/mysql_install_db:no such file or directory//Discovery scripts directory without//mysql_ INSTALL_DB has/mysql_install_db.sh.

[Email protected] mysql]# scripts/mysql_install_db.sh--user=mysql--datadir=/mydata/data

-bash:scripts/mysql_install_db.sh:permission denied//no permissions

[Email protected] scripts]# chown-r mysql:mysql mysql_install_db.sh

[email protected] scripts]# LL

-rw-r--r--. 1 mysql mysql 14806 Sep 23:01 mysql_install_db.sh

[Email protected] scripts]# scripts/mysql_install_db.sh--user=mysql--datadir=/mydata/data

-bash:scripts/mysql_install_db.sh:no such file or directory//or cannot initialize, is there a problem with the package?

[[email protected] opt]# Find/-name mysql_install_db//Still not found

[Email protected] opt]# cd/usr/local/

[Email protected] local]# RM-RF mysql-5.5.53/


___________________________________________________________________________________________


Re-install a package


[[email protected] mysql]# rpm-qa |grep mysql//Uninstall the system originally installed

Mysql-libs-5.1.73-5.el6_6.x86_64

[[email protected] mysql]# rpm-e--nodeps mysql-libs-5.1.73-5.el6_6.x86_64//uninstall already installed, want to suddenly Slightly dependent relationships

[[email protected] local]# Unzip Mysql-5.5.53.zip//Unzip

[[email protected] local]# RM-RF mysql-5.5.53.zip//Delete original package

[Email protected] local]# LN-SV mysql-5.5.53/mysql

' MySQL ', ' mysql-5.5.53/'

[[Email protected] tool]# CD MySQL

[Email protected] mysql]# scripts/mysql_install_db--user=mysql--datadir=/mydata/data System initialization MySQL

[[email protected] mysql]# cp/usr/local/support-files/my-large.cnf/etc/my.cnf//Copy the MySQL configuration file

[Email protected] mysql]# VIM/ETC/MY.CNF

Datadir=/mydata/data//Join Data storage Directory

innodb_file_per_table=1//Open MySQL table space per table

[[email protected] mysql]# CP support-files/mysql.server.sh/etc/init.d/mysql//copy MySQL startup script

[[email protected] mysql]# chkconfig--add mysql//add MySQL to system service

[[email protected] mysql]# chkconfig mysqld off//cluster resource does not boot from boot

[[Email protected] mysql]# service mysqld start

[[Email protected] mysql]# service mysqld stop

[Email protected] mysql]# umount/mydata/


___________________________________________________________________________________________


Re-installing MySQL on 192.168.139.4


___________________________________________________________________________________________


192.168.139.2


[[Email protected] mysql]service heartbeat start

[[email protected] mysql]ssh 192.168.139.4 service Heartbeat start

[[email protected] MySQL] Hb_gui//In the graphical interface will Mysql,vip (192.168.139.10), filesystem configured as a capital//source group, and let the VIP start first, in the boot filesystem, and finally start MySQL

[Email protected] Mysql]crm_mon

You can see that 192.168.139.4 is selected for DC

[[email protected] mysql]mysql-uroot-p-h192.168.139.10//Connect VIP, can connect up

Let the 192.168.139.4 break down

[[email protected] mysql]mysql-uroot-p-h192.168.139.10//can still connect up

The main point is that the MySQL data storage directory is the Nfs-server shared directory, so that on the two hosts installed MySQL will be a common data storage directory, so that the data consistency, so that MySQL is highly available, but Nfs-server is still a single node, Easy to become a cluster failure point










This article is from the "11097124" blog, please be sure to keep this source http://11107124.blog.51cto.com/11097124/1871489

Implementation of HA high availability cluster based on NFS shared MySQL

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.