MySQL + MHA + Keepalive + VIP installation Configuration
I. Overview:
This article describes the implementation scheme of MySQL high availability (MHA). MHA is composed of Node and Manager. Node runs on each MySQL server, whether it is a MySQL master server or a MySQL slave server, install Node. Keepalived is installed on the master and slave nodes to achieve virtual ip address drift. The program does not need to change the IP address to automatically switch.
II. 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: 192.168.1.201master: 192.168.1.231slave1: 192.168.1.232 (Backup master)
6. General steps:
(1) install MYSQL 5.6. (2) Configure master-replica for MYSQL. (3) First, use ssh-keygen to achieve mutual key-free login between the four hosts. (4) install MHAmha4mysql-node, mha4mysql-manager Software Package (5), configure master, slave1 files in MHA. (6) configure the MHA file (7) and masterha_check_ssh tools on the manager to verify that the ssh trusted logon is successful (8) and masterha_check_repl tools verify that mysql replication is successful (9) start MHA manager and monitor log files. (10) test whether automatic failover is performed after the master node is down. (11) install keepalived on the master and slave nodes to implement virtual ip address drift.
Iii. Install mysql
1. Download MYSQL 5.5
wget http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-5.6.17-1.el6.x86_64.rpm-bundle.tar
tar -cf MySQL-5.6.17-1.el6.x86_64.rpm-bundle.tar
2. After decompression, the files are:
MySQL-client-5.6.17-1.el6.x86_64.rpmMySQL-devel-5.6.17-1.el6.x86_64.rpmMySQL-embedded-5.6.17-1.el6.x86_64.rpmMySQL-server-5.6.17-1.el6.x86_64.rpmMySQL-shared-5.6.17-1.el6.x86_64.rpmMySQL-shared-compat-5.6.17-1.el6.x86_64.rpmMySQL-test-5.6.17-1.el6.x86_64.rpm
Note: in fact, as long as the installation, the 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 (can solve some compatibility)
3. Installation
rpm -ivh MySQL-client-5.6.17-1.el6.x86_64.rpmrpm -ivh MySQL-server-5.6.17-1.el6.x86_64.rpmrpm -ivh MySQL-shared-compat-5.6.17-1.el6.x86_64.rpm
4. Possible errors:
(1) existing databases
[root@localhost 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_64file /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_64file /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_64file /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
(The system has a mysql-libs-5.1.71-1.el6.x86_64 must unload it. Solution:
yum -y remove mysql-libs-5.1.71*
(2) The dependent components are missing
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
Solution:
yum install perlyum install libaio
Re-install. The installation is successful. By default, the root user has no password and the port is 3306.
5. There is no MYSQL my. cnf file in/etc/because it is installed by RPM. Solution:
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
In this way, you can modify some MYSQL configuration files.
6. start, stop, and restart mysql.
Service mysql start or/etc/init. d/mysql startservice mysql stop or/etc/init. d/mysql stopservice mysql restart or/etc/init. d/mysql restart
7. Create an account for master-slave replication.
Create user 'username' @ 'host' identified by 'Password'; username-the username you will CREATE, host-specifies the host on which the USER can log on, if a local user can use localhost, if you want the user to log on from any remote host, you can use the wildcard %. password-the user's login password. The password can be blank. If it is blank, the user can log on to the server without the password. 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 'sunene' @ '%' identified by "sunney"; flush privileges // The modification takes effect.
9. You can access the database remotely.
Follow the steps above to install MYSQL on both hosts: 231 and 232.
4. Create mysql master-slave Database Configuration
[Master: 231] 1. shell> vi/etc/my. cnfserver-id = 1log-bin = mysql-binbinlog_format = mixed2.mysql> show master status; [slave1] 3. change master to operate mysql> change master tomaster_host = '2017. 168.1.231 ', master_port = 3306, master_user = 'sunnin', master_password = 'sunnin', master_log_file = 'mysql-bin.000001', master_log_pos = 112; [master, slave1] 4. command to check whether the master-slave replication is successful: mysql> start slave; mysql> stop slave; mysql> reset slave; mysql> show slave status \ G; 5. set the replication permission account mysql> grant all privileges on * on all hosts *. * TO 'sunnin' @ '%' identified by 'sunnin ';
Note:
(1), master_log_file = 'mysql-bin.000001 ', master_log_pos = 112;
The two names are found through the show master status in maste.
(2) The master and slave server-id cannot be the same; otherwise, the synchronization fails.
You can modify the server-id of slave by modifying/etc/my. cnf or
Mysql> set global server_id = 2; # The value here is the same as that set in my. cnf.
V. Summary
The database is successfully installed and the master and slave configurations are successful. You can synchronize the master and slave nodes! The Common Errors of master-slave synchronization are actually network, permission, iptables, SELinux, etc. We usually check these problems and it should not be very difficult to solve them, remember to disable iptables (or activate the corresponding port) and SELinux. Note that the Slave_IO_Running and Slave_ SQL _Running statuses must ensure that the master is Yes, in addition, note that the Seconds_Behind_Master value of the slave machine and the server-id of the master/slave machine cannot be the same!
For more details, please continue to read the highlights on the next page:
HAProxy + Keepalived dual-host high availability solution in Linux
Haproxy + Keepalived build Weblogic high-availability server Load balancer Cluster
Keepalived + HAProxy configure high-availability Load Balancing
Haproxy + Keepalived + Apache configuration notes in CentOS 6.3
Haproxy + KeepAlived WEB Cluster on CentOS 6
Haproxy + Keepalived build high-availability Load Balancing
[Content navigation] |
Page 1st: MySQL installation Configuration |
Page 1: MHA Configuration |
Page 7: install and configure Keepalived |
|