MHA实现mysql5.6主从切换安装配置教程
2019/10/10/17:32:48 阅读:2038 来源:谷歌SEO算法 标签:
手机网站制作
下面给各位介绍一下MHA实现mysql5.6主从切换安装配置教程,希望此教程能帮助到大家.
基于这里的master/slave复制,我们这里介绍下MHA软件的安装与测试.
一、安装MHA软件:
- yum-yinstallperl-DBD-MySQLperl-Config-Tinyperl-Log-Dispatchperl-Parallel-ForkManager
- wgethttp://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.52-0.noarch.rpm
- wgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52-0.noarch.rpm
- wgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz
rpm包安装:
- rpm-ivhmha4mysql-manager-0.52-0.noarch.rpm
- rpm-ivhmha4mysql-node-0.52-0.noarch.rpm
源码包安装(我这里采用源码包安装,manager安装在slave上):
- tarzxvfmha4mysql-manager-0.52.tar.gz
- cdmha4mysql-manager-0.52
- perlMakefile.PL
- make
- makeinstall
二、配置基本环境:
1、配置master和slave之间可以ssh无密码登陆(这里略)
2、保证mha manager能登陆主从服务器的mysql
- --10.1.1.231上执行:
- grantallprivilegeson*.*to'root'@'10.1.1.234'identifiedby'rootpasswd';
- flushprivileges;
- --10.1.1.234上执行:
- grantallprivilegeson*.*to'root'@'10.1.1.231'identifiedby'rootpasswd';
- flushprivileges;
三、修改mha的manager配置文件:
- [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha
- [root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
- [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/
- [root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
- [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha
- [root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
- [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/
- [root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
- [serverdefault]
- 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
- --phpfensi.com
- [server2]
- hostname=10.1.1.234
- port=63306
- master_binlog_dir="/state/partition1/mysql/data"
- candidate_master=1
四、检测配置:检查ssh:
- [root@localhostmasterha]#masterha_check_ssh--conf=/etc/masterha/app1.cnf
- FriSep1215:23:252014-[info]Readingdefaultconfiguratoinsfrom/etc/masterha_default.cnf..
- FriSep1215:23:252014-[info]Readingapplicationdefaultconfigurationsfrom/etc/masterha/app1.cnf..
- FriSep1215:23:252014-[info]Readingserverconfigurationsfrom/etc/masterha/app1.cnf..
- FriSep1215:23:252014-[info]StartingSSHconnectiontests..
- FriSep1215:23:322014-[debug]
- FriSep1215:23:252014-[debug]ConnectingviaSSHfromroot@10.1.1.231(10.1.1.231)toroot@10.1.1.234(10.1.1.234)..
- Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
- Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
- FriSep1215:23:322014-[debug]ok.
- FriSep1215:23:382014-[debug]
- FriSep1215:23:262014-[debug]ConnectingviaSSHfromroot@10.1.1.234(10.1.1.234)toroot@10.1.1.231(10.1.1.231)..
- Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
- Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
- Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
- Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
- FriSep1215:23:382014-[debug]ok.
- FriSep1215:23:382014-[info]AllSSHconnectiontestspassedsuccessfully.
检查mha启动状态:
- [root@localhostmasterha]#masterha_check_status--conf=/etc/masterha/app1.cnf
- app1(pid:11444)isrunning(0:PING_OK),master:10.1.1.231
检查主从复制状态:
- [root@compute-0-52masterha]#masterha_check_repl--conf=/etc/masterha/app1.cnf
- FriSep1216:15:122014-[info]Readingdefaultconfiguratoinsfrom/etc/masterha_default.cnf..
- FriSep1216:15:122014-[info]Readingapplicationdefaultconfigurationsfrom/etc/masterha/app1.cnf..
- FriSep1216:15:122014-[info]Readingserverconfigurationsfrom/etc/masterha/app1.cnf..
- FriSep1216:15:122014-[info]MHA::MasterMonitorversion0.52.
- FriSep1216:15:122014-[info]DeadServers:
- FriSep1216:15:122014-[info]AliveServers:
- FriSep1216:15:122014-[info]10.1.1.231(10.1.1.231:3306)
- FriSep1216:15:122014-[info]10.1.1.234(10.1.1.234:3306)
- FriSep1216:15:122014-[info]AliveSlaves:
- FriSep1216:15:122014-[info]10.1.1.234(10.1.1.234:3306)Version=5.6.13-log(oldestmajorversionbetweenslaves)log-bin:enabled
- FriSep1216:15:122014-[info]Replicatingfrom10.1.1.231(10.1.1.231:3306)
- FriSep1216:15:122014-[info]PrimarycandidateforthenewMaster(candidate_masterisset)
- FriSep1216:15:122014-[info]CurrentAliveMaster:10.1.1.231(10.1.1.231:3306)
- FriSep1216:15:122014-[info]Checkingslaveconfigurations..
- FriSep1216:15:122014-<divclass="warningshortcodestyle"></div>relay_log_purge=0isnotsetonslave10.1.1.234(10.1.1.234:3306).
- FriSep1216:15:122014-[info]Checkingreplicationfilteringsettings..
- FriSep1216:15:122014-[info]binlog_do_db=denovo_ng,binlog_ignore_db=information_schema,mysql,test
- FriSep1216:15:122014-[info]Replicationfilteringcheckok.
- FriSep1216:15:122014-[info]StartingSSHconnectiontests..
- FriSep1216:15:252014-[info]AllSSHconnectiontestspassedsuccessfully.
- FriSep1216:15:252014-[info]CheckingMHANodeversion..
- FriSep1216:15:322014-[info]Versioncheckok.
- FriSep1216:15:322014-[info]CheckingSSHpublickeyauthenticationandcheckingrecoveryscriptconfigurationsonthecurrentmaster..
- FriSep1216:15:382014-[info]Executingcommand:save_binary_logs--command=test--start_file=mysql-master-bin.000004--start_pos=4--binlog_dir=/state/partition1/mysql/data--output_file=/var/tmp/save_binary_logs_test--manager_version=0.52
- FriSep1216:15:382014-[info]Connectingtoroot@10.1.1.231(10.1.1.231)..
- Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
- Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
- Creating/var/tmpifnotexists..ok.
- Checkingoutputdirectoryisaccessibleornot..
- ok.
- Binlogfoundat/state/partition1/mysql/data,uptomysql-master-bin.000004
- FriSep1216:15:452014-[info]Mastersettingcheckdone.
- FriSep1216:15:452014-[info]CheckingSSHpublickeyauthenticationandcheckingrecoveryscriptconfigurationsonallaliveslaveservers..
- FriSep1216:15:452014-[info]Executingcommand:apply_diff_relay_logs--command=test--slave_user=root--slave_host=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
- FriSep1216:15:452014-[info]Connectingtoroot@10.1.1.234(10.1.1.234)..
- Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
- Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
- Checkingslaverecoveryenvironmentsettings..
- Opening/state/partition1/mysql/data/relay-log.info...ok.
- Relaylogfoundat/state/partition1/mysql/data,uptocompute-0-52-relay-bin.000007
- Temporaryrelaylogfileis/state/partition1/mysql/data/compute-0-52-relay-bin.000007
- Testingmysqlconnectionandprivileges..Warning:Usingapasswordonthecommandlineinterfacecanbeinsecure.
- mysql:UnknownOScharacterset'ISO-8859-15'.
- mysql:Switchingtothedefaultcharacterset'latin1'.
- done.
- Testingmysqlbinlogoutput..done.
- Cleaninguptestfile(s)..done.
- FriSep1216:15:512014-[info]Slavessettingscheckdone.
- FriSep1216:15:512014-[info]
- 10.1.1.231(currentmaster)
- +--10.1.1.234
- FriSep1216:15:512014-[info]Checkingreplicationhealthon10.1.1.234..
- FriSep1216:15:512014-[info]ok.
- FriSep1216:15:512014-<divclass="warningshortcodestyle"></div>master_ip_failover_scriptisnotdefined.
- FriSep1216:15:512014-<divclass="warningshortcodestyle"></div>shutdown_scriptisnotdefined.
- FriSep1216:15:512014-[info]Gotexitcode0(Notmasterdead).
- MySQLReplicationHealthisOK
热门评论