表操作
- 锁表 (这个命令是全局读锁定,执行了命令之后所有库所有表都被锁定只读。一般都是用在数据库联机备份,这个时候数据库的写操作将被阻塞,读操作顺利进行。)
FLUSH TABLES WITH READ LOCK
- 解锁
unlock tables
docker cp mysql:/etc/mysql/mysql.conf.d
主从配置
GRANT REPLICATION SLAVE ON *.* TO 'corner'@'%' IDENTIFIED BY 'corner2802';
FLUSH PRIVILEGES;
stop slave; #关闭Slave
change master to master_host='192.168.1.182',master_user='corner',master_password='corner2802',master_log_file='mysqlmaster-bin.000075', master_log_pos=249162658;
start slave; #开启Slave
主库状态查看
show master status;
主从同步中断跳过处理步骤
stop slave;
set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
start slave;
查看配置的信息
show slave status \G;
输出结果
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.182
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 28125
Relay_Log_File: VM_128_194_centos-relay-bin.000004
Relay_Log_Pos: 26111
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: ufind_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: 28125
Relay_Log_Space: 26296
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: 2
Master_UUID: 8ac3066a-9680-11e5-a2ec-5254007529fd
Master_Info_File: /data/mysqldb/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)