Mysql master-slave configuration parameters and steps

Source: Internet
Author: User

Mysql master-slave configuration parameters and steps
Master-slave configuration steps:
Create the database to be synchronized in the master database, create the account of the master database, and modify the configuration of the master and slave databases.

Create database web default character set utf8

Grant replication slave on *. * to 'repdcssub '@ '192. 168.191.112 'identified by '123 ';
Grant all privileges on *. * to 'repdcssub '@ '192. 168.191.112' identified by '20140901'
Mysql-h192.168.191.113-urep-p123456



Mysqldump -- master-data can be restored from the top,


Create a synchronization user (Master/Slave)

Grant replication slave on *. * to 'repdcs '@ '192. 168.191.110 'identified by '123 ';
Grant all privileges on *. * to 'repdcs '@ '192. 168.191.110 'identified by '123 ';
Flush privileges;

Mysql> show master status;
Flush privileges;
Configure my. cnf from the slave Database
[Root @ ligangtest u02] # more/etc/my. cnf
[Mysqld]
Datadir =/u02/ligangdata
Socket =/var/lib/mysql. sock
User = mysql
Old_passwords = 1
Character-set-server = utf8

Symbolic-links = 0

Lower_case_table_names = 1

Default-storage-engine = innoDB

# Innodb_log_buffer_pool_size = 2G
Max_connections = 300

Server-id = 2
Init_connect = 'set NAMES utf8'
Log-bin = mysqlbin
Master-host = 192.168.191.111
Master-user = repdcs
Master-pass = 123456
Master-connect-retry = 60
Replicate-do-db = dcs

[Mysqld_safe]
Log-error =/u03/log/mysqld. log
Pid-file =/var/run/mysqld. pid

[Mysql]
Default-character-set = utf8
# Character-set-server = utf8


Configure my. ini for the master database

[Root @ ligang log] # more/etc/my. cnf
[Mysqld]
Datadir =/u02/ligangdata
Socket =/var/lib/mysql. sock
User = mysql
Old_passwords = 1
Character-set-server = utf8

# Disabling symbolic-links is recommended to prevent assorted security risks;
Symbolic-links = 0

Lower_case_table_names = 1

Default-storage-engine = innoDB

Server-id = 1
Log-bin = mysqlbin
Innodb_flush_log_at_trx_commit = 1
Sync_binlog = 1
Init_connect = 'set NAMES utf8'

# Innodb_log_buffer_pool_size = 2G
Max_connections = 300

[Mysqld_safe]
Log-error =/u03/log/mysqld. log
Pid-file =/var/run/mysqld. pid

[Mysql]
Default-character-set = utf8
# Character-set-server = utf8

Parameter configuration instructions
Server-id = n // set the database id. The default master server is 1, which can be set at will, but it cannot be repeated if there are multiple slave servers.
Master-host = 192.168.191.111 // ip address or domain name of the master server
Master-port = 3306 // The port number of the master database
Master-user = repdcs // user who synchronizes the database
Master-password = 123456 // password for Database Synchronization
Master-connect-retry = 60 // time difference between the reconnection if the master server is disconnected from the slave server
Replicate-do-db = dcs // database for synchronization


Set slave server to readonly
Mysql-e "set global read_only = 1 ;"

Command to check whether the master database is normal or not:
Show slave status;

Show master status;



For more information about master-slave switchover, see the next article.



How to configure mysql master-slave synchronization configuration steps and code in LINUX

How can it be unstable? Our company is doing very well, but it is only one-way Master/Slave.
Open Baidu. Search for it. You may not be able to understand it if I paste code directly. Search for it. There are many online tutorials.

For mysql master-slave synchronization, what are the consequences of adding slave-skip-errors to the mysql configuration file mycnf on the slave machine?

Write in my. cnf of slave
Slave-skip-errors = 1062
Once started, it will ignore all errors of Type 1062.

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.