Configuration and procedure of MySQL master-slave configuration parameters

Source: Internet
Author: User

Master-Slave configuration steps:
Establish the database to be synchronized in the main library, establish the account number of the main library and modify the main repository configuration

Create database Web default character set UTF8

Grant Replication Slave on * * to ' repdcssub ' @ ' 192.168.191.112 ' identified by ' 123456 ';
Grant all privileges on * * to ' repdcssub ' @ ' 192.168.191.112 ' identified by ' 123456 '
mysql-h192.168.191.113-urep-p123456



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


Establish a synchronous user (master/slave)

Grant Replication Slave on * * to ' Repdcs ' @ ' 192.168.191.110 ' identified by ' 123456 ';
Grant all privileges on * * to ' Repdcs ' @ ' 192.168.191.110 ' identified by ' 123456 ';
FLUSH privileges;

Mysql> Show master status;
FLUSH privileges;
Configure MY.CNF from Library
[Email protected] u02]# MORE/ETC/MY.CNF
[Mysqld]
Datadir=/u02/ligangdata
Socket=/var/lib/mysql/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/mysqld.pid

[MySQL]
Default-character-set=utf8
#character-set-server=utf8


Main Library Configuration My.ini

[Email protected] log]# MORE/ETC/MY.CNF
[Mysqld]
Datadir=/u02/ligangdata
Socket=/var/lib/mysql/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/mysqld.pid

[MySQL]
Default-character-set=utf8
#character-set-server=utf8

Parameter configuration Instructions
Server-id=n//Set database ID The default master server is 1 and can be set casually but cannot be duplicated if there are multiple slave servers.
IP address or domain name of the master-host=192.168.191.111//master server
master-port=3306//port number of the primary database
Master-user=repdcs//Synchronizing the database user
master-password=123456//Synchronizing the password of the database
MASTER-CONNECT-RETRY=60//If the primary server is found to be disconnected from the server, the time lag for reconnection
Replicate-do-db=dcs//Database for synchronization


Set from server to ReadOnly
MYSQL-E "set global Read_only=1;"

To view the command for the master repository to be normal or not:
SHOW SLAVE STATUS;

SHOW MASTER STATUS;



Master-slave Switch please see the next article


Configuration and procedure of MySQL master-slave configuration parameters

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.