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

Docker Operation and maintenance deployment-mysql Hot backup data handout

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

Share

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

This article mainly gives you a brief introduction to docker chemical operation and maintenance deployment-mysql hot backup data handout. You can check the relevant professional terms on the Internet or find some related books to supplement them. I will not dabble here and go straight to the topic. I hope I can bring you some practical help.

Cold backup is the backup method when the database is closed. The usual practice is to copy data files. Cold backup is the simplest and safest backup method. Large websites cannot close business backup data, so cold backup is not the best choice for PXC cold backup.

First, take one of the PXC offline, and then complete the backup by copying the data files. After the backup, the offline PXC is online, complete with the automatic synchronization of other nodes.

Hot backup hot backup is the backup of data when the system is running, and it is also the most difficult backup. For example, if Taobao offline 1 hour backup data, Taobao lost how much money, who suffered ah. This is all white silver. LVM and XtraBackup are two common hot backup schemes for Mysql. LVM is aimed at partition backup, for linux system, he claims that any kind of database can be backed up, but there is a drawback that it can only be read but not written when backing up. It is recommended to use XtrBackup hot backup Mysql, which does not need a lock, can be read or written when backing up, and XtraBackup is free.

# XtrBackup

Is an online hot backup tool based on InnoDB, with open source free, support online hot backup, small disk space, can very fast backup and restore mysql database. It supports various derivative versions of mysql.

XtraBackup advantage

The backup process does not lock the table, and the fast and reliable backup process will not interrupt the ongoing transaction. Full backup and incremental backup can save disk space and traffic based on functions such as compression. Full backup is to back up all data, backup process time, and take up a lot of space. Incremental backup is to back up only the changed part of the data. Backup time is short. It takes up a little space.

On a normal production system, it is common to make full backups once a week and incremental backups once a week. Enough.

Preparation for XtraBackup installation

This tool is required to be within the node of the database. The data from the backup is direct. You need to create a data volume that will be used to back up the files generated by XtraBackup and then map to the host's disk.

Create a data volume

Docker volume create backup

Stop one of the nodes and select node1 here to delete the node1 and add the newly created data volume. New data volumes cannot be added to containers that are already running. As long as the data volume of v1 is mounted, the file of v1 is not deleted, so the data will not be lost.

Docker stop node1docker rm node1

Reinstall node1 to mount the new node and synchronize the other 4 nodes. -- CLUSTER_JONIN=node2 the newly created node1 to synchronize the node2 node.

Docker run-d-p 3306 CLUSTER_NAME=PXC 3306-- net=net1-- name=node1\-e CLUSTER_NAME=PXC\-e MYSQL_ROOT_PASSWORD=a123456\-e XTRABACKUP_PASSWORD=a123456\-v v1:/var/lib/mysql\-- privileged\-- ip 172.18.0.2\-v backup:/data\-e CLUSTER_JOIN=node2\ percona/percona-xtradb-clusterPXC

Secure XtraBackup in the PXC container and perform backup. I regret that I didn't find an image with XtraBackup directly when I was in PXC.

Docker exec-it-- user root node1echo "nameserver 8.8.8.8" | tee / etc/resolv.conf > / dev/null apt-get cleanapt-get updateapt-get install vimvi / etc/apt/sources.list

Sources.list adds the following

Deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted Commands for full backup of deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restrictedapt-get cleanapt-get updateapt-get install percona-xtrabackup-24

Completed OK appears! Indicates that the backup is complete.

Innobackupex-- user=root-- password=a123456 / data/backup/fullPXC full recovery steps

The database can be hot backed up, but not hot restored. In order to avoid data synchronization in the recovery process, we use a blank mysql to restore the data, and then establish a PXC cluster. Therefore, in the development, we must pay attention to the issue of permissions, do not give developers root users.

Roll back the uncommitted transactions before restoring the data, and restart after restoring the data! Execute the code

Delete all the original containers

Docker stop node1 node2 node3 node4 node5docker rm node1 node2 node3 node4 node5docker volume rm v1 v2 v3 v4 v5docker volume create v1

Create node1 and data volumes

Docker volume create v1docker run-d-p 3306 CLUSTER_NAME=PXC 3306-- net=net1-- name=node1\-e CLUSTER_NAME=PXC\-e MYSQL_ROOT_PASSWORD=a123456\-e XTRABACKUP_PASSWORD=a123456\-v v1:/var/lib/mysql\-- privileged\-- ip 172.18.0.2\-v backup:/data\ percona/percona-xtradb-cluster

Enter the container to restore the database

# root users log in to docker exec-it-- user root node1 bash# delete data rm-rf / var/lib/mysql/*# unsubmitted data rollback innobackupex-- user=root-- password=a123456-- apply-back / data/backup/full/2018-12-06 data 17-18-19 data/backup/full/2018 # perform a cold restore innobackupex-- user=root-- password=a123456-- copy-back / data/backup/full/2018-12-06 data 17-18-19/chown-R mysql:mysql / var/lib/mysql/

Node1 node under exit container restart

Docker stop node1docker start node1

Docker chemical operation and maintenance deployment-mysql hot backup data handout to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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