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)