当前位置:首页 > MySQL > MySQL基础

MHA实现mysql5.6主从切换安装配置教程

来源:www.zhiqinet.com|时间:2014-10-17 14:45:48

下面给各位介绍一下MHA实现mysql5.6主从切换安装配置教程,希望此教程能帮助到大家.

基于这里的master/slave复制,我们这里介绍下MHA软件的安装与测试.

一、安装MHA软件:

  1. yum-yinstallperl-DBD-MySQLperl-Config-Tinyperl-Log-Dispatchperl-Parallel-ForkManager
  2. wgethttp://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.52-0.noarch.rpmwgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52-0.noarch.rpm
  3. wgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz

rpm包安装:

  1. rpm-ivhmha4mysql-manager-0.52-0.noarch.rpmrpm-ivhmha4mysql-node-0.52-0.noarch.rpm

源码包安装(我这里采用源码包安装,manager安装在slave上):

  1. tarzxvfmha4mysql-manager-0.52.tar.gzcdmha4mysql-manager-0.52
  2. perlMakefile.PLmake
  3. makeinstall

二、配置基本环境:

1、配置master和slave之间可以ssh无密码登陆(这里略)

2、保证mha manager能登陆主从服务器的mysql

  1. --10.1.1.231上执行:
  2. grantallprivilegeson*.*to'root'@'10.1.1.234'identifiedby'rootpasswd';flushprivileges;
  3. --10.1.1.234上执行:
  4. grantallprivilegeson*.*to'root'@'10.1.1.231'identifiedby'rootpasswd';
  5. flushprivileges;

三、修改mha的manager配置文件:

  1. [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha[root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
  2. [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/[root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
  3. [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha[root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
  4. [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/[root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
  5. [serverdefault]
  6. manager_workdir=/masterha/app1/manager_log=/masterha/app1/manager.log
  7. user=rootpassword=d3n0v0
  8. ssh_user=rootrepl_user=jpsync
  9. repl_password=jpsyncpass2014laping_interval=1
  10. shutdown_script=""#master_ip_failover_script="/usr/local/bin/master_ip_failover"
  11. master_ip_online_change_script=""report_script=""
  12. [server1]
  13. hostname=10.1.1.231port=63306
  14. master_binlog_dir="/state/partition1/mysql/data"candidate_master=1
  15. --phpfensi.com[server2]
  16. hostname=10.1.1.234port=63306
  17. master_binlog_dir="/state/partition1/mysql/data"candidate_master=1

四、检测配置:检查ssh:

  1. [root@localhostmasterha]#masterha_check_ssh--conf=/etc/masterha/app1.cnfFriSep1215:23:252014-[info]Readingdefaultconfiguratoinsfrom/etc/masterha_default.cnf..
  2. FriSep1215:23:252014-[info]Readingapplicationdefaultconfigurationsfrom/etc/masterha/app1.cnf..FriSep1215:23:252014-[info]Readingserverconfigurationsfrom/etc/masterha/app1.cnf..
  3. FriSep1215:23:252014-[info]StartingSSHconnectiontests..FriSep1215:23:322014-[debug]
  4. 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
  5. Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.FriSep1215:23:322014-[debug]ok.
  6. 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)..
  7. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgeneratedWarning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  8. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgeneratedWarning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  9. FriSep1215:23:382014-[debug]ok.FriSep1215:23:382014-[info]AllSSHconnectiontestspassedsuccessfully.

检查mha启动状态:

  1. [root@localhostmasterha]#masterha_check_status--conf=/etc/masterha/app1.cnfapp1(pid:11444)isrunning(0:PING_OK),master:10.1.1.231

检查主从复制状态:

  1. [root@compute-0-52masterha]#masterha_check_repl--conf=/etc/masterha/app1.cnfFriSep1216:15:122014-[info]Readingdefaultconfiguratoinsfrom/etc/masterha_default.cnf..
  2. FriSep1216:15:122014-[info]Readingapplicationdefaultconfigurationsfrom/etc/masterha/app1.cnf..FriSep1216:15:122014-[info]Readingserverconfigurationsfrom/etc/masterha/app1.cnf..
  3. FriSep1216:15:122014-[info]MHA::MasterMonitorversion0.52.FriSep1216:15:122014-[info]DeadServers:
  4. FriSep1216:15:122014-[info]AliveServers:FriSep1216:15:122014-[info]10.1.1.231(10.1.1.231:3306)
  5. FriSep1216:15:122014-[info]10.1.1.234(10.1.1.234:3306)FriSep1216:15:122014-[info]AliveSlaves:
  6. FriSep1216:15:122014-[info]10.1.1.234(10.1.1.234:3306)Version=5.6.13-log(oldestmajorversionbetweenslaves)log-bin:enabledFriSep1216:15:122014-[info]Replicatingfrom10.1.1.231(10.1.1.231:3306)
  7. FriSep1216:15:122014-[info]PrimarycandidateforthenewMaster(candidate_masterisset)FriSep1216:15:122014-[info]CurrentAliveMaster:10.1.1.231(10.1.1.231:3306)
  8. FriSep1216:15:122014-[info]Checkingslaveconfigurations..FriSep1216:15:122014-<divclass="warningshortcodestyle"></div>relay_log_purge=0isnotsetonslave10.1.1.234(10.1.1.234:3306).
  9. FriSep1216:15:122014-[info]Checkingreplicationfilteringsettings..FriSep1216:15:122014-[info]binlog_do_db=denovo_ng,binlog_ignore_db=information_schema,mysql,test
  10. FriSep1216:15:122014-[info]Replicationfilteringcheckok.FriSep1216:15:122014-[info]StartingSSHconnectiontests..
  11. FriSep1216:15:252014-[info]AllSSHconnectiontestspassedsuccessfully.FriSep1216:15:252014-[info]CheckingMHANodeversion..
  12. FriSep1216:15:322014-[info]Versioncheckok.FriSep1216:15:322014-[info]CheckingSSHpublickeyauthenticationandcheckingrecoveryscriptconfigurationsonthecurrentmaster..
  13. 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.52FriSep1216:15:382014-[info]Connectingtoroot@10.1.1.231(10.1.1.231)..
  14. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgeneratedWarning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  15. Creating/var/tmpifnotexists..ok.Checkingoutputdirectoryisaccessibleornot..
  16. ok.Binlogfoundat/state/partition1/mysql/data,uptomysql-master-bin.000004
  17. FriSep1216:15:452014-[info]Mastersettingcheckdone.FriSep1216:15:452014-[info]CheckingSSHpublickeyauthenticationandcheckingrecoveryscriptconfigurationsonallaliveslaveservers..
  18. 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=xxxFriSep1216:15:452014-[info]Connectingtoroot@10.1.1.234(10.1.1.234)..
  19. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgeneratedWarning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  20. Checkingslaverecoveryenvironmentsettings..Opening/state/partition1/mysql/data/relay-log.info...ok.
  21. Relaylogfoundat/state/partition1/mysql/data,uptocompute-0-52-relay-bin.000007Temporaryrelaylogfileis/state/partition1/mysql/data/compute-0-52-relay-bin.000007
  22. Testingmysqlconnectionandprivileges..Warning:Usingapasswordonthecommandlineinterfacecanbeinsecure.mysql:UnknownOScharacterset'ISO-8859-15'.
  23. mysql:Switchingtothedefaultcharacterset'latin1'.done.
  24. Testingmysqlbinlogoutput..done.Cleaninguptestfile(s)..done.
  25. FriSep1216:15:512014-[info]Slavessettingscheckdone.FriSep1216:15:512014-[info]
  26. 10.1.1.231(currentmaster)+--10.1.1.234
  27. FriSep1216:15:512014-[info]Checkingreplicationhealthon10.1.1.234..
  28. FriSep1216:15:512014-[info]ok.FriSep1216:15:512014-<divclass="warningshortcodestyle"></div>master_ip_failover_scriptisnotdefined.
  29. FriSep1216:15:512014-<divclass="warningshortcodestyle"></div>shutdown_scriptisnotdefined.FriSep1216:15:512014-[info]Gotexitcode0(Notmasterdead).
  30. MySQLReplicationHealthisOK

栏目最新

相关文章

关于我们 - 广告合作 - 联系我们 - 免责声明 - 网站地图 - 投诉建议 - 在线投稿

严禁网站镜像,否则追究法律责任 CopyRight © 2014 智启教程 zhiqinet.com , All Rights Reserved.