1. Tools:
Two machines
master:192.168.0.1
slave:192.168.0.2
2, the master configuration
Find MySQL config file, General CentOS is/etc/my.cnf,ubuntu is/etc/mysql/mysql.conf.d/mysqld.cnf
Skip to configuration under [Mysqld]
# can be commented # unique Node ID in schemalog_bin=mysql-# open binlogbinlog-ignore-db=mysql # Databases that do not need tobe replicated binlog-do-db=ufind_db # databases to replicate
Restart Master
Service MySQL Restart
Go to MySQL command line, add user
CREATE USER 'zhylioooo'@'%'Identified by '123456';GRANT REPLICATIONSLAVE on *.* to 'zhylioooo'@'%';
Export the master database
Lock the database to make it readable only
with READ LOCK;
Database files Everywhere
Mysqldump-u root-p--all-databases--master-data > Dbdump.sql
Unlocking a Database
UNLOCK TABLES;
View master's binary record file and the location of the file's current record
SHOW MASTER STATUS;
+
------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+
------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 1050 | | | |
+
------------------+----------+--------------+------------------+-------------------+
1 row
in
set
(0.00 sec)3, slave configuration slave configuration focus
# unique Node ID in schema, larger than master log_bin=mysql-# Open Binlog
Restart MySQL
Import the master exported database file to make the database consistent
Mysql-u Root-p < Dbdump.sql
Enter MySQL to connect the slave to master
STOP SLAVE; Change MASTER to -Master_host='192.168.0.1', -Master_user='zhylioooo', -Master_password='123456', -Master_log_file='mysql-bin.000001', -Master_log_pos=1050; START SLAVE;
4. Cluster strategy: https://www.cnblogs.com/KTblog/p/5122825.html
MySQL Master-Slave separation