Mysql master-slave warm-up (when master-slave data is inconsistent)

Source: Internet
Author: User
Mysql master-slave Hot Standby (when master-slave data is inconsistent) 1. grantslave none; severe error GRANTREPLICATIONSLAVEON *. * TOslave@172.16.8. % IDENTIFIEDBY ******** 88; 2. lock the table for backup; Be sure to carefully flushtableswithreadlock; 3. local backup: mysqldum

Mysql master-slave Hot Standby (when master-slave data is inconsistent) 1. grant slave does not exist; 'serious error' grant replication slave on *. * TO slave @ '2017. 16.8.% 'identified BY '******** 88'; 2. lock the table for backup; 'Be sure to be careful' flush tables with read lock; 3. local backup:/mysqldum

Mysql master-slave Hot Standby (when master-slave data is inconsistent)


1. grant slave none; 'critical error'
Grant replication slave on *. * TO slave @ '192. 172.% 'identified by' ******** 88 ';


2. Lock the table for backup; 'Be careful'

> Flush tables with read lock;

3. Local backup:
/Mysqldump-uroot-proot -- all-databases>/data/backup-all. SQL

4. Record the master Status:

> Show master status \ G;
Mysql> show master status;
+ ------------------ + ---------- + ---------------- + -------------------- + ------------------- +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+ ------------------ + ---------- + ---------------- + -------------------- + ------------------- +
| Mysql-bin.000011 | 2253254 | juxinli_credit | mysql

5. Unlock;
> Unlock tables;


6. Pass the local backup file to the slave machine;
Scp backup-all. SQL:/home/ubuntu/



7. Restore the database from the slave machine
../Mysql-uroot-p

8. Slave mysql settings
> Change master to master_host = '2017. 16.56.82 ', master_user = 'slave', master_password = '***** 88', master_port = 3306, master_log_file = 'mysql-bin.000011 ', master_log_pos = 2253254;


9. Start slave;
Start slave;

10. Check the slave startup status
> Show slave status \ G;

Error diagnosis:
1. Be sure to carefully check whether master_log_file is correct in step 1.

2. identify the cause of the problem through show slave status

3. Check error. log (under the database data directory by default). It is helpful to accurately lock the cause of the problem and modify the error information step by step.

Attached:
My. cnf of the master:
#----------------------------------------------------------
Server-id = 11
# Log_bin =/data/mysql-bin
Binlog_do_db = juxinli_credit
Binlog_ignore_db = mysql
# Replication Mode
# Binlog_format = "STATEMENT"
# Binlog_format = "ROW"
Binlog_format = "MIXED"

#----------------------------------------------------------
# Enable dual-machine hot standby
# Max_connections = 16384
# Log File Configuration:


# Configure a binary log file
Log_bin =/data/mysql/mysql-bin.log

# Configure common log files
General_log = on
General_log_file =/var/log/mysql. log

# Configuration error output log file/change default data directory
Log-error =/var/log/mysql/mysql-error.log

# Configure slow query log files
# Slow_query_log = on ??
# Slow_query_log_file =/var/log/mysql/slow-query.log.





My. cnf of slave:

#1. Indicates opening the log;
# General_log = 1

Server-id = 13
Replicate-do-db = juxinli_credit
Replicate-ignore-db = mysql
# Slave-skip-erros = 1062
Binlog_format = "MIXED"


# Configure the slave server binary log file
Relay-log =/var/log/mysql/mysql-slave-relay-bin.log
Relay-log-index =/var/log/mysql/mysql-relay-log-bin.index
(If you have modified the directory, you also need to delete the relevant relay-bin.log under the default data directory) and then restart mysql

# Configure common log files
General_log = on
General_log_file =/var/log/mysql. log

# Configuration error output Log File
Log-error =/var/log/mysql/mysql-error.log

# Configure slow query log files
Slow_query_log = on ??
Slow_query_log_file =/var/log/mysql/slow-query.log.

================================================================ I hope to have something for you help =

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.