mysql搭建mha
时间: 2023-08-16 08:13:53 浏览: 124
要在MySQL上搭建MHA(MySQL Master High Availability),需要执行以下步骤:
1. 在所有MySQL服务器上创建一个MHA管理账号,并赋予其所有权限。在MySQL命令行中执行以下语句:
```
mysql> grant all privileges on *.* to 'root'@'192.168.1.%' identified by '123456';
mysql> flush privileges;
```
如果是在slave服务器上安装的manager,则需要创建一个以本机hostname名连接的账号,以确保masterha_check_repl测试通过。在MySQL命令行中执行以下语句:
```
GRANT ALL PRIVILEGES ON *.* TO 'root'@'master(主机名)' IDENTIFIED BY '123456';
```
2. 安装MHA软件包。在MHA节点服务器上执行以下命令:
```
cd /opt
tar zxvf mha4mysql-manager-0.57.tar.gz
cd mha4mysql-manager-0.57
perl Makefile.PL
make && make install
```
3. 在manager节点上测试MySQL主从连接情况。在命令行中执行以下命令:
```
masterha_check_repl -conf=/etc/masterha/app1.cnf
```
如果最后出现"MySQL Replication Health is OK"字样,说明连接正常。
请注意,以上步骤仅为搭建MHA的基本步骤,具体操作可能会因环境和需求而有所不同。建议参考MHA的官方文档或相关教程进行详细配置和操作。
#### 引用[.reference_title]
- *1* [MySQL高可用架构之基于MHA的搭建](https://blog.csdn.net/weixin_34137799/article/details/93427145)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [MySQL——MHA搭建](https://blog.csdn.net/qq_45773660/article/details/118445729)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文