MYSQL + MHA +keepalive + VIP installation configuration (i)--mysql installation configuration

Source: Internet
Author: User
Tags install node install perl


First, general overview:


This paper introduces the implementation of MySQL high availability MHA,MHA is made up of node and manager, node runs on each MySQL server, whether it is MySQL master server or MySQL slave server, install node. Master-Slave installation keepalived, to achieve virtual IP drift, the program does not have to change the IP automatic switch.


Second, the environment


1. Operating system: CentOS 6.5 64-bit


2. Database: Mysql-5.6.17-1.el6.x86_64.rpm-bundle.tar Download


3, MHA version: mha4mysql-node-0.54-0.el6.noarch.rpm,


mha4mysql-manager-0.54-0.el6.noarch.rpm


4. Keepalived version:


5. Host Deployment:


Manager Machine: 192.168.1.201

Master machine: 192.168.1.231

Slave1 machine: 192.168.1.232 (Standby Master)

6. Approximate steps:



(1), install MySQL 5.6.

(2), MySQL configuration master repeating system.

(3), first use Ssh-keygen to achieve the mutual key between four host-free login.

(4), install Mhamha4mysql-node,mha4mysql-manager package

(5), in the MHA configuration master,slave1 related files.

(6). Configure the MHA file on the management manager

(7), masterha_check_ssh tools Verify that SSH trust login is successful

(8), MASTERHA_CHECK_REPL Tools Verify that MySQL replication is successful

(9), Start MHA Manager, and monitor the log files.

(10), test master down, whether it will automatically switch.

(11), the master-slave installation keepalived, to achieve virtual IP drift.


Third, MySQL installation


1. Download MySQL 5.5


Wget Http://cdn.mysql.com/Downloads/M ... 6_64.rpm-bundle.tar

TAR-CF Mysql-5.6.17-1.el6.x86_64.rpm-bundle.tar

2. The files after decompression are:



mysql-client-5.6.17-1.el6.x86_64.rpm

mysql-devel-5.6.17-1.el6.x86_64.rpm

mysql-embedded-5.6.17-1.el6.x86_64.rpm

mysql-server-5.6.17-1.el6.x86_64.rpm

mysql-shared-5.6.17-1.el6.x86_64.rpm

mysql-shared-compat-5.6.17-1.el6.x86_64.rpm

mysql-test-5.6.17-1.el6.x86_64.rpm


Note: In fact, as long as the installation, server-side mysql-server-5.6.17-1.el6.x86_64.rpm client mysql-client-5.6.17-1.el6.x86_64.rpm and mysql-shared-compat-5.6.17-1.el6.x86_64.rpm (some compatibility can be resolved)


3. Installation


RPM-IVH mysql-client-5.6.17-1.el6.x86_64.rpm

RPM-IVH mysql-server-5.6.17-1.el6.x86_64.rpm

RPM-IVH mysql-shared-compat-5.6.17-1.el6.x86_64.rpm

4. Errors that may be reported:


(1) Existence of existing databases



[Email protected] local]# RPM-IVH mysql-server-5.6.17-1.el6.x86_64.rpm

Preparing ... ########################################### [100%]

File/usr/share/mysql/charsets/index.xml from install of mysql-server-5.6.17-1.el6.x86_64 conflicts with file from Package mysql-libs-5.1.71-1.el6.x86_64

File/usr/share/mysql/charsets/armscii8.xml from install of mysql-server-5.6.17-1.el6.x86_64 conflicts with file from Package mysql-libs-5.1.71-1.el6.x86_64

File/usr/share/mysql/charsets/ascii.xml from install of mysql-server-5.6.17-1.el6.x86_64 conflicts with file from Package mysql-libs-5.1.71-1.el6.x86_64

File/usr/share/mysql/charsets/cp1250.xml from install of mysql-server-5.6.17-1.el6.x86_64 conflicts with file from Package mysql-libs-5.1.71-1.el6.x86_64


Description: The system already exists mysql-libs-5.1.71-1.el6.x86_64 it must be unloaded. Workaround:


Yum-y Remove mysql-libs-5.1.71*

(2), missing a dependent component


error:failed dependencies:

/usr/bin/perl is needed by mysql-server-5.6.17-1.el6.x86_64

Libaio.so.1 () (64bit) is needed by mysql-server-5.6.17-1.el6.x86_64

Libaio.so.1 (libaio_0.1) (64bit) is needed by mysql-server-5.6.17-1.el6.x86_64

Libaio.so.1 (libaio_0.4) (64bit) is needed by mysql-server-5.6.17-1.el6.x86_64


Workaround:


Yum Install Perl

Yum Install Libaio

Re-install and install successfully. The default root has no password and the port is: 3306.


5, due to the RPM installation, there is no MySQL my.cnf file under/etc/. Workaround:


Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf

This allows you to modify some of the MySQL configuration files.


6, MySQL start, stop, restart.


Service MySQL start or/etc/init.d/mysql start

Service MySQL stop or/etc/init.d/mysql stop

Service MySQL restart or/etc/init.d/mysql restart

7, create the user, for the master-slave copy of the account


CREATE USER ' username ' @ ' host ' identified by ' password ';

Username-the user name that you will create,

Host-Specifies the host on which the user can log on, and if localhost is available to the local user, you can use the wildcard% if you want the user to be able to log on from any remote host.

Password-The user's login password, the password can be empty, if it is empty, the user can not require a password to log on to the server.

For example:

CREATE USER ' sunney ' @ '% ' identified by ' Sunney ';

8. User authorization


Grant privileges on Databasename.tablename to ' username ' @ ' host ' identified by ' password ';

For example:

Grant all privileges on * * to ' sunney ' @ '% ' identified by "Sunney";

FLUSH privileges//modification takes effect

9, the database can be accessed remotely.


As the previous step two hosts: 231, 232, follow the previous steps to install MySQL.


Iv. build MySQL master and slave database configuration



[master:231]

1.shell>vi/etc/my.cnf

Server-id=1

Log-bin=mysql-bin

Binlog_format=mixed

2.mysql>show Master status;


[Slave1]

3.change Master Operation

Mysql>change Master to

Master_host= ' 192.168.1.231 ',

master_port=3306,

Master_user= ' Sunney ',

Master_password= ' Sunney ',

Master_log_file= ' mysql-bin.000001 ',

master_log_pos=112;


[Master,slave1]

4. Some commands to see if master-slave replication is successful

Mysql>start slave;

Mysql>stop slave;

Mysql>reset slave;

Mysql>show slave status\g;

5. Set replication rights account on all hosts

Mysql>grant all Privileges on*.*to ' Sunney ' @ ' percent ' identified by ' Sunney ';


Attention:


(1), master_log_file= ' mysql-bin.000001 ', master_log_pos=112;


These two names are used in Maste: Show Master status;


(2), Master and slave Server-id is not the same, otherwise it cannot be synchronized successfully.


Slave's Server-id can be modified by/etc/my.cnf or


mysql> set global server_id=2; #此处的数值和my. CNF, just as you set it.


V. Summary


Database installation and master and slave configuration is successful, master and slave synchronization can be done! Master-Slave synchronization of common errors, in fact, is nothing more than network, authority, Iptables, SELinux and other issues, we usually pay attention to check these problems, processing should not be very difficult, we remember to close the iptables (or open the corresponding port) and SELinux, pay attention to Slave_ The io_running and slave_sql_running states must ensure that the main yes is not the same, but also note that the slave's seconds_behind_master value and the Server-id of the Master machine cannot be the same


MYSQL + MHA +keepalive + VIP installation configuration (i)--mysql installation configuration

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.