mysql HA 方案(2):MHA
以下摘錄自(http://code.google.com/p/mysql-master-ha/wiki/Overview)
MHA performs automating master failover and slave promotion with minimal downtime, usually within 10-30 seconds. MHA prevents replication consistency problems and saves on expenses of having to acquire additional servers. All this with zero performance degradation, no complexity (easy-to-install) and requiring no change to existing deployments.
MHA also provides scheduled online master switching, safely changing the currently running master to a new master, within mere seconds (0.5-2 seconds) of downtime (blocking writes only).
MHA provides the following functionality, and can be useful in many deployments in which high availability, data integrity and near non-stop master maintenance are required.
。。。。。。。。。。
應用要考慮的問題:
應用架構要考慮兩個問題(在一個特定的叢集下):
1 自動識別master和slave的問題(master機器可能會切換)
2 負載均衡的問題(我們可以定義大概的讀寫比例,每臺機器可承擔的負載比例,當有機器離開叢集時,需要考慮這個)
比如說下面的場景:
From:
db-181 (current master)
+–db-183
+–db-184
To:
db-183 (new master)
+–db-184
這個方案需要機器至少4臺(1 master+ 3 slaves(其中一個專門作為備份))。
以下是我的測試過程:
準備,機器安排,db-182為管理機:
db-181 (current master)
+--db-183
+--db-184
準備工作,配置ssh:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh db-181 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh db-181 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh db-183 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh db-183 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh db-184 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh db-184 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys db-181:~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys db-183:~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys db-184:~/.ssh/authorized_keys
1 所有機器安裝DBD-mysql-4.020
mkdir /tmp/mysql-static
cp /usr/lib64/mysql/*.a /tmp/mysql-static
perl Makefile.PL --libs="-L/tmp/mysql-static -lmysqlclient"
make
make test
make install
2 所有機器Installing MHA Node
You can also install MHA Node from source.
## Install DBD::mysql if not installed
tar -zxf mha4mysql-node-0.53.tar.gz
cd mha4mysql-node-0.53
perl Makefile.PL
make
make install
3 管理機Installing MHA Manager
## Install DBD::mysql if not installed
rpm -ivh perl-Config-Tiny-2.12-1.el5.rf.noarch.rpm
rpm -ivh perl-Params-Validate-0.95-1.el5.rf.x86_64.rpm
rpm -ivh perl-Log-Dispatch-2.26-1.el5.rf.noarch.rpm
rpm -ivh perl-Parallel-ForkManager-0.7.5-2.2.el5.rf.noarch.rpm
tar -zxf mha4mysql-manager-0.53.tar.gz
cd mha4mysql-manager-0.53
perl Makefile.PL
make
make install
4 配置檔案
[server default]
manager_workdir=/masterha/app1
manager_log=/masterha/app1/manager.log
user=root
password=123zzz
ssh_user=root
repl_user=rep
repl_password=123zzz
ping_interval=1
[server1]
hostname=db-181
master_binlog_dir=/data/mysql
candidate_master=1
[server2]
hostname=db-183
master_binlog_dir=/data/mysql
candidate_master=1
[server3]
hostname=db-184
master_binlog_dir=/data/mysql
5 root 的許可權及MASTER_HOST(vip待試驗)
CHANGE MASTER TO
MASTER_HOST='192.168.99.181',
MASTER_USER='rep',
MASTER_PASSWORD='xxx',
MASTER_LOG_FILE='mysql-bin.000004',
MASTER_LOG_POS=107;
db-181
mysql> grant all privileges on *.* to 'root'@'db-182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'db-181' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'192.168.99.182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
db-183
mysql> grant all privileges on *.* to 'root'@'192.168.99.182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'db-182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'db-183' identified by 'xxx';
Query OK, 0 rows affected (0.01 sec)
db-184
mysql> grant all privileges on *.* to 'root'@'192.168.99.182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'db-182' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'db-184' identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-721331/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql HA 方案(3):MHAMySql
- mysql HA方案MySql
- mysql HA 方案(1)MySql
- MySQL MHA高可用方案MySql
- MySQL-HA MHA(Master High Availability manager)搭建手冊MySqlASTAI
- MySQL高可用方案MHA介紹MySql
- MySQL官方的HA切換方案MySql
- 【MySQL】Consul+MHA高考用方案MySql
- 【MHA】mysql高可用之MHAMySql
- Mysql MHA部署-04MHA配置MySql
- Openstack的HA解決方案【mysql叢集配置】MySql
- mysql之MHAMySql
- MySQL MHA配置MySql
- MySQL MHA部署 Part 5 MHA部署指南MySql
- mysql-HAMySql
- 【Mysql】MHA的原理MySql
- MySQL MHA介紹MySql
- 【MySQL】MHA安裝MySql
- Mysql MHA部署-03MHA軟體安裝MySql
- MySQL高可用方案MHA線上切換的步驟及原理MySql
- MySQL高可用方案MHA的一些總結和思考MySql
- Mysql 5.7 MHA 高可用MySql
- MySQL MHA部署實戰MySql
- MySQL MHA原始碼解析MySql原始碼
- mysql5.7MHA配置MySql
- MySQL MHA部署 Part 6 MHA故障轉移測試MySql
- MySQL MHA部署 Part 7 MHA手動切換測試MySql
- MYSQL + MHA +keepalive + VIP安裝配置(二)--MHA的配置MySql
- 【Mysql】MHA配置虛擬ipMySql
- Mysql MHA部署-05故障轉移MySql
- 基於 MHA 高可用的 MySQLMySql
- MySQL MHA詳細搭建過程MySql
- mysql高可用架構MHA搭建MySql架構
- mysql MHA 高可用架構部署MySql架構
- 【MYSQL】MHA引數列表說明MySql
- MySQL MHA部署與測試-下篇MySql
- 在Linux上實現DB2雙機HA完整方案(轉)LinuxDB2
- MySQL MHA資訊的收集【Filebeat+logstash+MySQL】MySql