溫馨提示×

溫馨提示×

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

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

Mysql-mmm集群部署

發布時間:2020-06-02 08:51:55 來源:網絡 閱讀:417 作者:劉真圓 欄目:MySQL數據庫

  90主 <----------> 91主

   |

   |

   |

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

   | |

   | |

   | |

  92從 93從    


systemctl stop firewalld.service ;systemctl disable firewalld.service ;setenforce 0



MySQL-mmm

一、配置主從同步結構

1)配置主從同步

90: 用戶配置 啟用 binlog 日志 重啟數據庫服務 指定主數據庫服務器信息

91: 用戶配置 啟用 binlog 日志 允許級聯復制 重啟數據庫服務 指定主數據庫服務器信息

[root@pc91 ~]# vim /etc/my.cnf

[mysqld]

validate_password_policy=0

validate_password_length=6

server_id=91

log-bin=master91

binlog_format="mixed"

log_slave_updates


-> grant replication slave on *.* to slaveuser@"%" identified by '123456';


-> change master to

-> master_host="主服務器 ip 地址",

-> master_user="授權用戶名",

-> master_password="授權用戶密碼",

-> master_log_file="主服務器正在使用的 binlog 日志",

-> master_log_pos=主服務當前的偏移量;

#指定主服務器


2)配置一主多從結構

92: 指定server_id 重啟數據庫服務 指定主數據庫服務器信息

93: 指定server_id 重啟數據庫服務 指定主數據庫服務器信息


[root@pc92 ~]# vim /etc/my.cnf

[mysqld]

validate_password_policy=0

validate_password_length=6

server_id=92


-> change master to

-> master_host="主服務器 ip 地址",

-> master_user="授權用戶名",

-> master_password="授權用戶密碼",

-> master_log_file="主服務器正在使用的 binlog 日志",

-> master_log_pos=主服務當前的偏移量;

#指定主服務器


mysql> show master status\G;


mysql> start slave;


mysql> show slave status\G;


3)在客戶端測試主從同步配置

a、 

在90主機上添加訪問數據的用戶guser,能夠在其他3臺主機上也有相同的授權用戶

-> grant select  on gamedb.* to guser@'%' identified by '123456';


b、

在客戶端主機94 使用授權用戶guser 連接14服務器,產生的新數據在他3臺主機上也有

-> select user,host from mysql.user where user="guser";


二、配置mysql-mmm

1)mysql-mmm 介紹 

監控服務: 運行在管理節點  用來監控數據節點

代理服務: 運行在數據節點  用來提供系統給監控主機


2)在所有主機上安裝mysql-mmm軟件(90-94)

#yum  -y  install   perl-*

#unzip  mysql-mmm.zip

#cd mysql-mmm

#make  install

#ls  /etc/mysql-mmm/*.conf


3)修改配置文件

a  修改數據節點代理服務配置文件  (90 91 92 93) 

vim  /etc/mysql-mmm/mmm_agent.conf

include  mmm_command.conf

this  自定義名稱


b  修改管理節點監控服務的配置文件 (94)

vim /etc/mysql-mmm/mmm_mon.conf

>

include mmm_common.conf


<monitor>

        ip                      192.168.4.94 //本機IP

        pid_path                                /var/run/mmm_mond.pid

        bin_path                                /usr/lib/mysql-mmm/

        status_path                             /var/lib/misc/mmm_mond.status

        ping_ips        192.168.4.90, 192.168.4.91, 192.168.4.92, 192.168.4.93 //監控的服務器IP

</monitor>


<host default>

        monitor_user                    monitor //監控狀態時使用的用戶名

        monitor_password                123456 //監控狀態時使用的用戶密碼

</host>

>


c 修改公共文件 

vim /etc/mysql-mmm/mmm_command.conf

>

active_master_role      writer



<host default>

        cluster_interface               eth0


        pid_path                                /var/run/mmm_agentd.pid

        bin_path                                /usr/lib/mysql-mmm/


    replication_user        slaveuser //設置主從同步的用戶

    replication_password    123456 //設置主從同步用戶密碼


        agent_user              agent //控制數據庫用戶

        agent_password          123456 //控制數據庫用戶密碼

</host>


<host db90> //設置第一個主服務器

        ip                              192.168.4.90

        mode                                    master

        peer                                    db91 //指定另外一臺主服務器

</host>


<host db91> //設置第二臺主服務器

        ip                              192.168.4.91

        mode                                    master

        peer                                    db90

</host>


<host db92> //設置從服務器

        ip                              192.168.4.92

        mode                                    slave

</host>


<host db93> //設置從服務器

        ip                              192.168.4.93

        mode                                    slave

</host>



<role writer> //指定主服務器VIP地址

        hosts                           db90, db91

        ips                             192.168.4.100

        mode                                    exclusive

</role>


<role reader> //指定從服務器VIP地址

        hosts                           db92, db93

        ips                             192.168.4.101, 192.168.0.102

        mode                                    balanced

</role>

>


d 根據配置文件的設置,在數據節點主機上添加對應授權用戶

-> grant replication client on *.* to monitor@'%' identified by '123456';

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

-> select  user,host from mysql.user where user in ("monitor","agent");


4)啟動服務

a 啟動數據節點主機上代理服務: mmm_agent

安裝服務運行依賴的軟件包   安裝獲取vip地址軟件包arp_net   啟動服務

[root@pc90 ~]# /etc/init.d/mysql-mmm-agent start

[root@pc90 ~]# netstat -pantu | grep 9989


b 啟動管理節點主機上監控服務:mmm_mond

安裝服務運行依賴的軟件包    啟動服務

[root@pc94 ~]# /etc/init.d/mysql-mmm-monitor start

[root@pc94 ~]# netstat -pantu | grep 9988


三、驗證mysql-mmm配置

a 查看數據庫節點上的數據庫服務是運行的

[root@pc94 ~]# systemctl status mysqld


b IO線程 和 SQL 線程都是Yes狀態  

mysql> show slave status\G;


c 在監控服務器本機登錄管理界面查看,查看數據庫服務器的狀態

[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/AWAITING_RECOVERY. Roles: 

  db91(192.168.4.91) master/AWAITING_RECOVERY. Roles: 

  db92(192.168.4.92) slave/AWAITING_RECOVERY. Roles: 

  db93(192.168.4.93) slave/AWAITING_RECOVERY. Roles:


[root@pc94 ~]# mmm_control set_online db90

[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/ONLINE. Roles: writer(192.168.4.100)

  db91(192.168.4.91) master/ONLINE. Roles: 

  db92(192.168.4.92) slave/ONLINE. Roles: reader(192.168.0.102)

  db93(192.168.4.93) slave/ONLINE. Roles: reader(192.168.4.101)


[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/ONLINE. Roles: writer(192.168.4.100)

  db91(192.168.4.91) master/HARD_OFFLINE. Roles: 

  db92(192.168.4.92) slave/ONLINE. Roles: reader(192.168.0.102)

  db93(192.168.4.93) slave/ONLINE. Roles: reader(192.168.4.101)


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女