Mysql5.5部署MHA

MHA分管理节点和数据库节点,数据库节点由mysql主从或者主主从构成,当主库挂掉后,管理节点会自动将从节点提升为主节点;管理节点的角色类似于oracle数据库中的

mha分管理节点和数据库节点,香港空间,数据库节点由mysql主从或者主主从构成,当主库挂掉后,管理节点会自动将从节点提升为主节点;管理节点的角色类似于oracle数据库中的fast start failover中的observer,但mha上层可以通过keepalive部署vip,程序连接数据库使用vip,从而实现后台数据库的故障切换透明化

MHA节点包含三个脚本,依赖perl模块;
save_binary_logs:保存和复制当掉的主服务器二进制日志;
apply_diff_relay_logs:识别差异的relay log事件,并应用于其他salve服务器;
purge_relay_logs:清除relay log文件;
需要在所有mysql服务器上安装MHA节点,网站空间,MHA管理服务器也需要安装。MHA管理节点模块内部依赖MHA节点模块;
MHA管理节点通过ssh连接管理mysql服务器和执行MHA节点脚本。MHA节点依赖perl的DBD::mysql模块;

本文环境介绍,香港服务器,操作系统均为rhel5.4
主库:192.168.123.13/dg53.yang.com
备库:192.168.123.14/dg54.yang.com
管理节点:192.168.123.15/dg55.yang.com

在开始之前,请先配置好服务器间的时间同步和名称解析

一:在数据库节点安装mha node

二:管理节点
1:按照步骤一安装mha node

2:安装mha manager

3:编辑配置文件

4:配置manager节点和node节点以及node节点间的ssh公钥信任

jQuery返回顶部跟底部浮窗代码 jQuery返回顶部跟底部浮窗代码

jQuery返回顶部跟底部浮窗代码是一款带有上下箭头跟留言按钮的jQuery悬浮网页右侧中间浮动窗口特效代码。

jQuery返回顶部跟底部浮窗代码 84 查看详情 jQuery返回顶部跟底部浮窗代码

5:测试ssh连接

6:测试主从复制情况,默认使用root用户连接

7:启动管理节点进程

三:测试failover过程
1:当前主库为192.168.123.13,关闭主库

2:在管理节点上观察日志输出

[root@dg55 ~]# tail -f /masterha/app1/manager.log
Wed Jun  6 14:50:48 2012 – [info]
192.168.123.13 (current master)
 +–192.168.123.14

Wed Jun  6 14:50:48 2012 – [warning] master_ip_failover_script is not defined.
Wed Jun  6 14:50:48 2012 – [warning] shutdown_script is not defined.
Wed Jun  6 14:50:48 2012 – [info] Set master ping interval 1 seconds.
Wed Jun  6 14:50:48 2012 – [warning] secondary_check_script is not defined. It is highly recommended setting it to check master reachability from two or more routes.
Wed Jun  6 14:50:48 2012 – [info] Starting ping health check on 192.168.123.13(192.168.123.13:3306)..
Wed Jun  6 14:50:48 2012 – [info] Ping succeeded, sleeping until it doesn’t respond..

Wed Jun  6 14:51:32 2012 – [warning] Got error on MySQL ping: 2006 (MySQL server has gone away)
Wed Jun  6 14:51:32 2012 – [info] HealthCheck: SSH to 192.168.123.13 is reachable.
Wed Jun  6 14:51:33 2012 – [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111)
Wed Jun  6 14:51:33 2012 – [warning] Connection failed 1 time(s)..
Wed Jun  6 14:51:34 2012 – [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111)
Wed Jun  6 14:51:34 2012 – [warning] Connection failed 2 time(s)..
Wed Jun  6 14:51:35 2012 – [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111)
Wed Jun  6 14:51:35 2012 – [warning] Connection failed 3 time(s)..
Wed Jun  6 14:51:35 2012 – [warning] Master is not reachable from health checker!
Wed Jun  6 14:51:35 2012 – [warning] Master 192.168.123.13(192.168.123.13:3306) is not reachable!
Wed Jun  6 14:51:35 2012 – [warning] SSH is reachable.
Wed Jun  6 14:51:35 2012 – [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/masterha/app1.cnf again, and trying to connect to all servers to check server status..
Wed Jun  6 14:51:35 2012 – [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jun  6 14:51:35 2012 – [info] Reading application default configurations from /etc/masterha/app1.cnf..
Wed Jun  6 14:51:35 2012 – [info] Reading server configurations from /etc/masterha/app1.cnf..
Wed Jun  6 14:51:35 2012 – [info] Dead Servers:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info] Alive Servers:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)
Wed Jun  6 14:51:35 2012 – [info] Alive Slaves:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)  Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
Wed Jun  6 14:51:35 2012 – [info]     Replicating from 192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info]     Primary candidate for the new Master (candidate_master is set)
Wed Jun  6 14:51:35 2012 – [info] Checking slave configurations..
Wed Jun  6 14:51:35 2012 – [warning]  read_only=1 is not set on slave 192.168.123.14(192.168.123.14:3306).
Wed Jun  6 14:51:35 2012 – [warning]  relay_log_purge=0 is not set on slave 192.168.123.14(192.168.123.14:3306).
Wed Jun  6 14:51:35 2012 – [info] Checking replication filtering settings..
Wed Jun  6 14:51:35 2012 – [info]  Replication filtering check ok.
Wed Jun  6 14:51:35 2012 – [info] Master is down!
Wed Jun  6 14:51:35 2012 – [info] Terminating monitoring script.
Wed Jun  6 14:51:35 2012 – [info] Got exit code 20 (Master dead).
Wed Jun  6 14:51:35 2012 – [info] MHA::MasterFailover version 0.52.
Wed Jun  6 14:51:35 2012 – [info] Starting master failover.
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] * Phase 1: Configuration Check Phase..
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] Dead Servers:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info] Checking master reachability via mysql(double check)..
Wed Jun  6 14:51:35 2012 – [info]  ok.
Wed Jun  6 14:51:35 2012 – [info] Alive Servers:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)
Wed Jun  6 14:51:35 2012 – [info] Alive Slaves:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)  Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
Wed Jun  6 14:51:35 2012 – [info]     Replicating from 192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info]     Primary candidate for the new Master (candidate_master is set)
Wed Jun  6 14:51:35 2012 – [info] ** Phase 1: Configuration Check Phase completed.
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] * Phase 2: Dead Master Shutdown Phase..
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] Forcing shutdown so that applications never connect to the current master..
Wed Jun  6 14:51:35 2012 – [warning] master_ip_failover_script is not set. Skipping invalidating dead master ip address.
Wed Jun  6 14:51:35 2012 – [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Wed Jun  6 14:51:35 2012 – [info] * Phase 2: Dead Master Shutdown Phase completed.
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] * Phase 3: Master Recovery Phase..
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] * Phase 3.1: Getting Latest Slaves Phase..
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] The latest binary log file/position on all slaves is mysql-bin.000021:107
Wed Jun  6 14:51:35 2012 – [info] Latest slaves (Slaves that received relay log files to the latest):
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)  Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
Wed Jun  6 14:51:35 2012 – [info]     Replicating from 192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info]     Primary candidate for the new Master (candidate_master is set)
Wed Jun  6 14:51:35 2012 – [info] The oldest binary log file/position on all slaves is mysql-bin.000021:107
Wed Jun  6 14:51:35 2012 – [info] Oldest slaves:
Wed Jun  6 14:51:35 2012 – [info]   192.168.123.14(192.168.123.14:3306)  Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
Wed Jun  6 14:51:35 2012 – [info]     Replicating from 192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:35 2012 – [info]     Primary candidate for the new Master (candidate_master is set)
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] * Phase 3.2: Saving Dead Master’s Binlog Phase..
Wed Jun  6 14:51:35 2012 – [info]
Wed Jun  6 14:51:35 2012 – [info] Fetching dead master’s binary logs..
Wed Jun  6 14:51:35 2012 – [info] Executing command on the dead master 192.168.123.13(192.168.123.13:3306): save_binary_logs –command=save –start_file=mysql-bin.000021  –start_pos=107 –binlog_dir=/mydata –output_file=/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog –handle_raw_binlog=1 –disable_log_bin=0 –manager_version=0.52
  Creating /var/tmp if not exists..    ok.
 Concat binary/relay logs from mysql-bin.000021 pos 107 to mysql-bin.000021 EOF into /var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog ..
  Dumping binlog format description event, from position 0 to 107.. ok.
  Dumping effective binlog data from /mydata/mysql-bin.000021 position 107 to tail(126).. ok.
 Concat succeeded.
Wed Jun  6 14:51:36 2012 – [info] scp from root@192.168.123.13:/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog to local:/masterha/app1/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog succeeded.
Wed Jun  6 14:51:36 2012 – [info] HealthCheck: SSH to 192.168.123.14 is reachable.
Wed Jun  6 14:51:37 2012 – [info]
Wed Jun  6 14:51:37 2012 – [info] * Phase 3.3: Determining New Master Phase..
Wed Jun  6 14:51:37 2012 – [info]
Wed Jun  6 14:51:37 2012 – [info] Finding the latest slave that has all relay logs for recovering other slaves..
Wed Jun  6 14:51:37 2012 – [info] All slaves received relay logs to the same position. No need to resync each other.
Wed Jun  6 14:51:37 2012 – [info] Searching new master from slaves..
Wed Jun  6 14:51:37 2012 – [info]  Candidate masters from the configuration file:
Wed Jun  6 14:51:37 2012 – [info]   192.168.123.14(192.168.123.14:3306)  Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
Wed Jun  6 14:51:37 2012 – [info]     Replicating from 192.168.123.13(192.168.123.13:3306)
Wed Jun  6 14:51:37 2012 – [info]     Primary candidate for the new Master (candidate_master is set)
Wed Jun  6 14:51:37 2012 – [info]  Non-candidate masters:
Wed Jun  6 14:51:37 2012 – [info]  Searching from candidate_master slaves which have received the latest relay log events..
Wed Jun  6 14:51:37 2012 – [info] New master is 192.168.123.14(192.168.123.14:3306)
Wed Jun  6 14:51:37 2012 – [info] Starting master failover..
Wed Jun  6 14:51:37 2012 – [info]
From:
192.168.123.13 (current master)
 +–192.168.123.14

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/529193.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年11月9日 09:35:27
下一篇 2025年11月9日 09:41:11

相关推荐

  • 网络进化!

    Web 应用程序从静态网站到动态网页的演变是由对更具交互性、用户友好性和功能丰富的 Web 体验的需求推动的。以下是这种范式转变的概述: 1. 静态网站(1990 年代) 定义:静态网站由用 HTML 编写的固定内容组成。每个页面都是预先构建并存储在服务器上,并且向每个用户传递相同的内容。技术:HT…

    2025年12月24日
    000
  • 为什么多年的经验让我选择全栈而不是平均栈

    在全栈和平均栈开发方面工作了 6 年多,我可以告诉您,虽然这两种方法都是流行且有效的方法,但它们满足不同的需求,并且有自己的优点和缺点。这两个堆栈都可以帮助您创建 Web 应用程序,但它们的实现方式却截然不同。如果您在两者之间难以选择,我希望我在两者之间的经验能给您一些有用的见解。 在这篇文章中,我…

    2025年12月24日
    000
  • CSS如何实现任意角度的扇形(代码示例)

    本篇文章给大家带来的内容是关于CSS如何实现任意角度的扇形(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。 扇形制作原理,底部一个纯色原形,里面2个相同颜色的半圆,可以是白色,内部半圆按一定角度变化,就可以产生出扇形效果 扇形绘制 .shanxing{ position:…

    2025年12月24日
    000
  • html中怎么运行sql语句_html中运行sql语句方法【教程】

    必须通过后端服务执行SQL操作。一、PHP与MySQL交互:使用PHP脚本在服务器端连接数据库,执行查询并嵌入HTML输出,避免硬编码凭证。二、Ajax调用API:前端通过JavaScript向后端API发送请求,服务端执行SQL并返回JSON数据,前端动态渲染结果。三、SQLite与JavaScr…

    2025年12月23日
    000
  • html手机怎么运行_手机运行html方法【教程】

    1、使用手机浏览器可直接打开本地HTML文件,只需通过文件管理器点击文件并选择浏览器打开即可预览;2、借助Spck Editor等专用编辑器应用能实现实时编辑与预览,适合开发调试;3、对于含JavaScript或需服务器支持的动态内容,应安装KSWEB类应用搭建本地服务器,再通过http://loc…

    2025年12月23日
    000
  • html如何连接_连接HTML与数据库或API接口【接口】

    HTML无法直接连接数据库或调用API,需借助JavaScript fetch、PHP中转、Node.js后端或Python Flask等服务端技术实现动态数据交互。 如果您希望在网页中动态获取数据,HTML本身无法直接连接数据库或调用API接口,必须借助服务器端语言或JavaScript等客户端技…

    2025年12月23日
    000
  • HTML如何添加批注功能_评论系统实现方案【教程】

    可实现HTML文本批注功能的四种方案:一、基于HTML5自定义属性与JS的静态批注;二、遵循W3C标准的语义化批注;三、嵌入Utterances或Giscus等第三方评论系统;四、自建AJAX评论后端+前端组件。 如果您希望在HTML页面中为特定文本添加可交互的批注功能,或构建一个轻量级的评论系统,…

    2025年12月23日
    000
  • html怎么在本地服务器运行_本地服务器运html方法【指南】

    使用本地服务器运行HTML文件需通过HTTP协议,可选Python命令启动服务、Node.js的http-server、VS Code的Live Server插件或XAMPP等工具,确保AJAX等功能正常。 要在本地服务器运行HTML文件,不能直接双击打开,因为部分功能(如AJAX、API调用)需要…

    2025年12月23日
    200
  • phpstudy怎么运行本地html_phpstudy运行本地html方法【教程】

    确保Apache或Nginx服务已启动;2. 将HTML文件放入WWW目录;3. 浏览器访问localhost即可运行页面。 在使用 PHPStudy 时,运行本地 HTML 文件非常简单。PHPStudy 是一个集成了 Apache/Nginx、PHP 和 MySQL 的集成环境工具,主要用于本地…

    2025年12月23日
    000
  • HTML页面如何生成短链接_URL压缩转换方法【攻略】

    可借助第三方服务、API调用、Nginx反向代理、PHP脚本或GitHub Pages五种方式将HTML页面URL转为短链接:1.用bit.ly等平台手动缩短;2.调用Bitly API批量生成;3.配置Nginx rewrite规则重定向;4.部署PHP+MySQL实现动态跳转;5.利用GitHu…

    2025年12月23日
    000
  • Java JDBC中SQL INSERT语句的常见语法错误及修复指南

    本文旨在解决java jdbc应用中常见的sql `insert`语句语法错误,特别是因缺少括号而导致的错误。我们将深入分析错误信息,指出问题根源,并提供正确的sql语句范例及java jdbc `preparedstatement`的使用方法。文章还将涵盖jdbc数据库操作的最佳实践、错误处理和调…

    2025年12月23日
    000
  • wampserver怎么运行html程序_wampserver运行html程序方法【教程】

    使用WampServer运行HTML程序需将文件放入www目录,启动Apache服务后通过http://localhost/项目路径访问,确保在本地服务器环境下正确解析运行。 如果您在本地开发网页,但无法正确查看HTML文件的运行效果,可能是由于未通过本地服务器环境进行访问。WampServer 提…

    2025年12月23日
    000
  • 平板怎么运行html代码_平板运行html代码步骤【指南】

    可在平板上通过四种方式查看HTML效果:一、用浏览器直接打开本地.html文件;二、使用JSFiddle等在线编辑器实时预览;三、安装Acode等编程应用离线编写并预览;四、通过KSWEB搭建本地服务器运行含动态内容的页面。 如果您希望在平板设备上查看或测试HTML代码的效果,但不确定如何操作,则可…

    2025年12月23日
    000
  • html上怎么运行php代码吗_html中运行php代码方法【教程】

    要使PHP代码在HTML中执行,必须通过支持PHP的服务器环境。首先将文件保存为.php格式并部署到配置好PHP模块的服务器(如Apache)根目录,通过http://localhost访问;或修改服务器配置(如.htaccess)令.html文件解析PHP;推荐使用.php文件混合HTML与PHP…

    2025年12月23日
    000
  • html怎么用sublime运行php_sublime运行html中php方法【教程】

    可在Sublime Text中通过配置PHP环境变量并创建Build System运行PHP代码,或使用PHP内置服务器、XAMPP等集成环境结合浏览器预览实现解析与调试。 如果您在使用Sublime Text编辑HTML或PHP文件时,希望直接运行PHP代码并查看输出结果,但发现无法像在浏览器中那…

    2025年12月23日
    000
  • PHP表单提交后防止页面刷新并保留数据与错误提示的教程

    本教程旨在解决php表单提交时页面刷新、用户输入数据丢失以及错误提示显示不佳的问题。核心方法是利用服务器端php的`$_post`变量,在表单提交并进行服务器端验证失败后,不进行页面重定向,而是直接在当前页面重新渲染表单,同时回填用户之前输入的数据并显示验证错误信息,从而显著提升用户体验。 引言:优…

    2025年12月23日
    000
  • 如何通过JavaScript/jQuery获取HTML元素内容并与PHP后端交互

    本教程详细阐述了如何利用JavaScript和jQuery从HTML页面中动态获取特定` `标签的文本内容,并进一步探讨了如何将这些前端捕获的数据通过AJAX技术安全地传递给PHP后端进行处理,例如执行SQL查询。文章涵盖了从前端事件触发、数据捕获到后端数据接收、处理及安全防护的全流程,旨在提供一个…

    2025年12月23日
    000
  • php怎么在html5中运行_php在html5中运行方法【教程】

    PHP在服务器端运行,通过嵌入HTML5文件生成动态内容。1. PHP与HTML5协同工作:PHP代码嵌入.html或.php文件,由服务器解析后输出纯HTML至浏览器。2. 创建index.php文件,使用标准HTML5结构,在其中插入等PHP代码,实现动态内容展示。3. 搭建本地环境可选用XAM…

    2025年12月23日 好文分享
    000
  • epp4怎么运行html文件_EPP4运行html文件步骤【指南】

    首先确认EPP4已安装并启动Apache服务,将HTML文件放入www目录后,通过http://localhost/路径访问即可预览页面,确保文件位置与路径正确。 打开EPP4后运行HTML文件并不复杂,只需正确操作即可在浏览器中预览页面效果。EPP4(Easy PHP Pack 4)是一个集成开发…

    2025年12月23日
    000
  • html怎么用浏览器运行php_浏览器运html中php文件方法【教程】

    正确答案是搭建本地开发环境。需安装XAMPP等集成工具,将.php文件放入htdocs目录,通过http://localhost访问,确保服务器解析PHP并返回HTML给浏览器显示。 PHP 是服务器端语言,不能直接通过浏览器像 HTML 那样双击打开运行。你看到的“在浏览器中运行 PHP”其实是指…

    2025年12月23日
    000

发表回复

登录后才能评论
关注微信