The main building from the database

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)

  1. 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)
  2. 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)
  3. Yum delete the original file that comes with two nodes do (rm -rf /etc/yum.repos.d/*)
  4. 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                     

  1. Mirror mount two nodes: mkdir / opt / centos (create the mount point) mount / dev / sr0 / opt / centos (mirror mount)
  2. Two service nodes and restart the service installation MariaDB: yum install mariadb-server -y

systemctl restart mariadb

  1. Two nodes are operating: mysql_secure_installation (up point y, the password is 000000) to install the database
  2. 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

 

  1. 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

  1. 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

 

  1. -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;

 

  1. search result

show slave status\G;

 

Published 18 original articles · won praise 0 · Views 456

Guess you like

Origin blog.csdn.net/weixin_45678149/article/details/104602275