Basic Configuration
Primary database
configuration files, modifying server_id=1
Create an account for slave to use synchronously
GRANT REPLICATION SLAVE on *.* to ' repl ' @ ' 192.168.56.3 ' identified by ' repl ';
Mysql> Show master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
| mysql-bin.000005 | 261 | | |
+------------------+----------+--------------+------------------+
Records the values of FILE and Position that need to be used for later operations from the server.
From the database
configuration files, modifying server_id=2
Execute synchronous SQL statements, addresses to primary database addresses, and user names and passwords on the primary database
Change Master to
Master_host= ' 192.168.56.2 ',
Master_user= ' Repl ',
Master_password= ' Repl ',
Master_log_file= ' mysql-bin.000005 ',
master_log_pos=261;
Start slave synchronization process after proper execution
Start slave;
Master-Slave Sync Check
Mysql> Show Slave Status\g
==============================================
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:192.168.56.2
Master_user:test
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000008
read_master_log_pos:258
relay_log_file:slave2-relay-bin.000003
relay_log_pos:404
relay_master_log_file:mysql-bin.000008
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:258
relay_log_space:561
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:1
==============================================
where slave_io_running and slave_sql_running values must be yes to indicate that the status is normal.