mysql高可用
1 mmm架構
mysql高可用集群 (mysql MMM + mysql主從同步)
1、公共配置
配置固定物理Ip地址 237 42 101 102 77
所有機器之間彼此可以ping通
服務器237 42 101 102 運行mysql數據庫服務、
配置YUM源
在所有服務器237 42 101 102 77上安裝
rpm -q perl || yum -y perl
yum -y install perl-*
2、配置主主結構 (237 42)
237的配置
mysql> grant replication slave on *.* to [email protected]"172.40.7.42" identified by "123";
[[email protected] mysql]# cat /etc/my.cnf
[mysqld]
log-bin=master237
server_id=237
:wq
[[email protected] mysql]# service mysql restart
42的配置
mysql> grant replication slave on *.* to [email protected]"%" identified by "123";
vim /etc/my.cnf
[mysqld]
server_id=42
log-bin=master42
log_slave_updates
:wq
service mysql restart
mysql -uroot -p123
mysql> change master to master_host="172.40.7.237",master_user="slaveuser",master_password="123",master_log_file="master237.000001",master_log_pos=120;
mysql> start slave;
在237上把自己配置為42的從數據庫服務器
change master to master_host="172.40.7.42",master_user="slaveuser",master_password="123",master_log_file="master42.000001",master_log_pos=120;
mysql> start slave;
3、配置 101 和 102 做42 的從數據庫服務器
vim /etc/my.cnf
[mysqld]
server_id=101
:wq
service mysql restart
mysql> change master to master_host="172.40.7.42",master_user="slaveuser",master_password="123",master_log_file="master42.000001",master_log_pos=120;
mysql> start slave;
在所有服務器237 42 101 102 77上安裝mysql-mmm軟件
unzip mysql-mmm.zip
cd mysql-mmm
tar -zxvf mysql-mmm-2.2.1.tar.gz
cd mysql-mmm-2.2.1
make install
ls /etc/mysql-mmm/*.conf
在所有數據庫服務器上授權
grant replication client,process,super on *.* to [email protected]"%" identified by "123456";
grant replication client on *.* to [email protected]"%" identified by "123456";
----------------------------------------------------------------
mysql-mmm簡介?
監控、故障轉移 (perl 腳本程序)
軟件安裝後提供2種進程
mmm-monitor 監控進程
運行在監控端 77
負責所有的監控工作的監控守護進
程,決定故 障節點的移除或恢復
mmm-agent 代理進程
運行在被監控端237 42 101 102
提供簡單遠程服務集、提供給
監控節點
寫vip 172.40.7.100
讀vip 172.40.7.110
172.40.7.120
文檔詳解
mmm_mon.conf mmm-monitor監控進程的主配置文件
只需要在監控服務器上有
mmm_agent.conf mmm-agent代理進程的主配置文件
只需要在數據庫服務器上有
[[email protected] 桌面]# cat /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this master237
[[email protected] 桌面]#
mmm_common.conf 所有服務器上都要有的文件。
定義服務器角色的配置文件
4 啟動服務
4.1 啟動mmm_agent進程(101 102 42 237)
日誌文件 /var/log/mysql-mmm/mmm_agentd.log
cd mysql-mmm
sh a.sh
[[email protected] mysql-mmm]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd‘
Daemon pid: ‘/var/run/mmm_agentd.pid‘
Starting MMM Agent daemon... Ok
[[email protected] mysql-mmm]#
4.2 啟動mmm_mon進程(77)
/var/log/mysql-mmm/mmm_mond.log 日誌文件
cd mysql-mmm
sh a.sh
# /etc/init.d/mysql-mmm-monitor start
# mmm_control help
[[email protected] mysql-mmm]# mmm_control show
master237(172.40.7.237) master/AWAITING_RECOVERY. Roles:
master42(172.40.7.42) master/AWAITING_RECOVERY. Roles:
slave101(172.40.7.101) slave/AWAITING_RECOVERY. Roles:
slave102(172.40.7.102) slave/AWAITING_RECOVERY. Roles:
[[email protected] mysql-mmm]#
[[email protected] mysql-mmm]# mmm_control show
master237(172.40.7.237) master/ONLINE. Roles: writer(172.40.7.100)
master42(172.40.7.42) master/AWAITING_RECOVERY. Roles:
slave101(172.40.7.101) slave/AWAITING_RECOVERY. Roles:
slave102(172.40.7.102) slave/AWAITING_RECOVERY. Roles:
mmm_control set_online slave101
安裝獲取虛擬ip地址的程序
yum -y install gcc gcc-c++
gunzip Net-ARP-1.0.8.tgz
79 tar -xvf Net-ARP-1.0.8.tar
80 cd Net-ARP-1.0.8
81 rpm -q gcc
82 yum -y install gcc gcc-c++
83 perl Makefile.PL
84 make
85 make install
86 ip addr show 查看虛擬ip地址的命令
本文出自 “13262050” 博客,請務必保留此出處http://13272050.blog.51cto.com/13262050/1962627
mysql高可用