北京SEO

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

2019/10/10/17:32:48  阅读:2038  来源:谷歌SEO算法  标签: 手机网站制作

下面给各位介绍一下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.rpm
  3. wgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52-0.noarch.rpm
  4. wgethttps://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz

rpm包安装:

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

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

  1. tarzxvfmha4mysql-manager-0.52.tar.gz
  2. cdmha4mysql-manager-0.52
  3. perlMakefile.PL
  4. make
  5. makeinstall

二、配置基本环境:

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

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

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

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

  1. [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha
  2. [root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
  3. [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/
  4. [root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
  5. [root@localhostmha4mysql-manager-0.52]#mkdir/etc/masterha
  6. [root@localhostmha4mysql-manager-0.52]#mkdir-p/masterha/app1
  7. [root@localhostmha4mysql-manager-0.52]#cpsamples/conf/*/etc/masterha/
  8. [root@localhostmha4mysql-manager-0.52]#cat/etc/masterha/app1.cnf
  9. [serverdefault]
  10. manager_workdir=/masterha/app1/
  11. manager_log=/masterha/app1/manager.log
  12. user=root
  13. password=d3n0v0
  14. ssh_user=root
  15. repl_user=jpsync
  16. repl_password=jpsyncpass2014la
  17. ping_interval=1
  18. shutdown_script=""
  19. #master_ip_failover_script="/usr/local/bin/master_ip_failover"
  20. master_ip_online_change_script=""
  21. report_script=""
  22. [server1]
  23. hostname=10.1.1.231
  24. port=63306
  25. master_binlog_dir="/state/partition1/mysql/data"
  26. candidate_master=1
  27. --phpfensi.com
  28. [server2]
  29. hostname=10.1.1.234
  30. port=63306
  31. master_binlog_dir="/state/partition1/mysql/data"
  32. candidate_master=1

四、检测配置:检查ssh:

  1. [root@localhostmasterha]#masterha_check_ssh--conf=/etc/masterha/app1.cnf
  2. FriSep1215:23:252014-[info]Readingdefaultconfiguratoinsfrom/etc/masterha_default.cnf..
  3. FriSep1215:23:252014-[info]Readingapplicationdefaultconfigurationsfrom/etc/masterha/app1.cnf..
  4. FriSep1215:23:252014-[info]Readingserverconfigurationsfrom/etc/masterha/app1.cnf..
  5. FriSep1215:23:252014-[info]StartingSSHconnectiontests..
  6. FriSep1215:23:322014-[debug]
  7. FriSep1215:23:252014-[debug]ConnectingviaSSHfromroot@10.1.1.231(10.1.1.231)toroot@10.1.1.234(10.1.1.234)..
  8. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
  9. Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  10. FriSep1215:23:322014-[debug]ok.
  11. FriSep1215:23:382014-[debug]
  12. FriSep1215:23:262014-[debug]ConnectingviaSSHfromroot@10.1.1.234(10.1.1.234)toroot@10.1.1.231(10.1.1.231)..
  13. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
  14. Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  15. Warning:untrustedX11forwardingsetupfailed:xauthkeydatanotgenerated
  16. Warning:Noxauthdata;usingfakeauthenticationdataforX11forwarding.
  17. FriSep1215:23:382014-[debug]ok.
  18. FriSep1215:23:382014-[info]AllSSHconnectiontestspassedsuccessfully.

检查mha启动状态:

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

检查主从复制状态:

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

广告内容

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

相关阅读

热门评论

木木老贼 木木老贼

互联网营销达人~

总篇数181

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法