Mysql-mmm cluster deployment
90 Lord 91 Lord
|
|
|
------------------------------
| |
| |
| |
92 from 93 from
systemctl stop firewalld.service ;systemctl disable firewalld.service ;setenforce 0
MySQL-mmm
I. Configuration of master-slave synchronization structure
1) Configure master-slave synchronization
90: User Configuration Enable binlog Log Restart Database Service Specify primary database server information
91: User Configuration Enable binlog logging Allow cascading replication Restart database service Specify primary database server information
[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="master server ip address",
-> master_user="authorized user name",
-> master_password="authorized user password",
-> master_log_file="binlog in use by master server",
-> master_log_pos= current offset of master service;
#Specify primary server
2) Configure a master multi-slave structure
92: Specify server_id Restart database service Specify primary database server information
93: Specify server_id Restart database service Specify primary database server information
[root@pc92 ~]# vim /etc/my.cnf
[mysqld]
validate_password_policy=0
validate_password_length=6
server_id=92
-> change master to
-> master_host="master server ip address",
-> master_user="authorized user name",
-> master_password="authorized user password",
-> master_log_file="binlog in use by master server",
-> master_log_pos= current offset of master service;
#Specify primary server
mysql> show master status\G;
mysql> start slave;
mysql> show slave status\G;
3) Test master-slave synchronization configuration on client side
a、
Add a user guser to access data on 90 hosts, and you can have the same authorized users on the other 3 hosts
-> grant select on gamedb.* to guser@'%' identified by '123456';
b、
The client host 94 uses the authorized user guser to connect to the server 14, and the new data generated is also available on his 3 hosts.
-> select user,host from mysql.user where user="guser";
II. Configuration mysql-mmm
1) Introduction to mysql-mmm
Monitoring service: runs on management node to monitor data node
Proxy service: runs on the data node to provide the system to the monitoring host
2) Install mysql-mmm software (90-94) on all hosts
#yum -y install perl-*
#unzip mysql-mmm.zip
#cd mysql-mmm
#make install
#ls /etc/mysql-mmm/*.conf
3) Modify configuration file
a Modify Data Node Proxy Service Profile (90 91 92 93)
vim /etc/mysql-mmm/mmm_agent.conf
include mmm_command.conf
this custom name
b Modify the profile of the management node monitoring service (94)
vim /etc/mysql-mmm/mmm_mon.conf
>
include mmm_common.conf
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.93 server IP 192.168.4.92
monitor_user monitor //user name used when monitoring status
monitor_password 123456 //User password used when monitoring status
>
C. Modification of public documents
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 //Set the user for master-slave synchronization
replication_password 123456 //Set master-slave synchronization user password
agent_user agent //control database user
agent_password 123456 //Control database user password
//Set the first master server
ip 192.168.4.90
mode master
peer db91 //Specify another primary server
//Set up the second primary server
ip 192.168.4.91
mode master
peer db90
//set slave server
ip 192.168.4.92
mode slave
//set slave server
ip 192.168.4.93
mode slave
//Specify the main server VIP address
hosts db90, db91
ips 192.168.4.100
mode exclusive
//Specify the slave server VIP address
hosts db92, db93
ips 192.168.4.101, 192.168.0.102
mode balanced
>
d Add the corresponding authorized user to the data node host according to the configuration file setting
-> 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) Start-up service
a Start proxy service on data node host: mmm_agent
install services run dependent packages install get vip address packages arp_net start services
[root@pc90 ~]# /etc/init.d/mysql-mmm-agent start
[root@pc90 ~]# netstat -pantu | grep 9989
b Start monitoring service on management node host: mmm_mond
Installation Services Running Dependent Packages Startup Services
[root@pc94 ~]# /etc/init.d/mysql-mmm-monitor start
[root@pc94 ~]# netstat -pantu | grep 9988
III. Verify mysql-mmm configuration
a Check whether database services are running on database nodes
[root@pc94 ~]# systemctl status mysqld
b IO threads and SQL threads are both Yes
mysql> show slave status\G;
c View the status of the database server in the login management interface of the monitoring server.
[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)