mysql5.6 and master-Slave environment Configuration installation method in centos5.6 system

Source: Internet
Author: User
Tags curl flush mixed mkdir ssh install perl

mysql5.6 Master-Slave environment configuration installation

Server configuration:

10.1.1.231 master server

10.1.1.234 Slave Server

The server system is: centos5.6

Package:

mysql-client-5.6.13-1.linux_glibc2.5.x86_64.rpm

mysql-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm

mysql-server-5.6.13-1.linux_glibc2.5.x86_64.rpm

mysql-shared-5.6.13-1.linux_glibc2.5.x86_64.rpm

mysql-shared-compat-5.6.13-1.linux_glibc2.5.x86_64.rpm

mysql-test-5.6.13-1.linux_glibc2.5.x86_64.rpm

First, install MySQL

  code is as follows copy code


Yum-y Install Libaio libaio-devel perl-time-hires Curl curl-devel zlib-devel openssl-devel perl cpio expat-devel P Erl-extutils-makemaker perl-dbd-mysql

Rpm-ivh mysql-test-5.6.13-1.linux_glibc2.5.x86_64.rpm
Rpm-ivh mysql-shared-5.6.13-1.linux_glibc2.5.x86_64.rpm 
Rpm-ivh mysql-shared-compat-5.6.13-1.linux_ glibc2.5.x86_64.rpm
Rpm-ivh mysql-server-5.6.13-1.linux_glibc2.5.x86_64.rpm
Rpm-ivh mysql-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm
Rpm-ivh mysql-client-5.6.13-1.linux_glibc2.5.x86_64.rpm

Second, modify master and slave configuration (some of the parameters to be adjusted according to the actual situation):

Main Library/ETC/MY.CNF configuration:

The code is as follows Copy Code
[Client]
Port = 3306
Socket =/state/partition1/mysql/mysql.sock
Default-character-set=utf8
[Mysqld]
server-id=1025
Log-bin=mysql-master-bin
Binlog_format = Mixed
Expire_logs_days=15
max_connections=1000
Innodb_flush_log_at_trx_commit=1
Sync_binlog=1
Binlog-do-db=denovo_ng
Binlog-ignore-db=mysql,test,information_schema
Innodb_buffer_pool_size = 46673M
Skip-name-resolve
DataDir =/state/partition1/mysql/data
Port = 3306
Socket =/state/partition1/mysql/mysql.sock
key_buffer_size=16m
max_allowed_packet=16m
Join_buffer_size = 512M
Sort_buffer_size = 256M
Read_rnd_buffer_size = 128M
Innodb_buffer_pool_size = 40960M
Sql_mode=no_engine_substitution,strict_trans_tables

Configure from Library/ETC/MY.CNF:

  code is as follows copy code
[Client]
Port = 3306
Socket =/state/partition1/mysql/mysql.sock
[Mysqld]
server-id=1052
DataDir =/state/partition1/mysql/data
Port = 3306
Socket =/state/partition1/mysql/mysql.sock
User=mysql
Log-bin=mysql-slave-bin
max_binlog_size=1000m
Binlog_format = Mixed
Expire_logs_days=7
Innodb_flush_log_at_trx_commit=1
Sync_binlog=1
Read_only=1
Binlog-do-db=denovo_ng
Binlog-ignore-db=mysql,test,information_schema
Innodb_buffer_pool_size = 36673M
Skip-name-resolve
max_connections=1000
max_user_connections=490
max_connect_errors=2
key_buffer_size=16m
max_allowed_packet=16m
Join_buffer_size = 512M
Sort_buffer_size = 256M
Read_rnd_buffer_size = 128M
Innodb_buffer_pool_size = 40960M
Sql_mode=no_engine_substitution,strict_trans_tables

Third, the principal and subordinate Library account authorization:

Main Library:

The code is as follows Copy Code


Grant replication slave on *.* to ' Jpsync ' @ ' 10.1.1.234 ' identified by ' jppasswd ';
Flush privileges;
Show master status; #查看主库信息
From library:


Stop slave;
Change Master to master_host= ' 10.1.1.231 ', master_port=3306,master_user= ' Jpsync ', master_password= ' jppasswd ', master _log_file= ' mysql-master-bin.000003 ', master_log_pos=408;
Start slave;
show slave statusg;
If it appears:

Slave_io_running:yes

Slave_sql_running:yes

Indicates that MySQL master and slave library is successful.


then we'll see MHA. Implementation of mysql5.6 master-slave switching installation configuration


Based on the master/slave copy here, we introduce the installation and test of MHA software

First, install MHA software:

The code is as follows Copy Code


Yum-y Install Perl-dbd-mysql perl-config-tiny perl-log-dispatch Perl-parallel-forkmanager

wget http://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.52-0.noarch.rpm
wget https://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52-0.noarch.rpm
wget https://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz
RPM Package Installation:

RPM-IVH mha4mysql-manager-0.52-0.noarch.rpm
RPM-IVH mha4mysql-node-0.52-0.noarch.rpm
Source Package installation (I use the source package installation, Manager installed on the slave)


Tar zxvf mha4mysql-manager-0.52.tar.gz
CD mha4mysql-manager-0.52
Perl makefile.pl
Make
Make install

Second, configure the basic environment:

1, configuration master and slave can ssh without password login (here slightly)

2, to ensure that MHA Manager can log on the master server MySQL

Execute on 10.1.1.231:

The code is as follows Copy Code


Grant all privileges in *.* to ' root ' @ ' 10.1.1.234 ' identified by ' rootpasswd ';
Flush privileges;
Execute on 10.1.1.234:

Grant all privileges in *.* to ' root ' @ ' 10.1.1.231 ' identified by ' rootpasswd ';
Flush privileges;

Iii. Modify the Manager profile for MHA:

The code is as follows Copy Code

[Root@localhost mha4mysql-manager-0.52] #mkdir/etc/masterha
[Root@localhost mha4mysql-manager-0.52] #mkdir-P/MASTERHA/APP1
[Root@localhost mha4mysql-manager-0.52] #cp samples/conf/*/etc/masterha/
[Root@localhost mha4mysql-manager-0.52] #cat/etc/masterha/app1.cnf
[Root@localhost mha4mysql-manager-0.52] #mkdir/etc/masterha
[Root@localhost mha4mysql-manager-0.52] #mkdir-P/MASTERHA/APP1
[Root@localhost mha4mysql-manager-0.52] #cp samples/conf/*/etc/masterha/
[Root@localhost mha4mysql-manager-0.52] #cat/etc/masterha/app1.cnf

[Server default]
manager_workdir=/masterha/app1/
Manager_log=/masterha/app1/manager.log
User=root
Password=d3n0v0
Ssh_user=root
Repl_user=jpsync
Repl_password=jpsyncpass2014la
Ping_interval=1
Shutdown_script= ""
#master_ip_failover_script = "/usr/local/bin/master_ip_failover"
Master_ip_online_change_script= ""
Report_script= ""

[Server1]
hostname=10.1.1.231
port=63306
Master_binlog_dir= "/state/partition1/mysql/data"
Candidate_master=1

[Server2]
hostname=10.1.1.234
port=63306
Master_binlog_dir= "/state/partition1/mysql/data"
Candidate_master=1

Four, the detection configuration:

Check SSH:

The code is as follows Copy Code

[Root@localhost masterha]# masterha_check_ssh--conf=/etc/masterha/app1.cnf
Fri SEP 15:23:25 2014-[info] Reading default Configuratoins from/etc/masterha_default.cnf.
Fri SEP 15:23:25 2014-[INFO] Reading application default configurations from/etc/masterha/app1.cnf.
Fri SEP 15:23:25 2014-[INFO] Reading server configurations from/etc/masterha/app1.cnf.
Fri SEP 15:23:25 2014-[INFO] Starting SSH connection tests.
Fri SEP 15:23:32 2014-[debug]
Fri SEP 15:23:25 2014-[debug] connecting via SSH from root@10.1.1.231 (10.1.1.231) to root@10.1.1.234 (10.1.1.234).
warning:untrusted X11 Forwarding Setup failed:xauth key data not generated
Warning:no Xauth data; Using fake authentication data for X11 forwarding.
Fri SEP 15:23:32 2014-[debug] OK.
Fri SEP 15:23:38 2014-[debug]
Fri SEP 15:23:26 2014-[debug] connecting via SSH from root@10.1.1.234 (10.1.1.234) to root@10.1.1.231 (10.1.1.231).
warning:untrusted X11 Forwarding Setup failed:xauth key data not generated
Warning:no Xauth data; Using fake authentication data for X11 forwarding.
warning:untrusted X11 Forwarding Setup failed:xauth key data not generated
Warning:no Xauth data; Using fake authentication data for X11 forwarding.
Fri SEP 15:23:38 2014-[debug] OK.
Fri SEP 15:23:38 2014-[INFO] All SSH connection tests passed.

Check MHA startup status:

The code is as follows Copy Code
[Root@localhost masterha]# Masterha_check_status--conf=/etc/masterha/app1.cnf
App1 (pid:11444) is running (0:PING_OK), master:10.1.1.231

Check Master-slave replication status:

The code is as follows Copy Code


[Root@compute-0-52 masterha]# Masterha_check_repl--conf=/etc/masterha/app1.cnf
Fri SEP 16:15:12 2014-[info] Reading default Configuratoins from/etc/masterha_default.cnf.
Fri SEP 16:15:12 2014-[INFO] Reading application default configurations from/etc/masterha/app1.cnf.
Fri SEP 16:15:12 2014-[INFO] Reading server configurations from/etc/masterha/app1.cnf.
Fri SEP 16:15:12 2014-[info] mha::mastermonitor version 0.52.
Fri SEP 16:15:12 2014-[info] Dead Servers:
Fri SEP 16:15:12 2014-[info] Alive Servers:
Fri SEP 16:15:12 2014-[info] 10.1.1.231 (10.1.1.231:3306)
Fri SEP 16:15:12 2014-[info] 10.1.1.234 (10.1.1.234:3306)
Fri SEP 16:15:12 2014-[info] Alive Slaves:
Fri SEP 16:15:12 2014-[info] 10.1.1.234 (10.1.1.234:3306) version=5.6.13-log (oldest major Version between slaves) Log-bin:enabled
Fri SEP 16:15:12 2014-[info] replicating from 10.1.1.231 (10.1.1.231:3306)
Fri SEP 16:15:12 2014-[INFO] Primary candidate for the new Master (Candidate_master is set)
Fri SEP 16:15:12 2014-[INFO] current Alive master:10.1.1.231 (10.1.1.231:3306)
Fri SEP 16:15:12 2014-[info] Checking slave configurations.
Fri Sep 16:15:12 2014-<div class= "Warning Shortcodestyle" ></div> relay_log_purge=0 is isn't set on slave 1 0.1.1.234 (10.1.1.234:3306).
Fri SEP 16:15:12 2014-[INFO] Checking replication filtering settings.
Fri SEP 16:15:12 2014-[info] binlog_do_db= denovo_ng, binlog_ignore_db= information_schema,mysql,test
Fri SEP 16:15:12 2014-[info] Replication filtering check OK.
Fri SEP 16:15:12 2014-[INFO] Starting SSH connection tests.
Fri SEP 16:15:25 2014-[INFO] All SSH connection tests passed.
Fri SEP 16:15:25 2014-[info] Checking MHA Node version.
Fri SEP 16:15:32 2014-[info] Version check OK.
Fri SEP 16:15:32 2014-[info] Checking SSH publickey authentication and Checking recovery script configurations on the Current master..
Fri SEP 16:15:38 2014-[info] executing command:save_binary_logs--command=test--start_file=mysql-master-bin.00000 4--start_pos=4--binlog_dir=/state/partition1/mysql/data--output_file=/var/tmp/save_binary_logs_test--manager_ version=0.52
Fri SEP 16:15:38 2014-[info] connecting to root@10.1.1.231 (10.1.1.231).
warning:untrusted X11 Forwarding Setup failed:xauth key data not generated
Warning:no Xauth data; Using fake authentication data for X11 forwarding.
Creating/var/tmp if not exists. Ok.
Checking output directory is accessible or not.
Ok.
Binlog found At/state/partition1/mysql/data, up to mysql-master-bin.000004
Fri SEP 16:15:45 2014-[info] Master setting check done.
Fri SEP 16:15:45 2014-[info] Checking SSH publickey authentication and Checking recovery script configurations on all Alive slave servers.
Fri SEP 16:15:45 2014-[info] executing command:apply_diff_relay_logs--command=test--slave_user=root--slave_hos t=10.1.1.234--slave_ip=10.1.1.234--slave_port=63306--workdir=/var/tmp--target_version=5.6.13-log--manager_ version=0.52--relay_log_info=/state/partition1/mysql/data/relay-log.info--slave_pass=xxx
Fri SEP 16:15:45 2014-[info] connecting to root@10.1.1.234 (10.1.1.234).
warning:untrusted X11 Forwarding Setup failed:xauth key data not generated
Warning:no Xauth data; Using fake authentication data for X11 forwarding.
Checking Slave recovery Environment settings.
Opening/state/partition1/mysql/data/relay-log.info ... ok.
Relay Log found At/state/partition1/mysql/data, up to compute-0-52-relay-bin.000007
Temporary relay log file is/state/partition1/mysql/data/compute-0-52-relay-bin.000007
Testing MySQL connection and privileges. Warning:using a password on the command line interface can is insecure.
Mysql:unknown OS Character set ' iso-8859-15 '.
Mysql:switching to the default character set ' Latin1 '.
Done.
Testing Mysqlbinlog output. Done.
Cleaning up test file (s). Done.
Fri SEP 16:15:51 2014-[INFO] slaves settings check done.
Fri SEP 16:15:51 2014-[INFO]
10.1.1.231 (Current master)
+--10.1.1.234

Fri SEP 16:15:51 2014-[INFO] Checking replication Health on 10.1.1.234.
Fri SEP 16:15:51 2014-[info] OK.
Fri Sep 16:15:51 2014-<div class= "Warning Shortcodestyle" ></div> master_ip_failover_script is not defined .
Fri Sep 16:15:51 2014-<div class= "Warning Shortcodestyle" ></div> shutdown_script is not defined.
Fri SEP 16:15:51 2014-[INFO] Got exit code 0 (not master dead).

MySQL Replication Health is OK.

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.