MHA实现mysql5.6主从切换安装配置教程
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-17 14:45:48 浏览: 评论:0
下面给各位介绍一下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
- --phpfensi.com
- [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
Tags: MHA切换安装 mysql5 6安装配置
相关文章
- ·CentOS6.4安装配置mysql 5.6服务器方法(2014-09-24)
- ·MySQL5.6 Using a password on the command line interface can be insecure(2014-09-24)
- ·mysql 5.5与5.6 timestamp 字段 DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIM(2014-09-27)
- ·Mysql5.5 InnoDB存储引擎设置(2014-09-28)
- ·mysql5.6设置sql_mode方法详解(2014-09-28)
- ·MYSQL开启慢查询与mysql5.6开启慢查询出错(2014-10-01)
- ·MySQL5.5默认编码的设置修改方法详解(2014-10-02)
- ·Linux中MySql5手动安装方法详解(2014-10-04)
- ·linux中mysql 5.5二进制文件安装详解(2014-10-04)
- ·mysql5存储过程入门创建,删除,调用详解(2014-10-07)
- ·MySql 5.X创建用户并授权方法(2014-10-08)
- ·mysql5 插入中文乱码问题(2014-10-08)
- ·mysql5.5提示Could not initialize master info structure(2014-10-09)
- ·mysql5 sql-mode 引起的错误解决办法(2014-10-10)
- ·MySQL5的存储过程详细实例(2014-10-13)
- ·php调用mysql5存储过程方法(2014-10-14)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)