1. Preparatory work:
To prepare a master server, my IP address is 192.168.13.138, and a Slave server: 192.168.13.137, database version consistent, master and slave libraries are built corresponding libraries and tables;
2, modify the master-slave server MySQL configuration:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[must] enable binary logging
server-id=222//[must] server unique ID, take server IP last paragraph
3, restart the master-slave Library of the MySQL service:
#service mysqld Restart
4. Create a MySQL account on the primary server and authorize it to the slave server:
Mysql>grant REPLICATION SLAVE, REPLICATION CLIENT on * * to [e-mail protected] ' 192.168.13.% ' identified by ' repl ';
5, query the status of master:
Mysql>show Master status;
+------------------+----------+--------------+------------------+--------------- ----+
| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_ Set |
+------------------+----------+--------------+------------------+--------------- ----+
| mysql-bin.000001 | 329 | | | |
+------------------+----------+--------------+------------------+--------------- ----+
6. Open the MySQL port of the primary server:
#firewall-cmd--add-port=3306/tcp
7. Configure from server:
Mysql>change Master to master_host= ' 192.168.13.138 ', master_user= ' repl ', master_password= ' repl ',
Master_log_file= ' mysql-bin.000001 ', master_log_pos=329;
Mysql>start slave;
8. Check the status of the replication function from the server:
Mysql> Show Slave status \g
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:192.168.13.138
Master_user:repl
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000001
read_master_log_pos:329
relay_log_file:mysqld-relay-bin.000002
relay_log_pos:283
relay_master_log_file:mysql-bin.000001
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
replicate_ignore_db:
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:329
relay_log_space:457
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
seconds_behind_master:0
Master_ssl_verify_server_cert:no
last_io_errno:0
Last_io_error:
last_sql_errno:0
Last_sql_error:
Replicate_ignore_server_ids:
master_server_id:138
Master_uuid:bd54c392-d746-11e6-8ea3-000c29fd50ed
Master_info_file:/var/lib/mysql/master.info
sql_delay:0
Sql_remaining_delay:null
Slave_sql_running_state:slave have read all relay log; Waiting for the slave I/O thread to update it
master_retry_count:86400
Master_bind:
Last_io_error_timestamp:
Last_sql_error_timestamp:
MASTER_SSL_CRL:
Master_ssl_crlpath:
Retrieved_gtid_set:
Executed_gtid_set:
auto_position:0
1 row in Set (0.00 sec)
MySQL Master copy Build