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

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

一、安装MHA软件:

yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager

wget http://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.52-0.noarch.rpm
wget https://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52-0.noarch.rpm
wget https://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz
rpm包安装:

rpm -ivh mha4mysql-manager-0.52-0.noarch.rpm
rpm -ivh mha4mysql-node-0.52-0.noarch.rpm

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

tar zxvf mha4mysql-manager-0.52.tar.gz
cd mha4mysql-manager-0.52
perl Makefile.PL
make
make install
二、配置基本环境:

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

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

10.1.1.231上执行:

grant all privileges on *.* to 'root'@'10.1.1.234' identified by 'rootpasswd';
flush privileges;
10.1.1.234上执行:

grant all privileges on *.* to 'root'@'10.1.1.231' identified by 'rootpasswd';
flush privileges;

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

[root@localhost mha4mysql-manager-0.52]#mkdir /etc/masterha
[root@localhost mha4mysql-manager-0.52]#mkdir -p /masterha/app1
[root@localhost mha4mysql-manager-0.52]#cp samples/conf/* /etc/masterha/
[root@localhost mha4mysql-manager-0.52]#cat /etc/masterha/app1.cnf 
[root@localhost mha4mysql-manager-0.52]#mkdir /etc/masterha
[root@localhost mha4mysql-manager-0.52]#mkdir -p /masterha/app1
[root@localhost mha4mysql-manager-0.52]#cp samples/conf/* /etc/masterha/
[root@localhost mha4mysql-manager-0.52]#cat /etc/masterha/app1.cnf

[server default]
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
 
[server2]
hostname=10.1.1.234
port=63306
master_binlog_dir="/state/partition1/mysql/data"
candidate_master=1
四、检测配置:

检查ssh:

[root@localhost masterha]# masterha_check_ssh  --conf=/etc/masterha/app1.cnf 
Fri Sep 12 15:23:25 2014 - [info] Reading default configuratoins from /etc/masterha_default.cnf..
Fri Sep 12 15:23:25 2014 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Fri Sep 12 15:23:25 2014 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Fri Sep 12 15:23:25 2014 - [info] Starting SSH connection tests..
Fri Sep 12 15:23:32 2014 - [debug]
Fri Sep 12 15:23:25 2014 - [debug]  Connecting via SSH from root@10.1.1.231(10.1.1.231) to root@10.1.1.234(10.1.1.234)..
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Fri Sep 12 15:23:32 2014 - [debug]   ok.
Fri Sep 12 15:23:38 2014 - [debug]
Fri Sep 12 15:23:26 2014 - [debug]  Connecting via SSH from root@10.1.1.234(10.1.1.234) to root@10.1.1.231(10.1.1.231)..
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Fri Sep 12 15:23:38 2014 - [debug]   ok.
Fri Sep 12 15:23:38 2014 - [info] All SSH connection tests passed successfully.

检查mha启动状态:

[root@localhost masterha]# masterha_check_status  --conf=/etc/masterha/app1.cnf
app1 (pid:11444) is running(0:PING_OK), master:10.1.1.231
检查主从复制状态:

[root@compute-0-52 masterha]# masterha_check_repl  --conf=/etc/masterha/app1.cnf
Fri Sep 12 16:15:12 2014 - [info] Reading default configuratoins from /etc/masterha_default.cnf..
Fri Sep 12 16:15:12 2014 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Fri Sep 12 16:15:12 2014 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Fri Sep 12 16:15:12 2014 - [info] MHA::MasterMonitor version 0.52.
Fri Sep 12 16:15:12 2014 - [info] Dead Servers:
Fri Sep 12 16:15:12 2014 - [info] Alive Servers:
Fri Sep 12 16:15:12 2014 - [info]   10.1.1.231(10.1.1.231:3306)
Fri Sep 12 16:15:12 2014 - [info]   10.1.1.234(10.1.1.234:3306)
Fri Sep 12 16:15:12 2014 - [info] Alive Slaves:
Fri Sep 12 16:15:12 2014 - [info]   10.1.1.234(10.1.1.234:3306)  Version=5.6.13-log (oldest major version between slaves) log-bin:enabled
Fri Sep 12 16:15:12 2014 - [info]     Replicating from 10.1.1.231(10.1.1.231:3306)
Fri Sep 12 16:15:12 2014 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Sep 12 16:15:12 2014 - [info] Current Alive Master: 10.1.1.231(10.1.1.231:3306)
Fri Sep 12 16:15:12 2014 - [info] Checking slave configurations..
Fri Sep 12 16:15:12 2014 - <div class="warning shortcodestyle"></div>  relay_log_purge=0 is not set on slave 10.1.1.234(10.1.1.234:3306).
Fri Sep 12 16:15:12 2014 - [info] Checking replication filtering settings..
Fri Sep 12 16:15:12 2014 - [info]  binlog_do_db= denovo_ng, binlog_ignore_db= information_schema,mysql,test
Fri Sep 12 16:15:12 2014 - [info]  Replication filtering check ok.
Fri Sep 12 16:15:12 2014 - [info] Starting SSH connection tests..
Fri Sep 12 16:15:25 2014 - [info] All SSH connection tests passed successfully.
Fri Sep 12 16:15:25 2014 - [info] Checking MHA Node version..
Fri Sep 12 16:15:32 2014 - [info]  Version check ok.
Fri Sep 12 16:15:32 2014 - [info] Checking SSH publickey authentication and checking recovery script configurations on the current master..
Fri Sep 12 16:15:38 2014 - [info]   Executing command: 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
Fri Sep 12 16:15:38 2014 - [info]   Connecting to root@10.1.1.231(10.1.1.231)..
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
  Creating /var/tmp if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /state/partition1/mysql/data, up to mysql-master-bin.000004
Fri Sep 12 16:15:45 2014 - [info] Master setting check done.
Fri Sep 12 16:15:45 2014 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Fri Sep 12 16:15:45 2014 - [info]   Executing command : 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
Fri Sep 12 16:15:45 2014 - [info]   Connecting to root@10.1.1.234(10.1.1.234)..
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
  Checking slave recovery environment settings..
    Opening /state/partition1/mysql/data/relay-log.info ... ok.
    Relay log found at /state/partition1/mysql/data, up to compute-0-52-relay-bin.000007
    Temporary relay log file is /state/partition1/mysql/data/compute-0-52-relay-bin.000007
    Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
mysql: Unknown OS character set 'ISO-8859-15'.
mysql: Switching to the default character set 'latin1'.
 done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Fri Sep 12 16:15:51 2014 - [info] Slaves settings check done.
Fri Sep 12 16:15:51 2014 - [info]
10.1.1.231 (current master)
 +--10.1.1.234
 
Fri Sep 12 16:15:51 2014 - [info] Checking replication health on 10.1.1.234..
Fri Sep 12 16:15:51 2014 - [info]  ok.
Fri Sep 12 16:15:51 2014 - <div class="warning shortcodestyle"></div> master_ip_failover_script is not defined.
Fri Sep 12 16:15:51 2014 - <div class="warning shortcodestyle"></div> shutdown_script is not defined.
Fri Sep 12 16:15:51 2014 - [info] Got exit code 0 (Not master dead).
 
MySQL Replication Health is OK

时间: 2024-09-20 00:00:47

MHA实现mysql5.6主从切换安装配置教程的相关文章

2009年最新版 win2003 IIS6+PHP5+MySQL5+Zend Optimizer+phpMyAdmin安装配置教程第1/8页_win服务器

操作系统:Windows.Server.2003.R2,Enterprise.Edition,SP2,x86,CHS,VOL,MSDN本次配置PHP的服务器环境:Windows2003+ IIS6+PHP5+MySQL3+Zend+phpMyAdmin整个配置过程需要是使用拥有管理员权限的系统帐号登录Windows在整个配置过程中所示的截图可能根据各使用的系统不同,窗口界面而有所不同,但对应的选项卡栏目是相同的,只需要找到提到的对应选项卡即可. 一.下载相关软件 安装前需要准备的软件(因为我这里

mysql5.6主从环境安装配置步骤详解

服务器配置: 10.1.1.231   master server 10.1.1.234   slave server 服务器系统为:centos5.6 软件包: MySQL-client-5.6.13-1.linux_glibc2.5.x86_64.rpm MySQL-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm MySQL-server-5.6.13-1.linux_glibc2.5.x86_64.rpm MySQL-shared-5.6.13-1.lin

jpgraph安装配置教程详细介绍

在学习了之前两篇php jpgraph安装教程后,只要jpgraph类库通过了PHP安装环境的验证后,就可以正式安装jpgraph类库了,其实jpgraph类库的安装非常方便,只要将下载的jpgraph类库解压缩至已搭建的PHP环境下的相关目录下即可.jpgraph安装过程的关键在于PHP配置文件php.ini与jpgraph配置文件jpg-config.inc.php配置.下面我根据jpgraph类库的英文文档进行说明,希望对使用jpgraph类库的PHP开发者有所帮助. jpgraph类库安

Windows2003下php5.4安装配置教程(IIS)_php技巧

本文与<Windows2003下php5.4安装配置教程(Apache2.4)>(点击打开链接)为姊妹篇,只是php所用的服务器有点不同,这里一个是Apache2.4,一个是Windows2003自带的IIS服务器. 一.在Windows2003安装IIS 1.首先打开Windows2003的控制面板,查看是否有"管理工具",没有也不要紧,点击"添加或删除程序".有的话,可以直接进入第二步,IIS的配置. 2.在弹出的窗口,选择添加/删除Windows组

MySQL5.7.14下载安装图文教程及MySQL数据库语句入门大全_Mysql

如何下载: 我先去MySQL首页下载最新版本的MySQL-链接:https://www.mysql.com/downloads/ 进入此界面下载: Downloads–>MySQL Community Edition (GPL)(这是免费版的,当然,有钱的可以用收费的,功能更强大)–>MySQL Community Server (GPL) –>选择对应的系统和电脑版本(在这里,我选择的是Window系统64位的下载) –>No thanks, just start my down

MySQL5.5.21安装配置教程(win7)_Mysql

Win7安装mysql的具体过程,我的版本是5.5.21 以下是我的安装步骤: 1.首先单击MySQL5.5.21的安装文件,出现该数据库的安装向导界面,单击"next"继续安装,如图所示: 2.在打开的窗口中,选择接受安装协议,单击"next"继续安装,如图所示: 3.在出现选择安装类型的窗口中,有"typical(默认)"."Complete(完全)"."Custom(用户自定义)"三个选项,我们选择&

IIS6+PHP5+MySQL5+Zend Optimizer+phpMyAdmin安装配置图文教程 2009年_php实例

便于大家转载和离线阅读,本教程的HTML源码.UBB源码.PDF版本.Flash版本提供下载.下载地址:http://code.google.com/p/wpmi/downloads/list 操作系统:Windows.Server.2003.R2,Enterprise.Edition,SP2,x86,CHS,VOL,MSDN本次配置PHP的服务器环境:Windows2003+ IIS6+PHP5+MySQL3+Zend+phpMyAdmin整个配置过程需要是使用拥有管理员权限的系统帐号登录Wi

Grunt安装配置教程:前端自动化工作流

文章简介:Grunt 打造前端自动化工作流. Grunt这货是啥? 最近很火的前端自动化小工具,基于任务的命令行构建工具 http://gruntjs.com Grunt能帮我们干啥? 在开始介绍前,先向大家描述下面的场景: [场景1:项目开始前] 先建立一个 projA 的文件夹 再建 html css js images (建5个或以上文件夹,花费1分钟) 拷贝 CSS库(Yui Reset bootstrap)JS库(Requiet.js Seajs jQuery jQuery插件 ) 进

mysql 5.7.13 解压缩版(免安装)安装配置教程_Mysql

MySQL是一个关系型数据库管理系统,官方网站是http://www.mysql.com/,分为MySQL Enterprise Edition(commercial).MySQL Cluster CGE.MySQL Community Edition三个版本,第一个 MySQL Enterprise Edition需要花钱,提供技术支持.第二个 MySQL Cluster,要在MySQL Enterprise Edition或MySQL Community Edition的基础上用,平衡多台数