溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

mysql高可用

發(fā)布時(shí)間:2020-08-22 06:50:49 來源:網(wǎng)絡(luò) 閱讀:407 作者:左客 欄目:MySQL數(shù)據(jù)庫

1 mmm架構(gòu)

mysql高可用集群    (mysql MMM   +  mysql主從同步)

 

1、公共配置

配置固定物理Ip地址   237   42   101   102    77

所有機(jī)器之間彼此可以ping

服務(wù)器237   42   101   102 運(yùn)行mysql數(shù)據(jù)庫服務(wù)、

配置YUM

 

在所有服務(wù)器237   42   101   102    77上安裝

rpm  -q  perl  ||  yum  -y  perl

yum  -y  install  perl-*

 

 

2、配置主主結(jié)構(gòu) (237   42

 

237的配置

mysql> grant  replication slave  on  *.* to  slaveuser@"172.40.7.42" identified by "123";

 

[root@www mysql]# cat /etc/my.cnf

[mysqld]

log-bin=master237

server_id=237

:wq

[root@www mysql]#  service  mysql  restart

 

 

42的配置

mysql> grant  replication slave  on  *.* to  slaveuser@"%" 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的從數(shù)據(jù)庫服務(wù)器

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 的從數(shù)據(jù)庫服務(wù)器

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;

 

 

在所有服務(wù)器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

 

 

在所有數(shù)據(jù)庫服務(wù)器上授權(quán)

grant  replication client,process,super  on *.*  to   agent@"%"   identified by  "123456";

 

grant  replication  client  on *.*  to      monitor@"%"   identified by "123456";

----------------------------------------------------------------

mysql-mmm簡介?

監(jiān)控、故障轉(zhuǎn)移     (perl 腳本程序)

 

 

軟件安裝后提供2種進(jìn)程

mmm-monitor   監(jiān)控進(jìn)程

                              運(yùn)行在監(jiān)控端 77

                             負(fù)責(zé)所有的監(jiān)控工作的監(jiān)控守護(hù)進(jìn)

程,決定故                             障節(jié)點(diǎn)的移除或恢復(fù)

 

mmm-agent       代理進(jìn)程

           運(yùn)行在被監(jiān)控端237  42   101   102

                             提供簡單遠(yuǎn)程服務(wù)集、提供給

 監(jiān)控節(jié)點(diǎn)

 

vip   172.40.7.100

 

vip   172.40.7.110

            172.40.7.120

 

 

       

文檔詳解   

 

mmm_mon.conf     mmm-monitor監(jiān)控進(jìn)程的主配置文件

                                  只需要在監(jiān)控服務(wù)器上有

 

mmm_agent.conf   mmm-agent代理進(jìn)程的主配置文件

                                  只需要在數(shù)據(jù)庫服務(wù)器上有

[root@www 桌面]# cat /etc/mysql-mmm/mmm_agent.conf

include  mmm_common.conf

this  master237

[root@www 桌面]#

 

 

mmm_common.conf   所有服務(wù)器上都要有的文件。

                                       定義服務(wù)器角色的配置文件

 

 

4 啟動(dòng)服務(wù)

4.1  啟動(dòng)mmm_agent進(jìn)程(101  102   42    237)

日志文件  /var/log/mysql-mmm/mmm_agentd.log

 

cd  mysql-mmm

sh  a.sh

 

[root@www 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

[root@www mysql-mmm]#

 

4.2  啟動(dòng)mmm_mon進(jìn)程(77)

/var/log/mysql-mmm/mmm_mond.log 日志文件

cd  mysql-mmm

sh  a.sh

# /etc/init.d/mysql-mmm-monitor start

# mmm_control   help

[root@svr5 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:

 

[root@svr5 mysql-mmm]#

[root@svr5 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地址的命令


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI