Centos7 MySQL master and slave settings

Source: Internet
Author: User

Already installed CENTOS7 and MySQL, the system is installed by default more than MARIADB

Two virtual machine IP

192.168.0.103

192.168.0.106

Firewall Open port

Permanent parameter means permanent modification

Firewall-cmd--zone=public--add-port=3306/tcp--permanent

Firewall-cmd--reload

Main Library Settings

Mysql-u root-p Password

Go to the MySQL console, add a new account, set only 192.168.0-Segment Multi-IP to access

Create Test account password 123456

Create user ' test ' @ ' 192.168.0.% ' identified ' 123456 ';

Give master-Slave synchronization permissions

Grant Replication Slave on * * to ' test ' @ ' 192.168.0.% ';

Configuration file

/etc/my.cnf

Mariadb/etc/my.cnf.d/server.cnf

Open Binary Log

Log-bin=master-bin,master-bin is the log file name

Server-id MySQL ID, the value must be unique, cannot be 0, otherwise all from the library can not connect

#binlog-do-db=master the database to be synchronized is typically set from the library

Restart MySQL

Systemctl Restart MySQL

Enter the MySQL console to view the status of the primary server

Mysql> Show master status;

Record file and position, set from library

Configure from Library

server-id=2 value Unique

Relay-log=relay-bin Recording master-slave synchronization data multi-log files

Read-only = On set read-only permission from library

REPLICATE-DO-DB = test developed to synchronize multiple databases

Configure information for connecting to the master server

mysql> stop Slave;

Mysql> Change Master to

Master_host= ' 192.168.0.103 ',

->master_user= ' Test ',

->master_password= ' 123456 ',

->master_log_file= ' master-bin.000001 ',

->master_log_pos=1317;

mysql> start slave;

ok~

Centos7 MySQL master and slave settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.