Note 1: Solve the problem of slow connection to MySQL database Add content: Note 2: (If the password contains ! or other special characters, add \ in front, for example, 123!321-->123\!321) 1. Master-slave backup Primary database: vim /etc/my.cnf Add the following content under [mysqld]: server-id = 1 log-bin=mysql-bin relay-log = mysql-relay-bin replicate-wild-ignore-table=mysql.% replicate-wild-ignore-table=test.% replicate-wild-ignore-table=information_schema.% From the database: vim .etc/my.cnf Add the following content under [mysqld]: server-id = 2 log-bin=mysql-bin relay-log = mysql-relay-bin replicate-wild-ignore-table=mysql.% replicate-wild-ignore-table=test.% replicate-wild-ignore-table=information_schema.% Restart the master-slave database and log in to the master database mysql -uusername -ppassword mysql>show master status; Find master_log_file, master_log_pos (usually mysql-bin.000001 and 155) mysql>change master to \ mysql>master_host='from database IP', mysql>master_user='from database user', mysql>master_password='from database password', mysql>master_log_file='from database master_log_file', mysql>master_log_pos='from database master_log_pos'; mysql>start slave; mysql>show slave status\G Log in to the database mysql -uusername -ppassword mysql>show master status; Find master_log_file, master_log_pos (usually mysql-bin.000001 and 155) mysql>change master to \ mysql>master_host='Master database IP', mysql>master_user='Master database user', mysql>master_password='Master database password', mysql>master_log_file='Master database master_log_file', mysql>master_log_pos='Master database master_log_pos'; mysql>start slave; mysql>show slave status\G At this point, the master-slave backup of the database has been successfully started. Let’s try the effect! 2. Daily scheduled full backup cd ../usr/local/src/dbback If there is no dbback, add a new folder vi bkDatabaseName.sh (if there is no dbback, this file will be added automatically) Copy content: #!/bin/bash source /etc/profile mysqldump -uusername -ppassword DatabaseName | gzip > /usr/local/src/dbback/DatabaseName_$(date +%Y%m%d_%H%M%S).sql.gz save. Add executable permissions: chmod u+x bkDatabaseName.sh After adding executable permissions, execute the script first to see if there are any errors and whether it can be used normally; ./bkDatabaseName.sh Then check if there is any compressed file added to the scheduled task 1. Install crontab Download crontab: Click to download After downloading, put it in the /usr/local/src/crontab directory Install Adding a scheduled task Execute the command: Added content: (Backup is performed at 1 am every day) Summarize The above is what I introduced to you about how to enable MySQL8 master-slave backup and daily scheduled full backup on CentOS7. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: A brief analysis of the difference between ref and toRef in Vue3
>>: MYSQL local installation and problem solving
Here is a case study on how to close ads using Ja...
1. Test environment name Version centos 7.6 docke...
1. Command Introduction The date command is used ...
1. Problem Description root@mysqldb 22:12: [xucl]...
In MySQL, we often use order by for sorting and l...
When a user registers, they will click on a label...
Preface Hello everyone, I am Liang Xu. At work, w...
Before we begin, we create two tables to demonstr...
Preface Query optimization is not something that ...
Table of contents How to create a Pod? kubectl to...
If prompted to enter a key, select [I don’t have ...
Table of contents 1. innodb_buffer_pool_size 2. i...
The div element is used to provide structure and b...
Table of contents Preface Dockerfile What is a Do...
Introduction to HTML HyperText Markup Language: H...