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 ...
随机推荐
- EhLib TitleButton SVisibleColumnsEh = '错误的列';
unit EhLibConsts; interface resourcestring SClearSelectedCellsEh = '清除选择的单元?'; SInvalidTextFormatEh ...
- C++中的数据存储方式自动存储、静态存储和动态存储
C++中变量存储方式有三种,自动存储,静态存储,动态存储 自动存储简单意义上就是在函数内不用任何关键字直接定义的变量,它在函数被调用时被创建,在函数退出时自动消失, 静态存储顾名思义就是在程序的整个运 ...
- Java实现责任链模式
责任链模式: 将接受者对象连成一条链,并在该链上传递请求,直到一个几首这对象处理它.通过让更多对象有机会处理请求,避免了请求发送者和接受者之间的耦合. 责任链模式的优缺点: 优点:高内聚,低耦合.业务 ...
- 内网dns劫持
进行内网的dns劫持呢 ---> 我们需要用到ettercap 和ettercap内置的工具dns_spoof 1.我们需要开启ip转发 echo >/proc/sys/net/ipv4/ ...
- Linux下mysql操作
1.linux下MYSQL的启动与访问 http://www.cnblogs.com/hunter007/articles/2251795.html 2.linux下mysql基本的操作 http:/ ...
- 7.3 5种IO模型与IO复用
5种IO模型分别如下: 1.阻塞IO模型 当上层应用app1调用recv系统调用时,如果对等方没有发送数据(缓冲区没有数据),上层app1将阻塞(默认行为,被linux内核阻塞). 当对等方发送了数据 ...
- parseConf(配置文件解析器)
/****************************************************************************** * * parseConf(配置文件解析 ...
- git的使用基础
/*游戏或者运动才能让我短暂的忘记心痛,现如今感觉学习比游戏和运动还重要——曾少锋*/ 在Git-Bash中配置自己的名字和Email: git config --global user.name & ...
- python笔记-6(import导入、time/datetime/random/os/sys模块)
一.了解模块导入的基本知识 此部分此处不展开细说import导入,仅写几个点目前的认知即可.其它内容待日后有深入理解了再来细说 1.import可以导入的两种不同的内容 1.1 *.py文件结尾的文件 ...
- (1)json和pickle序列化模块
json 和pickle 模块 json和pickle模块下都有4个功能 dumps <---> loads (序列化 <--->反序列化) dump <---> ...