Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of CentOS7 enabling MySQL8 Master-Slave backup and Daily scheduled full backup

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of CentOS7 enabling MySQL8 master-slave backup and regular full backup every day, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

Note 1: solve the problem of slow connection to MySQL database

Vim / etc/my.cnf

Add content: skip-name-resolve, restart the database.

Note 2: (password tape! Or other special matches, preceded by\, for example, 123 / 321 / color-> 123\! 321)

1. Master-slave backup

Add content under vim / etc/my.cnf [mysqld]: server-id = 1log-bin=mysql-binrelay-log = mysql-relay-binreplicate-wild-ignore-table=mysql.%replicate-wild-ignore-table=test.%replicate-wild-ignore-table=information_schema.% from database: vim .etc / my.cnf [mysqld]: server-id = 2 log-bin=mysql-binrelay-log = mysql-relay-binreplicate-wild-ignore-table=mysql.%replicate-wild-ignore -table=test.% replicate-wild-ignore-table=information_schema.% restart master-slave database login master database mysql-uusername-ppasswordmysql > show master status Find master_log_file, master_log_pos (usually mysql-bin.000001 and 155s) 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 login from database mysql- uusername-ppasswordmysql > show master status Find master_log_file, master_log_pos (usually mysql-bin.000001) 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 opened successfully, hurry up to try the effect!

2. Full backup on a daily basis

Cd.. / usr/local/src/dbback if there is no dbback, add a new folder vi bkDatabaseName.sh (no new file will be added automatically) copy the contents: #! / bin/bashsource / etc/profilemysqldump-uusername-ppassword DatabaseName | gzip > / usr/local/src/dbback/DatabaseName_$ (date +% Y%m%d_%H%M%S) .sql.gz save. Add executable permissions: chmod Ubunx bkDatabaseName.sh executes after adding executable permissions to see if there are any errors in the script and whether it can be used properly;. / bkDatabaseName.sh then check to see if there are any compressed files to add scheduled tasks

1. Install crontab

Download crontab: click to download

Download and put it in the / usr/local/src/crontab directory

Cd.. / usr/local/src/crontab

Installation

Rpm-ivh-- nodeps-- force * .rpm

Add scheduled task

Execute the command:

Crontab-e

Add: (backup is performed at 1 am every day)

0 1 *.. / usr/local/src/dbback/bkDatabaseName.sh

Thank you for reading this article carefully. I hope the article "CentOS7 enables MySQL8 master-slave backup and regular full backup every day" shared by the editor will be helpful to you. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report