MySQL turns on master-slave replication

Source: Internet
Author: User

First step : Turn on all MySQL server's bin log, each server set a unique Server-id value (default is 1, generally take IP last paragraph)

Modifying the my.cnf of the primary server (master)

[mysqld] log-bin=Mysql-binserver-id=91

Modify the MY.CNF from the server (slave)

[mysqld] log-bin=Mysql-binserver-id=92

Step two : Reboot and slave server

Service mysqld Restart

Step three : Create an account on the master server to synchronize the data (for example, the test_slave,% below indicates that all clients may be connected)

GRANT replication Slave on * * to ' test_slave ' @ '% ' identified by ' 123456 ';

Fourth Step : Log in to the master server MySQL, query the status of master

Show Master Status

See the following example

+------------------+----------+--------------+------------------+| File             |Position|binlog_do_db|binlog_ignore_db|+------------------+----------+--------------+------------------+|Mysql-Bin.000025 |       the |              |                  | +------------------+----------+--------------+------------------+

Fifth Step : Configure the state from the server

Stop Slave;change Master toMaster_host='192.168.1.91', Master_user='Test_slave', Master_password='123456', Master_log_file='mysql-bin.000025', Master_log_pos= the; start slave;

Explain:
master_host= ' The IP address of the primary server ',
Master_user= ' account for synchronizing data on the primary server ',
master_password= ' Sync account password ',
master_log_file= ' bin log filename ',
The value of the position in the Master_log_pos=bin log;

Sixth step : view slave Server Status

Show Slave Status\g

Appear

*************************** 1. Row***************************slave_io_state:waiting forMaster toSend event Master_host:192.168.1.91master_user:slave Master_port:3306Connect_retry: -Master_log_file:mysql-Bin.000025Read_master_log_pos: theRelay_log_file:bogon-Relay-Bin.000002Relay_log_pos:342Relay_master_log_file:mysql-Bin.000025Slave_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:0Last_error:skip_counter:0Exec_master_log_pos: theRelay_log_space:498until_condition:none Until_log_file:until_log_pos:0Master_ssl_allowed:no Master_SSL_CA_File:Master_SSL_CA_Path:Master_SS L_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master:0master_ssl_verify_server_cert:no Last_io_errno:0Last_io_error:last_sql_errno:0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id:11Rowinch Set(0.00Sec

If Slave_io_running:yes Slave_sql_running:yes stands for success
The general appearance of this sentence slave_io_state:waiting for master to send event also represents success

MySQL turns on master-slave replication

Related Article

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.