MySQL Master-Slave synchronization

Source: Internet
Author: User

1.MDB

[Client]
Port = 3306
Socket =/usr/local/mysql/mysql.sock

[Mysqld]
Port = 3306
Socket =/usr/local/mysql/mysql.sock
DataDir =/usr/local/mysql/var

Server-id = 1
Log-bin =/data/mysqllog/binlog/mysql-bin
Wait_timeout = 300
Expire_logs_days = 10


Skip-name-resolve
Default-character-set = UTF8

Back_log = 50
max_connections = 1000
Max_connect_errors = 32
Max_allowed_packet = 16M

Table_cache = 2048
Binlog_cache_size = 1M
Max_heap_table_size = 64M
Tmp_table_size = 64M

Key_buffer_size = 32M
Read_buffer_size = 2M
Read_rnd_buffer_size = 16M
Bulk_insert_buffer_size = 64M
Sort_buffer_size = 8M
Join_buffer_size = 8M

Thread_cache_size = 8
Thread_concurrency = 8
Thread_stack = 192K

Query_cache_size = 64M
Query_cache_limit = 2M
Tmp_table_size = 64M

Ft_min_word_len = 2
Default_table_type = INNODB
Transaction_isolation = Repeatable-read

Log_slow_queries
Long_query_time = 2
Log_long_format

Myisam_sort_buffer_size = 128M
Myisam_max_sort_file_size = 10G
Myisam_max_extra_sort_file_size = 10G
Myisam_repair_threads = 1
Myisam_recover

Skip-bdb

innodb_file_per_table = 1
Innodb_additional_mem_pool_size = 16M
Innodb_buffer_pool_size = 2G
Innodb_data_file_path = Ibdata1:1024m:autoextend
Innodb_file_io_threads = 4
Innodb_thread_concurrency = 16
Innodb_flush_log_at_trx_commit = 0
Innodb_log_buffer_size = 8M
Innodb_log_file_size = 256M
Innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90

[Mysqldump]
Quick
Max_allowed_packet = 16M

[MySQL]
No-auto-rehash

[Isamchk]
Key_buffer = 512M
Sort_buffer_size = 512M
Read_buffer = 8M
Write_buffer = 8M

[Myisamchk]
Key_buffer = 512M
Sort_buffer_size = 512M
Read_buffer = 8M
Write_buffer = 8M

[Mysqlhotcopy]
Interactive-timeout

[Mysqld_safe]
Open-files-limit = 8192

2.SDB and MDB, add the following fields:

Server-id = 291 #serverid不能和master一样.
Master-host = 192.168.7.14 #MDBip
Master-port = 3306
Master-user = XXX #MDB授权sdb同步的账号
Master-password = ujlpax36vhnbx25m #密码
Master-connect-retry = 30

replicate-ignore-db = MySQL
Replicate-ignore-db = Txwy_s1_50hero_combats #表示同步的时候忽略此库.
#replicate-do-db = Sanguo

Log-bin =/data/mysqllog/binlog/mysql-bin
Wait_timeout = 300
Expire_logs_days = 10
Slave-skip-errors = 1062


Relay-log =/data/mysqllog/relaylog/relay
Max-relay-log-size = 255M
Relay-log-space-limit = 10240M
Relay-log-index =/data/mysqllog/relaylog/relay
Relay-log-info-file =/data/mysqllog/relaylog/relay-log.info
Master-info-file =/data/mysqllog/relaylog/master.info # # # #binlog日志,

3. Configure master-Slave synchronization:

#在MDB上执行

Mysql-uxxx-pxxx-h127.0.0.1-e "Show master status \g;"

View current Binlog values and POS values

For example:

#在SDB上执行

mysql-uxxx-pxxx-h127.0.0.1

>slave stop;

>change Master to master_log_file= ' mysql-bin.000001 ', master_log_pos=582783685;

Prompt to execute after OK

>slave start

See if syncing

>show slave status \g;

MySQL Master-Slave synchronization

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.