Installation process http://xiong51.blog.51cto.com/5239058/1826190
Vim/etc/hosts
192.168.0.30 MYSQL1
192.168.0.31 MYSQL2
Please note that MySQL installation must use the same disk, to avoid the next login inconsistent,
Heartbeat do not enable service on standby will cause the master to break the file out of sync, workaround: You can use NFS, DRBD, iSCSI
NFS Settings
/nfsfile 192.168.0.30/24 (rw,sync,no_root_squash) do not use root compression, avoid permissions errors
When MySQL is used , please give < mount files filname> mysql user group permissions
Showmount-a NFS server address mount on line
Both need to be mounted and then installed
or/etc/fstab 192.168.0.30:/nfsfile/filenameNFS_netdev0 0
installation please see MySQL
Use filename directly when initializing, keep binary logs in the best different disks within different partitions, avoid errors
Master configuration can also not
Heartbeat can use the master-slave configuration, the master-slave configuration does not require NFS, or can not be configured, but the two MySQL initial files must be together and can be guaranteed.
Note: The directory defined in MY.CF must first give chown Mysql.mysql * permissions mysql2 the same
MYSQL1
Vim/etc/my.cnf
Basedir =/usr/local/mysql Local installation directory
DataDir =/mysql/data data file should be/filenmae mount file
Port = 3306 Ports
Socket =/var/lib/mysql/mysql.sock Sock Directory
Auto_increment_offset = 1 start step
Auto_increment_increment = 2 progressive Step
Log_bin =/mysql/master/masterbin Open binary Log
Relay_log =/mysql/relay/mastrelay_log turn on the trunk log
Binlog_format = mixed binary log for promiscuous mode
server_id = 111 Service ID number should remain inconsistent with the other
Grant all on * * to [e-mail protected] ' 192.168.0.31 ' identified by ' ekccetih '; give MYSQL2 authorization
View Peer-to-peer MYSQ2 binary log files show Mstart status\g;
Change Master to master_host= ' 192.168.0.31 ', master_user= ' Massam ', master_password= ' ekccetih ', master_log_file= ' Masterbin.000001 ', master_log_pos=850;
Reset Master Recovery binary log is initial, do not use this option after a successful configuration
Reset slave restores the trunk log as the initial,
In the case of Slave failed to initialize relay log info structure from the repository
This error is used when you save the relay log to a different format such as Mysql=1_log Mysql2=2_log cannot be the same
Grant all on * * to [e-mail protected] ' 192.168.0.% ' identified by ' mysqltete '; give heartbeat VIP authorization
Mysql2
Vim/etc/my.cnf
Vim/etc/my.cnf
Basedir =/usr/local/mysql Local installation directory
DataDir =/mysql/data data file should be/filenmae mount file
Port = 3306 Ports
Socket =/var/lib/mysql/mysql.sock Sock Directory
Auto_increment_offset = 2 start step
Auto_increment_increment = 2 progressive Step
Log_bin =/mysql/master/master_bin Open binary Log
The log name must be different or it will be an error
Relay_log =/mysql/relay/relay_log turn on the trunk log
Binlog_format = mixed binary log for promiscuous mode
server_id = 111 Service ID number should remain inconsistent with the other
Grant all on * * to [e-mail protected] ' 192.168.0.30 ' identified by ' ekccetih '; Give MYSQL1 authorization
View Peer-to-peer MySQL binary log files show Mstart status\g;
Master_host= ' 192.168.0.31 ', master_user= ' Massam ', master_password= ' ekccetih ', master_log_file= ' masterbin.000001 ', master_log_pos=120;
Reset Master Recovery binary log is initial, do not use this option after a successful configuration
Heartbeat segment
Host MYSQL1 under
Yum-y Install heartbeat*
Cp/usr/share/doc/heartbeat-3.0.4/authkeys,ha.cf,haresources/etc/ha.d/Directory
Vim/etc/ha.d/ha.cf
LogFile/var/log/ha-log Log
KeepAlive 2 connection time
Deadtime time of death
Warntime Warning Time
Initdead time after death
Udpport694 UDP port number
Ucast eth0 192.168.0.30 unicast address MYSQL2 address
Auto_failback off after the death on the line whether to re-seize back
Node MYSQL1 Master node uname-n must be the same as the host name of the nodes
Node MYSQL2 Standby nodes
Ping 192.168.0.1 quorum node?
Respawn hacluster/usr/lib64/heartbeat/ipfailPing doesn't try to pull back the address again
Vim/etc/ha.d/authkeys
Auth 2
2 SHA1 xiong.com
Vim/etc/ha.d/haresources
MYSQL1 ipaddr2::192.168.0.99/24/eth0:0mysqld
Name script: VIP Address: Mask: interface Service OCF
MYSQL2 with MYSQL1 same configuration except
Ucast eth0 192.168.0.31 unicast address MYSQL1 address
Ifconfig Configuring VIP Addresses
eth0:0 Link encap:ethernet HWaddr 00:0c:29:36:26:ee
inet addr:192.168.0.99 bcast:192.168.0.255 mask:255.255.255.0
NETSTAT-ANPT | grep 3306
TCP 0 0::: 3306:::* LISTEN 28222/mysqld
The above can only be the main node enabled, both have a description of the brain cracked, need to see/var/log/ha-log wrong
Then on the standby server authentication, success, must be granted to the login user authorization, using Windows can also test success
[Email protected] ha.d]# mysql-umysqlte-p-h192.168.0.99
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 14
Server Version:5.6.30-log Source Distribution
Copyright (c) and/or, Oracle, its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql>
This article is from the "Xiong" blog, make sure to keep this source http://xiong51.blog.51cto.com/5239058/1828045
MySQL Heartbeat high Availability