十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊
量身定制 + 運營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
90主 <----------> 91主

我們提供的服務(wù)有:成都網(wǎng)站制作、網(wǎng)站設(shè)計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、芒康ssl等。為千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的芒康網(wǎng)站制作公司
|
|
|
------------------------------
| |
| |
| |
92從 93從
systemctl stop firewalld.service ;systemctl disable firewalld.service ;setenforce 0
MySQL-mmm
一、配置主從同步結(jié)構(gòu)
1)配置主從同步
90: 用戶配置 啟用 binlog 日志 重啟數(shù)據(jù)庫服務(wù) 指定主數(shù)據(jù)庫服務(wù)器信息
91: 用戶配置 啟用 binlog 日志 允許級聯(lián)復(fù)制 重啟數(shù)據(jù)庫服務(wù) 指定主數(shù)據(jù)庫服務(wù)器信息
[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="主服務(wù)器 ip 地址",
-> master_user="授權(quán)用戶名",
-> master_password="授權(quán)用戶密碼",
-> master_log_file="主服務(wù)器正在使用的 binlog 日志",
-> master_log_pos=主服務(wù)當(dāng)前的偏移量;
#指定主服務(wù)器
2)配置一主多從結(jié)構(gòu)
92: 指定server_id 重啟數(shù)據(jù)庫服務(wù) 指定主數(shù)據(jù)庫服務(wù)器信息
93: 指定server_id 重啟數(shù)據(jù)庫服務(wù) 指定主數(shù)據(jù)庫服務(wù)器信息
[root@pc92 ~]# vim /etc/my.cnf
[mysqld]
validate_password_policy=0
validate_password_length=6
server_id=92
-> change master to
-> master_host="主服務(wù)器 ip 地址",
-> master_user="授權(quán)用戶名",
-> master_password="授權(quán)用戶密碼",
-> master_log_file="主服務(wù)器正在使用的 binlog 日志",
-> master_log_pos=主服務(wù)當(dāng)前的偏移量;
#指定主服務(wù)器
mysql> show master status\G;
mysql> start slave;
mysql> show slave status\G;
3)在客戶端測試主從同步配置
a、
在90主機(jī)上添加訪問數(shù)據(jù)的用戶guser,能夠在其他3臺主機(jī)上也有相同的授權(quán)用戶
-> grant select on gamedb.* to guser@'%' identified by '123456';
b、
在客戶端主機(jī)94 使用授權(quán)用戶guser 連接14服務(wù)器,產(chǎn)生的新數(shù)據(jù)在他3臺主機(jī)上也有
-> select user,host from mysql.user where user="guser";
二、配置mysql-mmm
1)mysql-mmm 介紹
監(jiān)控服務(wù): 運行在管理節(jié)點 用來監(jiān)控數(shù)據(jù)節(jié)點
代理服務(wù): 運行在數(shù)據(jù)節(jié)點 用來提供系統(tǒng)給監(jiān)控主機(jī)
2)在所有主機(jī)上安裝mysql-mmm軟件(90-94)
#yum -y install perl-*
#unzip mysql-mmm.zip
#cd mysql-mmm
#make install
#ls /etc/mysql-mmm/*.conf
3)修改配置文件
a 修改數(shù)據(jù)節(jié)點代理服務(wù)配置文件 (90 91 92 93)
vim /etc/mysql-mmm/mmm_agent.conf
include mmm_command.conf
this 自定義名稱
b 修改管理節(jié)點監(jiān)控服務(wù)的配置文件 (94)
vim /etc/mysql-mmm/mmm_mon.conf
>
include mmm_common.conf
ip 192.168.4.94 //本機(jī)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 //監(jiān)控的服務(wù)器IP
monitor_user monitor //監(jiān)控狀態(tài)時使用的用戶名
monitor_password 123456 //監(jiān)控狀態(tài)時使用的用戶密碼
>
c 修改公共文件
vim /etc/mysql-mmm/mmm_command.conf
>
active_master_role writer
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user slaveuser //設(shè)置主從同步的用戶
replication_password 123456 //設(shè)置主從同步用戶密碼
agent_user agent //控制數(shù)據(jù)庫用戶
agent_password 123456 //控制數(shù)據(jù)庫用戶密碼
ip 192.168.4.90
mode master
peer db91 //指定另外一臺主服務(wù)器
ip 192.168.4.91
mode master
peer db90
ip 192.168.4.92
mode slave
ip 192.168.4.93
mode slave
hosts db90, db91
ips 192.168.4.100
mode exclusive
hosts db92, db93
ips 192.168.4.101, 192.168.0.102
mode balanced
>
d 根據(jù)配置文件的設(shè)置,在數(shù)據(jù)節(jié)點主機(jī)上添加對應(yīng)授權(quán)用戶
-> 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)啟動服務(wù)
a 啟動數(shù)據(jù)節(jié)點主機(jī)上代理服務(wù): mmm_agent
安裝服務(wù)運行依賴的軟件包 安裝獲取vip地址軟件包arp_net 啟動服務(wù)
[root@pc90 ~]# /etc/init.d/mysql-mmm-agent start
[root@pc90 ~]# netstat -pantu | grep 9989
b 啟動管理節(jié)點主機(jī)上監(jiān)控服務(wù):mmm_mond
安裝服務(wù)運行依賴的軟件包 啟動服務(wù)
[root@pc94 ~]# /etc/init.d/mysql-mmm-monitor start
[root@pc94 ~]# netstat -pantu | grep 9988
三、驗證mysql-mmm配置
a 查看數(shù)據(jù)庫節(jié)點上的數(shù)據(jù)庫服務(wù)是運行的
[root@pc94 ~]# systemctl status mysqld
b IO線程 和 SQL 線程都是Yes狀態(tài)
mysql> show slave status\G;
c 在監(jiān)控服務(wù)器本機(jī)登錄管理界面查看,查看數(shù)據(jù)庫服務(wù)器的狀態(tài)
[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)