溫馨提示×

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

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

MySQL數(shù)據(jù)管理7

發(fā)布時(shí)間:2020-07-14 19:41:18 來源:網(wǎng)絡(luò) 閱讀:498 作者:hj_1314wgn 欄目:MySQL數(shù)據(jù)庫

部署mysql高可集群 mysql-mmm + mysql主從同步

環(huán)境準(zhǔn)備  (四臺(tái)數(shù)據(jù)庫服務(wù)器 12   11    10    9 )

systemctl  stop firewalld

setenforce  0

配置YUM源

yum -y  install  gcc  gcc-c++   perl-*

systemctl   start  mysqld

++++++++++++++++++++++++++++++

一 配置mysql主從同步(12   11    10    9 )

9 和  10   配置為主主結(jié)構(gòu)

12  和  11  配置為 10 的從數(shù)據(jù)庫服務(wù)器

要求:客戶端訪問數(shù)據(jù)庫服務(wù)器9時(shí) 創(chuàng)建的庫表記錄 在 11 和12 


上也要有。


用戶授權(quán):

1 有同步數(shù)據(jù)權(quán)限的用戶(9 和 10)

grant  replication  slave  on  *.*   to  slaveuser@"%"  


identified by "123456";

把9 和  10   配置為主主結(jié)構(gòu)

9

vim /etc/my.cnf

[mysqld]

server_id=9

log_bin=master9

binlog_format="mixed"

:wq

10

vim /etc/my.cnf

[mysqld]

server_id=10

log_bin=master10

binlog_format="mixed"

log_slave_updates

:wq

9

mysql> change master  to  


master_host="192.168.4.10",master_user="slaveuser",


master_password="123456",master_log_file="master10


.000001",master_log_pos=154;

mysql> show slave status\G;



10

mysql> change master  to  


master_host="192.168.4.9",master_user="slaveuser",m


aster_password="123456",master_log_file="master9.00


0001",master_log_pos=154;

mysql> show slave status\G;



12  和  11  配置為 10 的從數(shù)據(jù)庫服務(wù)器


11

vim /etc/my.cnf

[mysqld]

server_id=11

:wq


12

vim /etc/my.cnf

[mysqld]

server_id=12

:wq


11 和 12 

mysql> change master  to  


master_host="192.168.4.10",master_user="slaveuser",


master_password="123456",master_log_file="master10


.000001",master_log_pos=154;

mysql> show slave status\G;


測(cè)試注冊(cè)同步配置:

9

mysql> create  database gamedb;

mysql>grant all on gamedb.*  to  stu10@"%" identified 


by "123456";


254

mysql  -h292.168.4.9  -ustu10  -p123456  gamedb

mysql> create  table  t1(id int);

mysql> insert into  t1  values(100);

在其他3臺(tái)數(shù)據(jù)庫服務(wù)器上能夠查看記錄和授權(quán)用戶

select  user,host  from mysql.user  where  user="stu10";

select  * from gamedb.t1;


二、配置mysql-mmm

mysql-mmm軟件介紹

mmm_monitor 監(jiān)控服務(wù) 運(yùn)行在監(jiān)控端

mmm_agentd  代理服務(wù)  運(yùn)行在數(shù)據(jù)庫服務(wù)器上


ip規(guī)劃

寫vip地址 192.168.4.100 (9  、10)

讀vip地址 192.168.4.101/102 (11  、12)


配置監(jiān)控服務(wù)器8

systemctl  stop firewalld

setenforce  0

配置YUM源

yum -y  install  gcc  gcc-c++   perl-*


裝包 (12  、 11   、 10 、 9 、8)

5  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/

mmm_mon.conf   mmm_monitor 監(jiān)控服務(wù)的主配置文件

mmm_agent.conf   mmm_agentd  代理服務(wù)

mmm_common.conf  公共文件( 監(jiān)控服務(wù)器和數(shù)據(jù)庫服務(wù)器


都要有)


修改配置文件


1、修改4臺(tái)數(shù)據(jù)庫服務(wù)器上mmm_agentd  代理服務(wù)的主配置


文件

vim  /etc/mysqlmmm/mmm_agent.conf 

include mmm_common.conf

this 主機(jī)名  #自定義

:wq


2 修改監(jiān)控服務(wù)器上的mmm_monitor 監(jiān)控服務(wù)的主配置文件


3 修改公共文件mmm_common.conf  公共文件


4 在4臺(tái)數(shù)據(jù)庫服務(wù)器上根據(jù)mmm_common.conf配置文件中


的設(shè)置添加對(duì)應(yīng)的授權(quán)用戶。


mysql>grant  replication  client  on *.*  to      


monitor@"%"   identified by    "123456";


mysql>grant  replication client,process,super on *.*  to    


 agent@“%" identified by   "123456";


四、啟動(dòng)服務(wù)


4.2 啟動(dòng)數(shù)據(jù)庫服務(wù)器上agnetd服務(wù)

2  rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm 

  4  tar -zxvf Algorithm-Diff-1.1902.tar.gz 

  6  cd Algorithm-Diff-1.1902/

  8  perl Makefile.PL

  9  make

  10  make install

   13  tar -zxvf Proc-Daemon-0.03.tar.gz 

   14  cd Proc-Daemon-0.03/

   16  perl Makefile.PL 

   17  make

   18  make install

21  gunzip Net-ARP-1.0.8.tgz 

23  tar -xvf Net-ARP-1.0.8.tar 

25  cd Net-ARP-1.0.8/

27  perl Makefile.PL 

28  make 

29  make install

31  /etc/init.d/mysql-mmm-agent status

 32  /etc/init.d/mysql-mmm-agent start

 33  netstat -utnalp  | grep :9989

ls /var/log/mysql-mmm/mmm_agentd.log


4.3 啟動(dòng)監(jiān)控服務(wù)器上monitor服務(wù)

  2  rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm 

  4  tar -zxvf Algorithm-Diff-1.1902.tar.gz 

  6  cd Algorithm-Diff-1.1902/

  8  perl Makefile.PL

  9  make

  10  make install

   13  tar -zxvf Proc-Daemon-0.03.tar.gz 

   14  cd Proc-Daemon-0.03/

   16  perl Makefile.PL 

   17  make

   18  make install

  27  /etc/init.d/mysql-mmm-monitor status

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

   29  netstat -utnalp  | grep :9988

   30  ls /var/log/mysql-mmm/mmm_mond.log 


登錄監(jiān)控服務(wù)器8的管理頁面查看數(shù)據(jù)庫服務(wù)器的狀態(tài)

# mmm_control help

# mmm_control show

# mmm_control  set_online  master9

# mmm_control  set_online  master10

# mmm_control  set_online  master11

# mmm_control  set_online  master12

# mmm_control show


在數(shù)據(jù)庫服務(wù)器本機(jī)查看獲取的虛擬ip地址

#ip  addr  show  | grep  192.168.4.100

  

測(cè)試配置

254客戶端訪問

ping  192.168.4.100

mysql  -h292.168.4.100   -ustu10  -p123456   gamedb


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

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

AI