1. Launch Instances 3306 and 3307
2. Check the main library configuration
[Email protected] 3306]# egrep "Log-bin|server|sock" my.cnf
Socket =/data/3306/mysql.sock
Socket =/application/mysql-5.5.32/tmp/mysql.sock
#socket =/data/3306/mysql.sock
Log-bin =/data/3306/mysql-bin
Server-id = 1
To see if the configuration takes effect
[Email protected] 3306]# mysql-s/application/mysql-5.5.32/tmp/mysql.sock-e "show variables like ' Log_bin '"
+---------------+-------+
| variable_name | Value |
+---------------+-------+
| Log_bin | On |
+---------------+-------+
3. Check the configuration from the library
[Email protected] 3307]# egrep "Log-bin|server|sock" my.cnf
Socket =/data/3306/mysql.sock
Socket =/application/mysql-5.5.32/tmp/mysql.sock
#socket =/data/3306/mysql.sock
Log-bin =/data/3306/mysql-bin
Server-id = 1
4. Main Library Configuration
Mysql>grant replication Slave on * * to ' rep ' @ '% ' identified by ' oldboy123 '
Mysql>flush Privileges
Mysql>flush table with read lock
Mysql> Show master status;
Mysqldump-s/application/mysql-5.5.32/tmp/mysql.sock-a-B--events--master-data=2 >/tmp/rep1.sql
Mysql>unlock tables
5. Recover from Library
Mysql-s/data/3307/mysql.sock </tmp/rep1.sql
Cat |mysql-s/data/3307/mysql.sock << EOF
Change MASTER to
Master_host= ' 192.168.12.200 ',
master_port=3306,-------------------------------Be careful not to use quotation marks
Master_user= ' rep ',
Master_password= ' oldboy123 ',
Master_log_file= ' mysql-bin.000016 ',
master_log_pos=421;--------------------------be careful not to use quotation marks
Eof
mysql> start slave;
Mysql> show slave status \g;
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:192.168.12.200
Master_user:rep
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000016
read_master_log_pos:421
relay_log_file:relay-bin.000002
relay_log_pos:253
relay_master_log_file:mysql-bin.000016
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
Replicate_ignore_db:mysql
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:421
relay_log_space:403
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
seconds_behind_master:0
Master_ssl_verify_server_cert:no
last_io_errno:0
Last_io_error:
last_sql_errno:0
Last_sql_error:
Replicate_ignore_server_ids:
Master_server_id:1
This article is from the "11300506" blog, please be sure to keep this source http://11310506.blog.51cto.com/11300506/1962167
MySQL master-slave replication--a primary one from