MySQL MHA环境搭建
2,识别含有最新更新的slave;
3,应用差异的中继日志(relay log)到其他的slave;
4,应用从master保存的二进制日志文事件;
5,提升一个slave为新的master;
6,是其他的slave连接新的master进行复制;
MHA环境搭建:
manager节点:192.168.125.210
node1节点:192.168.125.200
node2节点:192.168.125.201
node3节点:192.168.125.202
[root@localhost ~]# ssh-keygen -t rsa -P '' //生成公钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:LzSIfKtqa4fh70k5xAreOULBySucDWzUsHf4+6PlHmQ root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| oo |
|= o.. |
| X o . |
|o Boo. . |
|o= .=.oES |
|+.oo.o+o o |
| +.*+..o. . |
| *.o++... |
| oo*=.o+. |
+----[SHA256]-----+
[root@localhost ~]# cat .ssh/id_rsa.pub > .ssh/authorized_keys //导入到本地认证文件
[root@localhost ~]# chmod go= .ssh/authorized_keys
[root@localhost ~]# scp .ssh/id_rsa .ssh/authorized_keys 192.168.125.200:/root/.ssh/ //SCP到各个节点就可以互相访问了。
[root@localhost ~]# scp -p .ssh/id_rsa .ssh/authorized_keys 192.168.125.201:/root/.ssh/
[root@localhost ~]# scp -p .ssh/id_rsa .ssh/authorized_keys 192.168.125.202:/root/.ssh/
下载地址:
https://downloads.mariadb.com/MHA/mha4mysql-manager-0.55-0.el6.noarch.rpm
https://downloads.mariadb.com/MHA/mha4mysql-node-0.54-0.el6.noarch.rpm
root@manager ~]# cat /etc/masterha/app1.cnf
[server default]
manager_workdir=/etc/masterha/app1 #配置manager的工作目录
manager_log=/etc/masterha/app1/manager.log #设置manager的日志
master_binlog_dir=/var/lib/mysql/ #设置master保存binlog的位置,以便MHA可以找到master的日志
user=mhaadmin #设置监控用的root权限账号,每个节点需要创建。
password=123123 #密码
ssh_user=root #设置ssh的登陆用户名。
repl_user=glq #设置复制环境中的复制用户名。
repl_password=123123 #密码
[server1]
hostname=192.168.125.200
port=3306
#master_binlog_dir=/var/lib64/mysql
candidate_master=1 #设置为候选master,即使这个库不是集群中最新的slave,也会选择为master。
#check_repl_delay=0 #默认情况下如果一个slave落后master 100M的relay logs的话,MHA将不会选择该slave作为一个新的master,因为对于这个slave的恢复需要花费很长时间,通过设置check_repl_delay=0,MHA触发切换在选择一个新的master的时候将会忽略复制延时,这个参数对于设置了candidate_master=1的主机非常有用,因为这个候选主在切换的过程中一定是新的master
[server2]
hostname=192.168.125.201
port=3306
#master_binlog_dir=/var/lib64/mysql
candidate_master=1
[server3]
hostname=192.168.125.202
port=3306
#master_binlog_dir=/var/lib64/mysql
#ignore_fail=1
#no_master=1
[root@manager ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf #测试ssh连接是否正常。
Wed Mar 14 15:44:16 2018 - [info] All SSH connection tests passed successfully.
[root@manager ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf #测试主从配置是否正常
Wed Mar 14 15:45:09 2018 - [info]
192.168.125.200 (current master)
+--192.168.125.201
+--192.168.125.202
Wed Mar 14 15:45:09 2018 - [info] ok.
Wed Mar 14 15:45:09 2018 - [info] Checking replication health on 192.168.125.202..
Wed Mar 14 15:45:09 2018 - [info] ok.
Wed Mar 14 15:45:09 2018 - [warning] master_ip_failover_script is not defined.
Wed Mar 14 15:45:09 2018 - [warning] shutdown_script is not defined.
Wed Mar 14 15:45:09 2018 - [info] Got exit code 0 (Not master dead).
[root@manager ~]# masterha_manager --conf=/etc/masterha/app1.cnf
Wed Mar 14 15:46:24 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Mar 14 15:46:24 2018 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Wed Mar 14 15:46:24 2018 - [info] Reading server configurations from /etc/masterha/app1.cnf..
[root@manager ~]# masterha_manager --conf=/etc/masterha/app1.cnf
Wed Mar 14 15:46:24 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Mar 14 15:46:24 2018 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Wed Mar 14 15:46:24 2018 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Creating /var/tmp if not exists.. ok. #检测到master不存在
Checking output directory is accessible or not..
ok.
Binlog found at /var/lib/mysql/, up to master-bin.000003 #发现二进制日志。
Wed Mar 14 15:47:08 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Mar 14 15:47:08 2018 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Wed Mar 14 15:47:08 2018 - [info] Reading server configurations from /etc/masterha/app1.cnf..
[root@manager ~]# nohup master_manager --conf=/etc/masterha/app1.cnf >/etc/masterha/app1/manager.log 2>&1 &
[1] 2832
[root@manager ~]# masterha_master_switch --master_state=alive --conf=/etc/masterha/app1.cnf --orig_master_is_new_slave --running_updates_limit=3600 --interactive=0
Wed Mar 14 15:52:45 2018 - [info]
Wed Mar 14 15:52:45 2018 - [info] * Phase 5: New master cleanup phase..
Wed Mar 14 15:52:45 2018 - [info]
Wed Mar 14 15:52:45 2018 - [info] 192.168.125.201: Resetting slave info succeeded.
Wed Mar 14 15:52:45 2018 - [info] Switching master to 192.168.125.201(192.168.125.201:3306) completed successfully.
[root@manager ~]# masterha_stop --conf=/etc/masterha/app1.cnf
MySQL MHA环境搭建的更多相关文章
- Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程
这篇文章主要介绍了Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程,需要的朋友可以参考下 准备篇 一.环境说明: 操作系统:Windows Server 201 ...
- ubuntu下mysql的环境搭建及使用
ubuntu下mysql的环境搭建及使用 环境安装 使用如下命令分别安装服务端程序,客户端程序,及客户端依赖库 sudo apt-get install mysql-server sudo apt-g ...
- CentOS6.8下MySQL MHA架构搭建笔记
转载请注明出处,本文地址:http://www.cnblogs.com/ajiangg/p/6552855.html 以下是CentOS6.8下MySQL MHA架构搭建笔记 IP资源规划: 192. ...
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建) 具体案例:局域网内有两台主机,一台Linux.一台Windows,现在需要配置一台Cacti监控服务器对这两台 ...
- Lamp(linux+apache+mysql+php)环境搭建
Lamp(linux+apache+mysql+php)环境搭建 .安装apache2:sudo apt-get installapache2 安装完毕后.执行例如以下命令重新启动apache:sud ...
- mysql MHA架构搭建过程
[环境介绍] 系统环境:Red Hat Enterprise Linux 7 + 5.7.18 + MHA version 0.57 系统 IP 主机名 备注 版本 xx系统 192.168.142. ...
- windows下PHP+Mysql+Apache环境搭建
Apache版本:httpd-2.2.22-win32-x86-openssl- 下载地址:http://pan.baidu.com/s/1sjuL4RV PHP版 ...
- WAMP(Windows+Apache+Mysql+PHP)环境搭建
学习PHP已经有一段时间,一直没有写过关于开发环境搭建的笔记,现在补上吧,因为安装配置的步骤记得不是很清楚,借鉴了一些别人的经验,总结如下: 首先去官方网站下载各个软件,下载需要的版本: Apache ...
- Apache+PHP+MySQL+phpMyAdmin环境搭建
最近在学习web服务端开发,一开始是使用wamp的,后来决定自己完整配置一下环境,并把整个过程记录下来.其中,Apache是服务器,php是用来编写服务端的语言,MySQL作为数据库,phpMyAdm ...
随机推荐
- CF 459A && 459B && 459C && 459D && 459E
http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...
- struts2.1.6 action 01
目录(?)[-] 安装与设置 HelloWorld 常见问题 Action struts 官网下载 http://www.apache.org/ http://struts.apache.org/ ...
- vector中erase用法注意事项
以前就发现了vector中的erase方法有些诡异(^_^),稍不注意,就会出错.今天又一次遇到了,就索性总结一下,尤其是在循环体中用erase时,由于vector.begin() 和vector.e ...
- SQL 递归找查所有子节点及所有父节
在SQL的树型结构中,很多时候,知道某一节点的值,需要查找该节点的所有子节点(包括多级)的功能,这时就需要用到如下的用户自定义函数. 表结构如下: ID int Dep_Type int Dep_Co ...
- Translating Skills(1)
本文是参加公司英语翻译培训的课程.做此记录,以防忘记. ------------------------------------------------------------------------ ...
- Android Mms专题之:Mms源码结构
从软件的功能角度来讲,Mms分为对话列表,消息列表,短信编辑,彩信编辑,短信显示,彩信显示和配置. 从实现的角度来看,它分为GUI展示层,发送/接收,彩信解析,彩信附件,信息数据等,这些分类对应着源码 ...
- AVAudioPlayer播放音频文件时没声音
AVAudioPlayer播放一个mp3文件时,居然没有声音.mp3文件是放在工程里面的,路径没有错误但就是死活没有声音. func playSound() { let notifyUrl = NSB ...
- web测试小结
今年5月份开始接触web测试,经过大半年的测试及学习,简单总结下 测试过程: 1.需求理解 2.测试策略.方案.用例编写及评审 3.测试环境搭建 4.测试执行 5.bug提单.问题跟踪 6.回归测试 ...
- C++ 和 Java 对类继承的差异
#include <iostream> using namespace std; class Base { public: int i; Base() { i = ; fun(); } v ...
- bisect
# 二分查找算法 import bisect farm = sorted(['haystack', 'needle', 'cow', 'pig']) # ['cow', 'haystack', 'ne ...