1. http://blog.itpub.net/26230597/cid-87082-list-2/
  2.  
  3. 1,简介
  4. .1mha简介
  5. MHA,即MasterHigh Availability Manager and Tools for MySQL,是日本的一位MySQL专家采用Perl语言编写的一个脚本管理工具,该工具仅适用于MySQLReplication(二层)环境,目的在于维持Master主库的高可用性。
  6.  
  7. MHA(Master High Availability)是自动的master故障转移和Slave提升的软件包.它是基于标准的MySQL复制(异步/半同步).
  8. MHA有两部分组成:MHA Manager(管理节点)和MHA Node(数据节点).
  9. MHA Manager可以单独部署在一台独立机器上管理多个master-slave集群,也可以部署在一台slave上.MHA Manager探测集群的node节点,当发现master出现故障的时候,它可以自动将具有最新数据的slave提升为新的master,然后将所有其它的slave导向新的master上.整个故障转移过程对应用程序是透明的。
  10. MHA node运行在每台MySQL服务器上(master/slave/manager),它通过监控具备解析和清理logs功能的脚本来加快故障转移的。
  11.  
  12. 1.2mha特点
  13. (). -30s实现master failover(-12s可以检测到主机故障,-10s可以关闭主机避免SB,在用很短的时间应用差异日志)
  14.  
  15. () 部署简单,无需对现有M-S结构做任何改动(至少3台,保证切换后仍保持M-S结构)
  16.  
  17. (). 支持手动在线切换(主机硬件维护),downtime几乎很短0.-2s
  18.  
  19. (). 保证故障切换后多从库数据的一致性
  20.  
  21. (). 完全自动化的failover及快速复制架构恢复方案(一主多从)
  22.  
  23. (). 恢复过程包括:选择新主库、确认从库间relaylog差异、新主库应用必要语句、其他从库同步差异语句、重新建立复制连接
  24.  
  25. ,工作原理
  26.  
  27. 相较于其它HA软件,MHA的目的在于维持MySQL ReplicationMaster库的高可用性,其最大特点是可以修复多个Slave之间的差异日志,最终使所有Slave保持数据一致,然后从中选择一个充当新的Master,并将其它Slave指向它。
  28. -从宕机崩溃的master保存二进制日志事件(binlogevents)。
  29. -识别含有最新更新的slave
  30. -应用差异的中继日志(relay log)到其它slave
  31. -应用从master保存的二进制日志事件(binlogevents)。
  32. -提升一个slave为新master
  33. -使其它的slave连接新的master进行复制。
  34.  
  35. mha工具包
  36. ()、 Manager工具:
  37. - masterha_check_ssh : 检查MHASSH配置。
  38. - masterha_check_repl : 检查MySQL复制。
  39. - masterha_manager : 启动MHA
  40. - masterha_check_status : 检测当前MHA运行状态。
  41. - masterha_master_monitor : 监测master是否宕机。
  42. - masterha_master_switch : 控制故障转移(自动或手动)。
  43. - masterha_conf_host : 添加或删除配置的server信息。
  44.  
  45. ()、 Node工具(这些工具通常由MHAManager的脚本触发,无需人手操作)。
  46. - save_binary_logs : 保存和复制master的二进制日志。
  47. - apply_diff_relay_logs : 识别差异的中继日志事件并应用于其它slave
  48. - filter_mysqlbinlog : 去除不必要的ROLLBACK事件(MHA已不再使用这个工具)。
  49. - purge_relay_logs : 清除中继日志(不会阻塞SQL线程)。
  50.  
  51. ,主机部署
  52. Ip地址
  53. mha状况
  54. Mysql状况
  55. 192.168.52.129
  56. Node
  57. Master
  58. 192.168.52.130
  59. Node
  60. Slave
  61. 192.168.52.131
  62. Manager
  63. Slave
  64.  
  65. ,生成ssh无密钥证书
  66. 5.1 先在192.168.52.129上面生成密钥
  67. ssh-keygen -t dsa -P '' -f id_dsa
  68. Id_dsa.pub为公钥,id_dsa为私钥,紧接着将公钥文件复制成authorized_keys文件,这个步骤是必须的,过程如下:
  69.  
  70. cat id_dsa.pub >> authorized_keys
  71.  
  72. 5.2 192.168.52.130上面生产密钥
  73. ssh-keygen -t dsa -P '' -f id_dsa
  74. cat id_dsa.pub >> authorized_keys
  75.  
  76. 5.3 192.168.52.131上面生产密钥
  77. ssh-keygen -t dsa -P '' -f id_dsa
  78. cat id_dsa.pub >> authorized_keys
  79.  
  80. 5.4 构造3个通用的authorized_keys
  81. 192.168.52.129上面操作:
  82. cd /root/.ssh #copy130和131上面的密钥过来
  83. scp 192.168.52.130:/root/.ssh/id_dsa.pub./id_dsa.pub.
  84. scp 192.168.52.131:/root/.ssh/id_dsa.pub./id_dsa.pub.
  85. cat id_dsa.pub. >> authorized_keys
  86. cat id_dsa.pub. >> authorized_keys
  87.  
  88. 查看生成的通用密钥
  89. [root@data01 .ssh]# cat authorized_keys
  90. ssh-dssAAAAB3NzaC1kc3MAAACBAKe9oTz+hQ3vAUE+x7s2EIT6RSrlPoD2VHuSsDo+ZmAyv6+DD6/eVhVXrCyqzjQPJa6UI0PYjlPMk2r2wqdvC/YqQaLhFuQmsBQwrVA2xNHwhB3ic+Om44GVoiZFM7+bGAtfhQ9DLK2+sjfaa/oQfuDvTJ2SI/f0oG3wDGmokgdLAAAAFQC/O4R1yX1FxW7+dCKHhV+LQHWWHQAAAIADR5yqZGZCx8VB8Q6kAYg3cuUCCo3gF/hA5bHY+2xO5CcGAD1mq/l5v55QPUlGAH7btdmfip1tiaQ+V3N+Ektf2psM0uap/LKvbV2jQYKc2UZrpfF6R0lG+x9rpkxWMce1TJ4yANGOasjNjUV6Lg0RVDxLiMT4Ja4+edQVduYt2AAAAIBPNfJlyglZ5CwsI+v753tD8WT4GaH8ssNLpIKrH9qJU6OuT9MmniKE1RqZr+e5MCvkUAAXHFPq0DhHQlPKWqhIpVlu0E8Zsn9a5tv728JpIYz1umB5VLo2J5fhpobefD3AhjEHSyaubJgQG4Gu+jdwsR0H21xLNx0VoP8YPbYkAQ==root@data01
  91. ssh-dssAAAAB3NzaC1kc3MAAACBAPtU+mTL9an88U1wfSwxdlHBg9n8eB9l218sXGLHwJyxNJN0pq4iPCLMfRxhM6T30HxUnyhghxBF2XvkAkMEjZ+IuCoA0mwRi1CcYSMh72SXqfRdgE2GpRBZDRRhlCIE5feNswWZdC7fIDmgNHtK5CFmJLcl+9Bkb3kfGqu8JOxbAAAAFQDo2YRMd5ZsfBRvPZcCYWcOsuy2oQAAAIEA4pGH2w7luN9JhJ0V6sDUUySg4R488yloKR/k4yD33qPXTejCiDUKUbanMLs6obQqxpbVvlhRT6cyo/le7PO6H8IzRHjFy65EPL0omn7J06PmHBUMqCn4jXo27EGXlRLavnonUf3tFeaVo7GxXerj71NdBKkQX7e/bgzD4d5v0PMAAACBAIhx1X50hlYzqPEZEDXTJmntLRXsMB20DvngvUcQLlgLozwfaNdJAQuYSGqklXYTquSmsyaTNJsxj8EkKG4XbM/7hHtNbV8KuAMJGT4Dm7jEdiKClyle2tIvVtonYaL41KeZVdn6Lk4lRYIFxpDoQHKXXr+XEFhLjoniT8urPISlroot@data02
  92. ssh-dss AAAAB3NzaC1kc3MAAACBAJtC3j4Gq+zR7adyKFco/1hELblR65Af+Cgi81mfL+sJAFuOqPcFvDANhymBQ9ltH1N2/eDq1CrD0U9tRMxSwBvgiWZW9brkMpl5ix6oJSCBHdyqL6iuREk7CZ3V/y7P2V+TDCc+am5onMWDG1Af9o6CeA7CP92CHaUoltcXd7L7AAAAFQCqpeVqjbEs/lC/J1utfWrpGDxt8QAAAIB1aeB6C3S9t0dU3bEZs06DaooO46foBFMOI7u0w7uEWvj48UQF7W5Y++vjsiARxr6clk2g2T70n0fJmZCtMMiHqD6vyy8OOy8PzdUcQVAUW2GZQ8hn7M1U2GOz2KPo6uUbPiKkXilEfh9YRsyZyxMdmC4raPjPea8sj6favK8RbgAAAIAima6hWfBFsFcE1oh02xk7ydavHGJbHAlxeH9g9glE0FPmzPgWMFkYQnLsyV2z+ouMPFmERUPYzg1k/8Dhoxjp9j4JB6bIcPNtKdlS660NcFLxRtFAhrnzvLOTzXYzeIuZOlE0WcjeQGNpx8JHAef/3WzpHnVmnhbmlkBrZ8X/OQ==root@oraclem1
  93. [root@data01 .ssh]#
  94.  
  95. 看到authorized_keys文件里面有3行记录,分别代表了访问data01192.168.52.129),oraclem1192.168.52.131),data02192.168.52.130)的公用密钥。然后把这个authorized_keys公钥文件copyoraclem1192.168.52.131)和data02192.168.52.130)上面同一个目录下。Scp命令如下:
  96. scp authorized_keys192.168.52.:/root/.ssh/
  97. scp authorized_keys192.168.52.:/root/.ssh/
  98.  
  99. 5.5 开始check验证如下:
  100. [root@oraclem1 ~]# ssh 192.168.52.130
  101. Last login: Tue Apr :: from data01
  102. [root@data02 ~]# ssh 192.168.52.131
  103. Last login: Tue Apr :: from 192.168.52.131
  104. [root@oraclem1 ~]# ssh 192.168.52.130
  105. Last login: Tue Apr :: from 192.168.52.131
  106. [root@data02 ~]# ssh 192.168.52.129
  107. Last login: Tue Apr :: from 192.168.52.131
  108. [root@data01 ~]# ssh 192.168.52.131
  109. Last login: Tue Apr :: from 192.168.52.130
  110. [root@oraclem1 ~]# ssh 192.168.52.129
  111. Last login: Tue Apr :: from data02
  112. [root@data01 ~]# ssh 192.168.52.131
  113. Last login: Tue Apr :: from 192.168.52.129
  114. [root@oraclem1 ~]# ssh 192.168.52.130
  115. Last login: Tue Apr :: from 192.168.52.131
  116. [root@data02 ~]# ssh 192.168.52.129
  117. Last login: Tue Apr :: from 192.168.52.131
  118. [root@data01 ~]
  119. OK3台服务器已经能实现两两互相ssh通了,不需要输入密码即可。
  120. PS:如果不能实现任何两台主机互相之间可以无密码登录,后面的环节可能会有问题。
  121.  
  122. 5.6 实现主机名hostname登录
  123. 3台服务器上,编辑/etc/hosts,追加入以下内容保存退出
  124. 192.168.52.129 data01
  125. 192.168.52.130 data02
  126. 192.168.52.131 oraclem1
  127.  
  128. 验证主机名登录:
  129. [root@data02 ~]# ssh oraclem1
  130. The authenticity of host 'oraclem1(192.168.52.131)' can't be established.
  131. RSA key fingerprint ise5:f0:ae:e3:::2f::1f::dd::c3:1a:e1:.
  132. Are you sure you want to continueconnecting (yes/no)? yes
  133. Warning: Permanently added 'oraclem1' (RSA)to the list of known hosts.
  134. Last login: Tue Apr :: from data01
  135. [root@oraclem1 ~]# ssh data02
  136. Last login: Tue Apr :: from data01
  137. [root@data02 ~]# ssh oraclem1
  138. Last login: Tue Apr :: from data02
  139. [root@oraclem1 ~]# vim /etc/hosts
  140. [root@oraclem1 ~]# ssh data01
  141. Last login: Tue Apr :: from data02
  142. [root@data01 ~]# ssh data02
  143. Last login: Tue Apr :: from oraclem1
  144. [root@data02 ~]# ssh data01
  145. Last login: Tue Apr :: from oraclem1
  146. [root@data01 ~]#
  147. OK,看到可以实现通过主机名来无密码登录了。
  148.  
  149. ,准备好mysql主从环境
  150.  
  151. 具体搭建过程,参考以前的blog:http://blog.csdn.net/mchdba/article/details/44734597
  152. 架构如下,一主二从的架构
  153. Master主库à192.168.52.,slave从库à192.168.52.
  154. Master 主库à192.168.52.,slave从库à192.168.52.
  155.  
  156. 创建用户mha管理的账号,在所有mysql服务器上都需要执行:
  157. GRANT SUPER,RELOAD,REPLICATIONCLIENT,SELECT ON *.* TO manager@'192.168.52.%' IDENTIFIED BY 'manager_1234';
  158. GRANT CREATE,INSERT,UPDATE,DELETE,DROP ON*.* TO manager@'192.168.52.%';
  159.  
  160. 创建主从账号,在所有mysql服务器上都需要执行:
  161. GRANT RELOAD, SUPER, REPLICATION SLAVE ON*.* TO 'repl'@'192.168.52.%' IDENTIFIED BY 'repl_1234';
  162.  
  163. ,开始安装mha
  164. mha包括manager节点和data节点,data节点包括原有的MySQL复制结构中的主机,至少3台,即1主2从,当masterfailover后,还能保证主从结构;只需安装node包。manager server:运行监控脚本,负责monitoring 和 auto-failover;需要安装node包和manager包。
  165.  
  166. 为了节省机器,可以从现有复制架构中选一台“闲置”从库作为manager server,比如:某台从库不对外提供读的服务,只是作为候选主库,或是专门用于备份。
  167. 7.1,在数据节点上安装mha
  168. 首先安装yum -y install perl-DBD-MySQL
  169. tar -zxvpf mha4mysql-node-0.56.tar.gz
  170. perl Makefile.PL
  171. make && make install
  172.  
  173. 7.2 在管理节点上安装mha
  174. 首先安装perl的mysql包:
  175. yum install -y perl-DBD-MySQL
  176. yum install -y perl-Config-Tiny
  177. yum install -y perl-Log-Dispatch
  178. yum install -y perl-Parallel-ForkManager
  179. yum install -y perl-Config-IniFiles
  180. 一些安装失败,可以直接下载rpm包安装:
  181. wgetftp://ftp.muug.mb.ca/mirror/centos/5.10/os/x86_64/CentOS/perl-5.8.8-41.el5.x86_64.rpm
  182. wgetftp://ftp.muug.mb.ca/mirror/centos/6.5/os/x86_64/Packages/compat-db43-4.3.29-15.el6.x86_64.rpm
  183. wgethttp://downloads.naulinux.ru/pub/NauLinux/6x/i386/sites/School/RPMS/perl-Log-Dispatch-2.27-1.el6.noarch.rpm
  184.  
  185. wget http://dl.fedoraproject.org/pub/epel/6/i386/perl-Parallel-ForkManager-0.7.9-1.el6.noarch.rpm
  186.  
  187. wget http://dl.fedoraproject.org/pub/epel/6/i386/perl-Mail-Sender-0.8.16-3.el6.noarch.rpm wget http://dl.fedoraproject.org/pub/epel/6/i386/perl-Mail-Sendmail-0.79-12.el6.noarch.rpm
  188.  
  189. wget http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-Time-HiRes-1.9721-136.el6.x86_64.rpm
  190.  
  191. 下载完后,一个个rpm安装好
  192. 如果最后还是安装不好,可以尝试一下perl CPAN的方式:
  193. perl -MCPAN -e shell
  194. cpan[]> install Log::Dispatch
  195.  
  196. 然后通过perlMakefile.PL检查mha的perl安装环境,如下所示:
  197. [root@oraclem1 mha4mysql-manager-0.56]#perl Makefile.PL
  198. *** Module::AutoInstall version 1.03
  199. *** Checking for Perl dependencies...
  200. [Core Features]
  201. - DBI ...loaded. (1.609)
  202. - DBD::mysql ...loaded. (4.013)
  203. - Time::HiRes ...loaded. (1.9726)
  204. - Config::Tiny ...loaded. (2.12)
  205. - Log::Dispatch ...loaded. (2.44)
  206. - Parallel::ForkManager ...loaded. (0.7.)
  207. - MHA::NodeConst ...loaded. (0.56)
  208. *** Module::AutoInstall configurationfinished.
  209. Generating a Unix-style Makefile
  210. Writing Makefile for mha4mysql::manager
  211. Writing MYMETA.yml and MYMETA.json
  212. [root@oraclem1 mha4mysql-manager-0.56]#
  213.  
  214. 然后解压缩安装:
  215. tar -xvf mha4mysql-manager-0.56.tar.gz
  216. cd mha4mysql-manager-0.56
  217. perl Makefile.PL
  218. make && make install
  219.  
  220. 7.3 编辑管理节点配置
  221.  
  222. 在管理节点192.168.52.129上面
  223.  
  224. [root@data01 mha4mysql-manager-0.56]# vim/etc/masterha/app1.cnf
  225.  
  226. [server default]
  227. manager_workdir=/var/log/masterha/app1
  228. manager_log=/var/log/masterha/app1/manager.log
  229.  
  230. ssh_user=root #ssh免密钥登录的帐号名
  231. repl_user=repl #mysql复制帐号,用来在主从机之间同步二进制日志等
  232. repl_password=repl_1234
  233. ping_interval= #ping间隔,用来检测master是否正常
  234.  
  235. [server1]
  236. hostname=192.168.52.129
  237. candidate_master= #master机宕掉后,优先启用这台作为新master
  238. master_binlog_dir=/home/data/mysql/binlog/
  239.  
  240. [server2]
  241. hostname=192.168.52.130
  242. #candidate_master=
  243. master_binlog_dir=/home/data/mysql/binlog/
  244.  
  245. [server3]
  246. hostname=192.168.52.131
  247. #candidate_master=
  248. master_binlog_dir=/home/data/mysql/binlog/
  249.  
  250. #[server4]
  251. #hostname=host4
  252. #no_master=
  253.  
  254. 7.4 利用mha工具检测ssh
  255. 然后check ssh成功,采用命令:masterha_check_ssh --conf=/etc/masterha/app1.cnf,如下所示:
  256. [root@data01 ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf
  257. Tue Apr :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  258. Tue Apr :: - [info] Reading application default configuration from /etc/masterha/app1.cnf..
  259. Tue Apr :: - [info] Reading server configuration from /etc/masterha/app1.cnf..
  260. Tue Apr :: - [info] Starting SSH connection tests..
  261. Tue Apr :: - [debug]
  262. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.129(192.168.52.129:) to root@192.168.52.130(192.168.52.130:)..
  263. Warning: Permanently added '192.168.52.129' (RSA) to the list of known hosts.
  264. Tue Apr :: - [debug] ok.
  265. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.129(192.168.52.129:) to root@192.168.52.131(192.168.52.131:)..
  266. Tue Apr :: - [debug] ok.
  267. Tue Apr :: - [debug]
  268. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.130(192.168.52.130:) to root@192.168.52.129(192.168.52.129:)..
  269. Tue Apr :: - [debug] ok.
  270. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.130(192.168.52.130:) to root@192.168.52.131(192.168.52.131:)..
  271. Tue Apr :: - [debug] ok.
  272. Tue Apr :: - [debug]
  273. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.131(192.168.52.131:) to root@192.168.52.129(192.168.52.129:)..
  274. Tue Apr :: - [debug] ok.
  275. Tue Apr :: - [debug] Connecting via SSH from root@192.168.52.131(192.168.52.131:) to root@192.168.52.130(192.168.52.130:)..
  276. Tue Apr :: - [debug] ok.
  277. Tue Apr :: - [info] All SSH connection tests passed successfully.
  278. [root@data01 ~]#
  279.  
  280. 7.5 使用mha工具check检查repl环境
  281. 检测命令为:masterha_check_repl--conf=/etc/masterha/app1.cnf,检测结果如下:
  282. [root@oraclem1 ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf
  283. Fri Apr :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  284. Fri Apr :: - [info] Reading application default configuration from /etc/masterha/app1.cnf..
  285. Fri Apr :: - [info] Reading server configuration from /etc/masterha/app1.cnf..
  286. Fri Apr :: - [info] MHA::MasterMonitor version 0.56.
  287. Fri Apr :: - [info] Multi-master configuration is detected. Current primary(writable) master is 192.168.52.129(192.168.52.129:)
  288. Fri Apr :: - [info] Master configurations are as below:
  289. Master 192.168.52.130(192.168.52.130:), replicating from 192.168.52.129(192.168.52.129:), read-only
  290. Master 192.168.52.129(192.168.52.129:), replicating from 192.168.52.130(192.168.52.130:)
  291.  
  292. Fri Apr :: - [info] GTID failover mode =
  293. Fri Apr :: - [info] Dead Servers:
  294. Fri Apr :: - [info] Alive Servers:
  295. Fri Apr :: - [info] 192.168.52.129(192.168.52.129:)
  296. Fri Apr :: - [info] 192.168.52.130(192.168.52.130:)
  297. Fri Apr :: - [info] 192.168.52.131(192.168.52.131:)
  298. Fri Apr :: - [info] Alive Slaves:
  299. Fri Apr :: - [info] 192.168.52.130(192.168.52.130:) Version=5.6.-log (oldest major version between slaves) log-bin:enabled
  300. Fri Apr :: - [info] Replicating from 192.168.52.129(192.168.52.129:)
  301. Fri Apr :: - [info] 192.168.52.131(192.168.52.131:) Version=5.6.-log (oldest major version between slaves) log-bin:enabled
  302. Fri Apr :: - [info] Replicating from 192.168.52.129(192.168.52.129:)
  303. Fri Apr :: - [info] Current Alive Master: 192.168.52.129(192.168.52.129:)
  304. Fri Apr :: - [info] Checking slave configurations..
  305. Fri Apr :: - [info] Checking replication filtering settings..
  306. Fri Apr :: - [info] binlog_do_db= user_db, binlog_ignore_db= information_schema,mysql,performance_schema,test
  307. Fri Apr :: - [info] Replication filtering check ok.
  308. Fri Apr :: - [info] GTID (with auto-pos) is not supported
  309. Fri Apr :: - [info] Starting SSH connection tests..
  310. Fri Apr :: - [info] All SSH connection tests passed successfully.
  311. Fri Apr :: - [info] Checking MHA Node version..
  312. Fri Apr :: - [info] Version check ok.
  313. Fri Apr :: - [info] Checking SSH publickey authentication settings on the current master..
  314. Fri Apr :: - [info] HealthCheck: SSH to 192.168.52.129 is reachable.
  315. Fri Apr :: - [info] Master MHA Node version is 0.56.
  316. Fri Apr :: - [info] Checking recovery script configurations on 192.168.52.129(192.168.52.129:)..
  317. Fri Apr :: - [info] Executing command: save_binary_logs --command=test --start_pos= --binlog_dir=/home/data/mysql/binlog/ --output_file=/var/tmp/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.
  318. Fri Apr :: - [info] Connecting to root@192.168.52.129(192.168.52.129:)..
  319. Creating /var/tmp if not exists.. ok.
  320. Checking output directory is accessible or not..
  321. ok.
  322. Binlog found at /home/data/mysql/binlog/, up to mysql-bin.
  323. Fri Apr :: - [info] Binlog setting check done.
  324. Fri Apr :: - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
  325. Fri Apr :: - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='manager' --slave_host=192.168.52.130 --slave_ip=192.168.52.130 --slave_port= --workdir=/var/tmp --target_version=5.6.-log --manager_version=0.56 --relay_dir=/home/data/mysql/data --current_relay_log=mysqld-relay-bin. --slave_pass=xxx
  326. Fri Apr :: - [info] Connecting to root@192.168.52.130(192.168.52.130:)..
  327. Checking slave recovery environment settings..
  328. Relay log found at /home/data/mysql/data, up to mysqld-relay-bin.
  329. Temporary relay log file is /home/data/mysql/data/mysqld-relay-bin.
  330. Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
  331. done.
  332. Testing mysqlbinlog output.. done.
  333. Cleaning up test file(s).. done.
  334. Fri Apr :: - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='manager' --slave_host=192.168.52.131 --slave_ip=192.168.52.131 --slave_port= --workdir=/var/tmp --target_version=5.6.-log --manager_version=0.56 --relay_log_info=/home/data/mysql/data/relay-log.info --relay_dir=/home/data/mysql/data/ --slave_pass=xxx
  335. Fri Apr :: - [info] Connecting to root@192.168.52.131(192.168.52.131:)..
  336. Checking slave recovery environment settings..
  337. Opening /home/data/mysql/data/relay-log.info ... ok.
  338. Relay log found at /home/data/mysql/data, up to mysql-relay-bin.
  339. Temporary relay log file is /home/data/mysql/data/mysql-relay-bin.
  340. Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
  341. done.
  342. Testing mysqlbinlog output.. done.
  343. Cleaning up test file(s).. done.
  344. Fri Apr :: - [info] Slaves settings check done.
  345. Fri Apr :: - [info]
  346. 192.168.52.129(192.168.52.129:) (current master)
  347. +--192.168.52.130(192.168.52.130:)
  348. +--192.168.52.131(192.168.52.131:)
  349.  
  350. Fri Apr :: - [info] Checking replication health on 192.168.52.130..
  351. Fri Apr :: - [info] ok.
  352. Fri Apr :: - [info] Checking replication health on 192.168.52.131..
  353. Fri Apr :: - [info] ok.
  354. Fri Apr :: - [warning] master_ip_failover_script is not defined.
  355. Fri Apr :: - [warning] shutdown_script is not defined.
  356. Fri Apr :: - [info] Got exit code (Not master dead).
  357.  
  358. MySQL Replication Health is OK.
  359. [root@oraclem1 ~]#
  360.  
  361. ,管理mha操作
  362. 8.1 启动manager
  363. nohup masterha_manager --conf=/etc/masterha/app1.cnf < /dev/null >/logs/mha/app1/manager.log >& &
  364. 执行后台情形,如下所示:
  365.  
  366. [root@oraclem1 mha4mysql-manager-0.56]# nohup masterha_manager --conf=/etc/masterha/app1.cnf /logs/mha/app1/manager.log >& &
  367. []
  368. [root@oraclem1 mha4mysql-manager-0.56]#
  369. [root@oraclem1 mha4mysql-manager-0.56]# tail -f /logs/mha/app1/manager.log
  370. Fri Apr :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  371. Fri Apr :: - [info] Reading application default configuration from /etc/masterha/app1.cnf..
  372. Fri Apr :: - [info] Reading server configuration from /etc/masterha/app1.cnf..
  373.  
  374. 8.2 使用masterha_check_status检测下
  375. [root@oraclem1 ~]# masterha_check_status--conf=/etc/masterha/app1.cnf
  376. app1 (pid:) is running(:PING_OK),master:192.168.52.129
  377. [root@oraclem1 ~]#
  378.  
  379. 手动操作:
  380.  
  381. 8.3 停止manager
  382. 命令:masterha_stop --conf=/etc/masterha/app1.cnf
  383. [root@oraclem1 mha4mysql-manager-0.56]#masterha_stop --conf=/etc/masterha/app1.cnf
  384. Stopped app1 successfully.
  385. []+ Exit nohupmasterha_manager --conf=/etc/masterha/app1.cnf < /dev/null >/logs/mha/app1/manager.log >&
  386. [root@oraclem1 mha4mysql-manager-0.56]#
  387.  
  388. 8.4 master死机自动切换测试
  389. 在mysql的master库52.129上,执行如下命令:echo c> /proc/sysrq-trigger
  390. 后果是:然后会看到master库变成了52.,而52.131从库也被迫去连接新的主库52.130了。
  391.  
  392. Manager自动完成了切换操作。
  393.  
  394. 8.5 master手动切换
  395. 先停止manager:masterha_stop --conf=/etc/masterha/app1.cnf
  396. 在备选slave和master上添加crontab –e任务,
  397.  
  398. 手动切换master,命令如下
  399. masterha_master_switch--conf=/etc/masterha/app1.cnf --master_state=dead--dead_master_host=192.168.52.129
  400. masterha_master_switch--conf=/etc/masterha/app1.cnf --master_state=alive--new_master_host=192.168.52.130
  401.  
  402. 先设置原来的master为dead,如下所示:
  403. [root@oraclem1 ~]# masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=dead --dead_master_host=192.168.52.129
  404. --dead_master_ip= is not set. Using 192.168.52.129.
  405. --dead_master_port= is not set. Using .
  406. Fri Apr :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  407. Fri Apr :: - [info] Reading application default configuration from /etc/masterha/app1.cnf..
  408. Fri Apr :: - [info] Reading server configuration from /etc/masterha/app1.cnf..
  409. Fri Apr :: - [info] MHA::MasterFailover version 0.56.
  410. Fri Apr :: - [info] Starting master failover.
  411. Fri Apr :: - [info]
  412. Fri Apr :: - [info] * Phase : Configuration Check Phase..
  413. Fri Apr :: - [info]
  414. Fri Apr :: - [info] Multi-master configuration is detected. Current primary(writable) master is 192.168.52.129(192.168.52.129:)
  415. Fri Apr :: - [info] Master configurations are as below:
  416. Master 192.168.52.130(192.168.52.130:), replicating from 192.168.52.129(192.168.52.129:), read-only
  417. Master 192.168.52.129(192.168.52.129:), replicating from 192.168.52.130(192.168.52.130:)
  418.  
  419. Fri Apr :: - [info] GTID failover mode =
  420. Fri Apr :: - [info] Dead Servers:
  421. Fri Apr :: - [error][/usr/local/share/perl5/MHA/MasterFailover.pm, ln187] None of server is dead. Stop failover.
  422. Fri Apr :: - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/local/bin/masterha_master_switch line
  423. [root@oraclem1 ~]#
  424.  
  425. 然后设置新的master为alive,在切换过程中,界面几次自动输入YES,最后会有Switchingmaster to 192.168.52.130(192.168.52.130:) completed successfully.提示标志着手动切换成功,如下所示:
  426. [root@oraclem1 ~]# masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --new_master_host=192.168.52.130
  427. Fri Apr :: - [info] MHA::MasterRotate version 0.56.
  428. Fri Apr :: - [info] Starting online master switch..
  429. Fri Apr :: - [info]
  430. Fri Apr :: - [info] * Phase : Configuration Check Phase..
  431. Fri Apr :: - [info]
  432. Fri Apr :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  433. Fri Apr :: - [info] Reading application default configuration from /etc/masterha/app1.cnf..
  434. Fri Apr :: - [info] Reading server configuration from /etc/masterha/app1.cnf..
  435. Fri Apr :: - [info] Multi-master configuration is detected. Current primary(writable) master is 192.168.52.129(192.168.52.129:)
  436. Fri Apr :: - [info] Master configurations are as below:
  437. Master 192.168.52.130(192.168.52.130:), replicating from 192.168.52.129(192.168.52.129:), read-only
  438. Master 192.168.52.129(192.168.52.129:), replicating from 192.168.52.130(192.168.52.130:)
  439.  
  440. Fri Apr :: - [info] GTID failover mode =
  441. Fri Apr :: - [info] Current Alive Master: 192.168.52.129(192.168.52.129:)
  442. Fri Apr :: - [info] Alive Slaves:
  443. Fri Apr :: - [info] 192.168.52.130(192.168.52.130:) Version=5.6.-log (oldest major version between slaves) log-bin:enabled
  444. Fri Apr :: - [info] Replicating from 192.168.52.129(192.168.52.129:)
  445. Fri Apr :: - [info] 192.168.52.131(192.168.52.131:) Version=5.6.-log (oldest major version between slaves) log-bin:enabled
  446. Fri Apr :: - [info] Replicating from 192.168.52.129(192.168.52.129:)
  447.  
  448. It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on 192.168.52.129(192.168.52.129:)? (YES/no): YES
  449. Fri Apr :: - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
  450. Fri Apr :: - [info] ok.
  451. Fri Apr :: - [info] Checking MHA is not monitoring or doing failover..
  452. Fri Apr :: - [info] Checking replication health on 192.168.52.130..
  453. Fri Apr :: - [info] ok.
  454. Fri Apr :: - [info] Checking replication health on 192.168.52.131..
  455. Fri Apr :: - [info] ok.
  456. Fri Apr :: - [info] 192.168.52.130 can be new master.
  457. Fri Apr :: - [info]
  458. From:
  459. 192.168.52.129(192.168.52.129:) (current master)
  460. +--192.168.52.130(192.168.52.130:)
  461. +--192.168.52.131(192.168.52.131:)
  462.  
  463. To:
  464. 192.168.52.130(192.168.52.130:) (new master)
  465. +--192.168.52.131(192.168.52.131:)
  466.  
  467. Starting master switch from 192.168.52.129(192.168.52.129:) to 192.168.52.130(192.168.52.130:)? (yes/NO): yes
  468. Fri Apr :: - [info] Checking whether 192.168.52.130(192.168.52.130:) is ok for the new master..
  469. Fri Apr :: - [info] ok.
  470. Fri Apr :: - [info] ** Phase : Configuration Check Phase completed.
  471. Fri Apr :: - [info]
  472. Fri Apr :: - [info] * Phase : Rejecting updates Phase..
  473. Fri Apr :: - [info]
  474. master_ip_online_change_script is not defined. If you do not disable writes on the current master manually, applications keep writing on the current master. Is it ok to proceed? (yes/NO): yes
  475. Fri Apr :: - [info] Locking all tables on the orig master to reject updates from everybody (including root):
  476. Fri Apr :: - [info] Executing FLUSH TABLES WITH READ LOCK..
  477. Fri Apr :: - [info] ok.
  478. Fri Apr :: - [info] Orig master binlog:pos is mysql-bin.:.
  479. Fri Apr :: - [info] Waiting to execute all relay logs on 192.168.52.130(192.168.52.130:)..
  480. Fri Apr :: - [info] master_pos_wait(mysql-bin.:) completed on 192.168.52.130(192.168.52.130:). Executed events.
  481. Fri Apr :: - [info] done.
  482. Fri Apr :: - [info] Getting new master's binlog name and position..
  483. Fri Apr :: - [info] mysql-bin.:
  484. Fri Apr :: - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.52.130', MASTER_PORT=, MASTER_LOG_FILE='mysql-bin.000058', MASTER_LOG_POS=, MASTER_USER='repl', MASTER_PASSWORD='xxx';
  485. Fri Apr :: - [info] Setting read_only= on 192.168.52.130(192.168.52.130:)..
  486. Fri Apr :: - [info] ok.
  487. Fri Apr :: - [info]
  488. Fri Apr :: - [info] * Switching slaves in parallel..
  489. Fri Apr :: - [info]
  490. Fri Apr :: - [info] -- Slave switch on host 192.168.52.131(192.168.52.131:) started, pid:
  491. Fri Apr :: - [info]
  492. Fri Apr :: - [info] Log messages from 192.168.52.131 ...
  493. Fri Apr :: - [info]
  494. Fri Apr :: - [info] Waiting to execute all relay logs on 192.168.52.131(192.168.52.131:)..
  495. Fri Apr :: - [info] master_pos_wait(mysql-bin.:) completed on 192.168.52.131(192.168.52.131:). Executed events.
  496. Fri Apr :: - [info] done.
  497. Fri Apr :: - [info] Resetting slave 192.168.52.131(192.168.52.131:) and starting replication from the new master 192.168.52.130(192.168.52.130:)..
  498. Fri Apr :: - [info] Executed CHANGE MASTER.
  499. Fri Apr :: - [info] Slave started.
  500. Fri Apr :: - [info] End of log messages from 192.168.52.131 ...
  501. Fri Apr :: - [info]
  502. Fri Apr :: - [info] -- Slave switch on host 192.168.52.131(192.168.52.131:) succeeded.
  503. Fri Apr :: - [info] Unlocking all tables on the orig master:
  504. Fri Apr :: - [info] Executing UNLOCK TABLES..
  505. Fri Apr :: - [info] ok.
  506. Fri Apr :: - [info] All new slave servers switched successfully.
  507. Fri Apr :: - [info]
  508. Fri Apr :: - [info] * Phase : New master cleanup phase..
  509. Fri Apr :: - [info]
  510. Fri Apr :: - [info] 192.168.52.130: Resetting slave info succeeded.
  511. Fri Apr :: - [info] Switching master to 192.168.52.130(192.168.52.130:) completed successfully.
  512. [root@oraclem1 ~]#
  513.  
  514. PS:手动切换后,使用masterha_check_repl不能使用原来的/etc/masterha/app1.cnf来做check,要用新的app2.cnf来做check,因为app1.cnf里面的master是原来旧的cnfcheck会报错主从复制失败。如何生成新的app2.cnf,很简单,如下所示:
  515. ()复制原理的app1.cnf为新的app2.cnf
  516. cp /etc/masterha/app1.cnf/etc/masterha/app2.cnf
  517. ()编辑app2.cnf,将里面的server1server2ip互换,也就是switch的两个主从的ip换掉,如下所示:
  518. [server1]
  519. hostname=192.168.52.130
  520. candidate_master=
  521. master_binlog_dir=/home/data/mysql/binlog/
  522. [server2]
  523. hostname=192.168.52.129
  524. #candidate_master=
  525. #master_binlog_dir=/home/data/mysql/binlog/
  526. ()然后在使用masterha_check_repl --conf=/etc/masterha/app2.cnf进行check,就可以看到switch后的mha的主从是ok的了。
  527.  
  528. 9报错记录总结
  529. 报错记录1
  530. [root@data01 ~]# masterha_check_repl--conf=/etc/masterha/app1.cnf
  531. Tue Apr :: - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
  532. Tue Apr :: - [info] Reading application default configuration from/etc/masterha/app1.cnf..
  533. Tue Apr :: - [info] Reading server configuration from/etc/masterha/app1.cnf..
  534. Tue Apr :: - [info] MHA::MasterMonitor version 0.56.
  535. Tue Apr :: - [error][/usr/local/share/perl5/MHA/Server.pm,ln303] Getting relay log directory orcurrent relay logfile from replication table failed on192.168.52.(192.168.52.130:)!
  536. Tue Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/share/perl5/MHA/ServerManager.pmline
  537. Tue Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
  538. Tue Apr :: - [info] Got exit code (Not master dead).
  539.  
  540. MySQL Replication Health is NOT OK!
  541. [root@data01 ~]#
  542.  
  543. 解决办法:在192.168.52.130上面,vim /etc/my.cnf,在里面添加
  544. relay-log=/home/data/mysql/binlog/mysql-relay-bin
  545. 然后重启mysql,再去重新设置slave连接。
  546. STOP SLAVE;
  547. RESET SLAVE;
  548. CHANGE MASTER TOMASTER_HOST='192.168.52.129',MASTER_USER='repl',MASTER_PASSWORD='repl_1234',MASTER_LOG_FILE='mysql-bin.000178',MASTER_LOG_POS=;
  549. START SLAVE;
  550. Ok,搞定了。
  551.  
  552. 报错记录2
  553.  
  554. [root@data01 perl]# masterha_check_repl--conf=/etc/masterha/app1.cnf
  555. Thu Apr :: - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
  556. Thu Apr :: - [info] Reading application default configuration from/etc/masterha/app1.cnf..
  557. Thu Apr :: - [info] Reading server configuration from/etc/masterha/app1.cnf..
  558. Thu Apr :: - [info] MHA::MasterMonitor version 0.56.
  559. Thu Apr :: - [error][/usr/local/share/perl5/MHA/Server.pm,ln306] Getting relay log directory orcurrent relay logfile from replication table failed on 192.168.52.130(192.168.52.130:)!
  560. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at/usr/local/share/perl5/MHA/ServerManager.pm line
  561. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
  562. Thu Apr :: - [info] Got exit code (Not master dead).
  563.  
  564. MySQL Replication Health is NOT OK!
  565. [root@data01 perl]#
  566.  
  567. 解决方法:
  568. /etc/masterha/app1.cnf文件里面的参数配置,userrepl_user都是mysql账号,需要创建好,这里是只创建了repl_user而没有创建好user账号:
  569. user=manager
  570. password=manager_1234
  571. repl_user=repl
  572. repl_password=repl_1234
  573.  
  574. mysql节点上,建立允许manager 访问数据库的“ manager manager ”账户,主要用于SHOW SLAVESTATUS,RESET SLAVE; 所以需要执行如下命令:
  575. GRANT SUPER,RELOAD,REPLICATIONCLIENT,SELECT ON *.* TO manager@'192.168.52.%' IDENTIFIED BY 'manager_1234';
  576.  
  577. 错误记录3
  578.  
  579. [root@oraclem1 ~]# masterha_check_repl--conf=/etc/masterha/app1.cnf
  580. Thu Apr :: - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
  581. Thu Apr :: - [info] Reading application default configuration from/etc/masterha/app1.cnf..
  582. Thu Apr :: - [info] Reading server configuration from/etc/masterha/app1.cnf..
  583. Thu Apr :: - [info] MHA::MasterMonitor version 0.56.
  584. Thu Apr :: - [error][/usr/local/share/perl5/MHA/ServerManager.pm,ln781] Multi-master configuration is detected, but two or more masters areeither writable (read-only is not set) or dead! Check configurations fordetails. Master configurations are as below:
  585. Master 192.168.52.130(192.168.52.130:),replicating from 192.168.52.129(192.168.52.129:)
  586. Master 192.168.52.129(192.168.52.129:),replicating from 192.168.52.130(192.168.52.130:)
  587.  
  588. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at/usr/local/share/perl5/MHA/MasterMonitor.pm line
  589. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
  590. Thu Apr :: - [info] Got exit code (Not master dead).
  591.  
  592. MySQL Replication Health is NOT OK!
  593. [root@oraclem1 ~]#
  594.  
  595. 解决办法:
  596. mysql> set global read_only=;
  597. Query OK, rows affected (0.00 sec)
  598.  
  599. mysql>
  600.  
  601. 报错记录4
  602.  
  603. Thu Apr :: - [info] Checking SSH publickey authentication andchecking recovery script configurations on all alive slave servers..
  604. Thu Apr :: - [info] Executing command : apply_diff_relay_logs --command=test--slave_user='manager' --slave_host=192.168.52.130 --slave_ip=192.168.52.130--slave_port= --workdir=/var/tmp --target_version=5.6.-log--manager_version=0.56 --relay_dir=/home/data/mysql/data--current_relay_log=mysqld-relay-bin. --slave_pass=xxx
  605. Thu Apr :: - [info] Connecting to root@192.168.52.130(192.168.52.130:)..
  606. Can't exec "mysqlbinlog": No suchfile or directory at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.
  607. mysqlbinlog version command failed with rc1:, please verify PATH, LD_LIBRARY_PATH, and client options
  608. at/usr/local/bin/apply_diff_relay_logs line
  609. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln205] Slaves settings check failed!
  610. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln413] Slave configuration failed.
  611. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/bin/masterha_check_repl line
  612. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
  613. Thu Apr :: - [info] Got exit code (Not master dead).
  614.  
  615. MySQL Replication Health is NOT OK!
  616. [root@oraclem1 ~]#
  617.  
  618. 解决办法:
  619. [root@data02 ~]# type mysqlbinlog
  620. mysqlbinlog is/usr/local/mysql/bin/mysqlbinlog
  621. [root@data02 ~]#
  622. [root@data02 ~]# ln -s/usr/local/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
  623.  
  624. 报错记录5:
  625. Thu Apr :: - [info] Connecting to root@192.168.52.130(192.168.52.130:)..
  626. Checking slave recovery environment settings..
  627. Relay log found at /home/data/mysql/data, up to mysqld-relay-bin.
  628. Temporary relay log file is /home/data/mysql/data/mysqld-relay-bin.
  629. Testing mysql connection and privileges..sh: mysql: command not found
  630. mysql command failed with rc :!
  631. at/usr/local/bin/apply_diff_relay_logs line
  632. main::check()called at /usr/local/bin/apply_diff_relay_logs line
  633. eval{...} called at /usr/local/bin/apply_diff_relay_logs line
  634. main::main()called at /usr/local/bin/apply_diff_relay_logs line
  635. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln205] Slaves settings check failed!
  636. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln413] Slave configuration failed.
  637. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/bin/masterha_check_repl line
  638. Thu Apr :: - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
  639. Thu Apr :: - [info] Got exit code (Not master dead).
  640.  
  641. MySQL Replication Health is NOT OK!
  642.  
  643. 解决办法:
  644. ln -s /usr/local/mysql/bin/mysql/usr/bin/mysql
  645.  
  646. 报错记录6:
  647. Fri Apr :: - [info] Executing command : apply_diff_relay_logs--command=test --slave_user='manager' --slave_host=192.168.52.130--slave_ip=192.168.52.130 --slave_port= --workdir=/var/tmp--target_version=5.6.-log --manager_version=0.56--relay_dir=/home/data/mysql/data--current_relay_log=mysqld-relay-bin. --slave_pass=xxx
  648. Fri Apr :: - [info] Connecting to root@192.168.52.130(192.168.52.130:)..
  649. Checking slave recovery environment settings..
  650. Relay log found at /home/data/mysql/data, up to mysqld-relay-bin.
  651. Temporary relay log file is/home/data/mysql/data/mysqld-relay-bin.
  652. Testing mysql connection and privileges..Warning: Using a password onthe command line interface can be insecure.
  653. ERROR () at line : CREATEcommand denied to user 'manager'@'192.168.52.130' for table'apply_diff_relay_logs_test'
  654. mysql command failed with rc :!
  655. at/usr/local/bin/apply_diff_relay_logs line
  656. main::check()called at /usr/local/bin/apply_diff_relay_logs line
  657. eval{...} called at /usr/local/bin/apply_diff_relay_logs line
  658. main::main()called at /usr/local/bin/apply_diff_relay_logs line
  659. Fri Apr :: -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln205] Slaves settingscheck failed!
  660. Fri Apr :: -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln413] Slave configurationfailed.
  661. Fri Apr :: -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened onchecking configurations. at/usr/local/bin/masterha_check_repl line
  662. Fri Apr :: -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln523] Error happened onmonitoring servers.
  663. Fri Apr :: - [info] Got exitcode (Not master dead).
  664.  
  665. MySQL Replication Health is NOT OK!
  666.  
  667. 解决办法:
  668. 执行如下授权语句sql:
  669. GRANT CREATE,INSERT,UPDATE,DELETE,DROP ON*.* TO manager@'192.168.52.%';
  670.  
  671. ,参考资料
  672. 参考:http://blog.csdn.net/largetalk/article/details/10006899
  673. 参考:http://www.tuicool.com/articles/NV3U3i
  674. 多实例参考:http://www.cnblogs.com/wingsless/p/4033093.html
  675. 参考:http://www.tuicool.com/articles/NV3U3i
  676. 参考人为模拟故障过程:
  677. http://www.mysqlsystems.com/2012/03/figure-out-process-of-autofailover-on-mha.html#more-2172
  678.  
  679. ----------------------------------------------------------------------------------------------------------------
  680. <版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!>
  681. 原博客地址: http://blog.itpub.net/26230597/viewspace-1570798/
  682. 原作者:黄杉 (mchdba)
  683. ----------------------------------------------------------------------------------------------------------------

MySQL 高可用MHA安装部署以及故障转移详细资料汇总 转的更多相关文章

  1. Mysql 高可用(MHA)-读写分离(Atlas)-分布式架构(Mycat)

    Mysql 高可用(MHA)-读写分离(Atlas) 1. 搭建主从复制(一主两从) 1.1 准备环境 1 主库:10.0.0.51/db01 2 从库:10.0.0.52/db02,10.0.0.5 ...

  2. MySQL高可用MHA实战

    MySQL高可用架构MHA介绍 简介: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职 ...

  3. 基于PXC的MySQL高可用环境简单部署

    PXC简介 Percona XtraDB Cluster(简称PXC集群)提供了MySQL高可用的一种实现方法. 1.集群是有节点组成的,推荐配置至少3个节点,但是也可以运行在2个节点上. 2.每个节 ...

  4. MySQL之Haproxy+Keepalived+MySQL高可用均衡负载部署 (网络摘抄)

    来源于:https://blog.csdn.net/weisong530624687/article/details/71536837?utm_source=blogxgwz3 一.安装主从MySQL ...

  5. 基于Keepalived的MySQL高可用

    keepalived负责的是故障转移,至于故障转以后的节点之间数据的一致性问题依赖于具体的复制模式.不管是主从.一主多从还是双主.集群节点个数.主从具体的模式无关(常规复制,半同步复制,GTID复制, ...

  6. MySQL高可用方案--MHA部署及故障转移

    架构设计及必要配置 主机环境 IP                 主机名             担任角色 192.168.192.128  node_master    MySQL-Master| ...

  7. MySQL高可用方案MHA的部署和原理

    MHA(Master High Availability)是一套相对成熟的MySQL高可用方案,能做到在0~30s内自动完成数据库的故障切换操作,在master服务器不宕机的情况下,基本能保证数据的一 ...

  8. MySQL高可用架构-MHA环境部署记录

    一.MHA介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司) ...

  9. MySQL MHA高可用集群部署及故障切换

    一.MHA概念MHA(MasterHigh Availability)是一套优秀的MySQL高可用环境下故障切换和主从复制的软件.MHA 的出现就是解决MySQL 单点的问题.MySQL故障切换过程中 ...

随机推荐

  1. javadoc注释规范

    javadoc做注释 一. Java 文档 // 注释一行 /* ...... */ 注释若干行 /** ...... */ 注释若干行,并写入 javadoc 文档 通常这种注释的多行写法如下: / ...

  2. Getting Started(Google Cloud Storage Client Library)

    在运行下面的步骤之前,请确保: 1.你的项目已经激活了Google Cloud Storage和App Engine,包括已经创建了至少一个Cloud Storage bucket. 2.你已经下载了 ...

  3. 【hbase】使用thrift with python 访问HBase

    HBase 版本: 0.98.6 thrift   版本: 0.9.0 使用 thrift client with python 连接 HBase 报错: Traceback (most recent ...

  4. 【转】一步步教你读懂NET中IL(图文详解)

    本文章以一个实际的例子,让你了解堆叠式 VM 的运作原理,并对 .NET IL(Intermediate Language)有最基本的領略,需要的朋友可以参考下  .NET CLR 和 Java VM ...

  5. C#多线程的几种实现方法

    1.最简单的多线程 using System; using System.Threading; namespace ThreadTest1 { public class SimpleThread { ...

  6. hdu4614Vases and Flowers(线段树,段设置,更新时范围的右边值为变量)

    Problem Description Alice is so popular that she can receive many flowers everyday. She has N vases ...

  7. 12个有趣的C语言面试题

    摘要:12个C语言面试题,涉及指针.进程.运算.结构体.函数.内存,看看你能做出几个! 1.gets()函数 问:请找出下面代码里的问题: #include<stdio.h> int ma ...

  8. MFC 应用、模板、框架、文档、视图 的关系

    从该对象 如何访问其他对象 全局函数 调用全局函数AfxGetApp可以得到CWinApp应用类指针 应用 AfxGetApp()->m_pMainWnd为框架窗口指针:用CWinApp::Ge ...

  9. 学习LINQ,发现一个好的工具。LINQPad!!

    今日学习LINQ,发现一个好的工具.LINQPad!! 此工具的好处在于,不需要在程序内执行,直接只用工具测试.然后代码通过即可,速度快,简洁方便. 可以生成其LINQ查询对应的lambda和SQL语 ...

  10. 更新证书错误Code Sign error: Provisioning profile ‘XXXX'can't be found

    在Xcode中当你在更新了你得证书而再重新编译你的程序,真机调试一直会出现 Code Sign error: Provisioning profile ‘XXXX’ can't be found是不是 ...