Hostnamectl set-hostname n1 (the host name of the node to modify the master database)
Hostnamectl set-hostname n2 (host name from the modified node)
- To two virtual machine configuration ip address (master node is 192.168.150.100, the node is 192.168.150.200, and then restart the network)
- Close to the two nodes firewall boot does not start (systemctl stop firewalld, disable firewalld, vi / etc / selinux / config modify enforcing is disabled setenforce 0)
- Yum delete the original file that comes with two nodes do (rm -rf /etc/yum.repos.d/*)
- Yum source node configuration to two (vi /etc/yum.repos.d/local.repo follows:
[Centos]
name=centos
baseurl = file: /// opt / CentOS
gpgcheck=0
enabled=1
Clear cache: yum clean all
yum repolist
- Mirror mount two nodes: mkdir / opt / centos (create the mount point) mount / dev / sr0 / opt / centos (mirror mount)
- Two service nodes and restart the service installation MariaDB: yum install mariadb-server -y
systemctl restart mariadb
- Two nodes are operating: mysql_secure_installation (up point y, the password is 000000) to install the database
- The master node modify the configuration file
we /etc/my.cnf
[mysql]
server_id = 100 # This number is usually the last paragraph of ip address
log_bin = mysql-bin # open MySQL binary log
binlog-do-db = keystone # Here is the name of the database to be synchronized
- Modify the configuration file from the node
we /etc/my.cnf
[mysql]
server_id = 200 # This number is usually the last paragraph of ip address
log_bin = mysql-bin # open MySQL binary log
binlog-do-db = keystone # Here is the name of the database to be synchronized
Restart both nodes after completion of service again mariadb
- The master node: mysql -uroot -p000000
Access to the database
grant replication slave on *.* To ‘backup’@’%’ identified by ‘1234567’;
Authorization allows all network
flush privileges;
show master status;
Query from a node to use variables
- -uroot -p000000 mysql: from node
stop slave ;
change master to master_host=’192.168.150.100’,master_user=’backup’,master_password=’1234567’,master_log_fire=’mysql-bin.000001’,master_log_pos=465;
start slave;
- search result
show slave status\G;