Operational details for synchronous configuration based on Mysql Master slave _mysql

Source: Internet
Author: User
Environment:
Pc:ubuntu 10.10 192.168.1.112 (master) 192.168.10.245 (slave)
Mysql:5.1.49-1ubuntu8.1-log
Database test already exists in master
First Modify MySQL configuration file:/etc/mysql/my.cnf
[Master]
#author: Zhxia
Copy Code code as follows:

#master Synchronization Settings
Server-id = 1
Log_bin =/var/log/mysql/mysql-test-bin.log
Expire_logs_days = 10
Max_binlog_size = 100M
Binlog_format =mixed

[Slave]
#author: Zhxia
Copy Code code as follows:

server-id                = 2
 replicate-do-db=test
 replicate-do-db=blog
 log_bin & nbsp;               =/var/log/mysql/ Mysql-bin.log
 relay_log                =/var/log/mysql/mysql-relay-bin.log
 expire_logs_days        = Ten
 max_binlog_size         = 100M
  #binlog_do_db             = Test
  #binlog_ignore_db         = Include_database_name
 binlog_format            = mixed
 slave-net-timeout=6012 master-connect-retry=10

Then create a backup account on master
Copy Code code as follows:

Grant replication Slave,replication client on *.* to ' slave ' @ ' 192.168.10.245 ' identified by ' 123456 ';

Import the database in master into slave,
Lock table First, disable write operation
Flush tables with read lock;
First export from master: Mysqldump-uroot-p Test >/tmp/test.sql
Then import to Slave:mysql-uroot-p test </tmp/test.sql, remember to build the library test first
Go to MySQL on master and view master status

#author: Zhxia
Copy Code code as follows:

Mysql> Show master status;
+-----------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+-----------------------+----------+--------------+------------------+
|      mysql-test-bin.000022 |              624 |                  | |
+-----------------------+----------+--------------+------------------+
1 row in Set (0.02 sec)

Enter MySQL on the slave
#author: Zhxia
Copy Code code as follows:

Change Master to master_host= ' 192.168.1.112 ', master_user= ' slave ', master_password= ' 123456 ', master_log_file= ' mysql-test-bin.000022 ', master_log_pos=106;

Then start salve and view the status:
#author: Zhxia
Copy Code code as follows:

Start slave;

Mysql> show Slave status\g;
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:192.168.1.112
Master_user:slave
master_port:3306
Connect_retry:60
master_log_file:mysql-test-bin.000022
read_master_log_pos:624
relay_log_file:mysql-relay-bin.000005
relay_log_pos:533
relay_master_log_file:mysql-test-bin.000022
Slave_io_running:yes
Slave_sql_running:yes
Replicate_do_db:test,blog
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:624
relay_log_space:688
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:
1 row in Set (0.00 sec)

ERROR:
No query specified

Finally unlock the table on master
Unlock tables;
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.