MySQL Master-slave replication (centos6.3&mysql5.6)

Source: Internet
Author: User
Tags server memory

Environment:

Master:centos 6.3 192.168.1.4

Slave:centos 6.3 192.168.1.5

mysql:mysql-5.6.25

MySQL using RPM Installation Method

Installation Method Reference: http://www.cnblogs.com/xs104/p/4589041.html

To configure the primary database:

After the installation is complete, a my.cnf file is generated in the/usr directory, the configuration file is modified and copied to the/etc directory

[Mysqld]server-id=1log-bin=mysqlmaster-bin.logsync_binlog=1  #注意: The following parameter needs to be modified to the server memory of%= 512minnodb_flush_log_at_trx_commit=1sql _mode=strict_trans_tables,no_auto_create_user,no_engine_substitution,no_auto_value_on_zerolower_ Case_table_names=1log_bin_trust_function_creators=1

Restart MySQL

Configuration from the database:

Also modify the My.cnf file in the/usr directory and copy it to the/etc directory

[Mysqld]server-id=2log-bin=mysqlslave-bin.logsync_binlog=1  #注意: The following parameter needs to be modified to the server memory of about innodb_buffer_pool_size=512minnodb_flush_log_at_trx_ Commit=1sql_mode=strict_trans_tables,no_auto_create_user,no_engine_substitution, No_auto_value_on_zerolower_case_table_names=1log_bin_trust_function_creators=  1

Restart database

create an account on the primary database for data replication between master and slave

' User name '@' from the database address ' password ';

Gets the binary log coordinates of the primary database  

Perform:

 with READ LOCK;

Primary Database Lock Table

Perform:

SHOW MASTER STATUS;

Displays the binary log name and location of the primary database, recording the alternate

  

Main database unlock:

UNLOCK TABLES;

To set up replicated primary database information from a database

 to Master_host=' Primary Database address ', master_user=' username just created ' , Master_password=' password ', master_log_file=' Binary log name ', master_log_pos= coordinate;

Start the replication thread

START slave;

  

Then query the slave state of the database:

SHOW slave STATUS \g

  

If both slave_io_running and slave_sql_running are yes, then the master-slave replication succeeds

Problems encountered

  1. When starting MySQL, Tip error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2)

The reason is that there are errors in my.cnf, fill in the correct parameters can

2.slave status look for that slave_io_running is connecting

After Google, there are three reasons:

1, the network does not pass (determine the network interoperability, you can shut down the firewall, if not yet can iptables-f (* * * * * * * * * *))

2. Password not confirm account password

3. POS does not determine the binary log name and directory of the main library

  

MySQL Master-slave replication (centos6.3&mysql5.6)

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.