当前位置:网站首页>Xtrabackup backup and recovery

Xtrabackup backup and recovery

2022-06-09 05:25:00 Anonymous s

xtrabackup

XtraBackup(PXB) The tool is Percona Company use perl One of the tools of language development is for MySQL Backup tool for physical hot backup of database , Support MySQl(Oracle)、Percona Server and MariaDB, And all open source , It's the conscience of the industry . Ali's RDS MySQL Physical backup is based on this tool . Because it is backed up by physical copy , So it's very fast , Dozens of G The data is done in a few minutes , And it cleverly uses mysql Features to achieve online hot backup , You don't have to shut down the database like you used to do a physical backup , The full backup and incremental backup of the whole database or part of the database can be completed directly online .

install

  1. Installation warehouse Install the Percona repository
    yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm

  2. Test whether the warehouse contains the latest version of resources
    yum list | grep percona

  3. install packages
    yum install percona-xtrabackup-24

  4. Installation error

    terms of settlement yum update percona-release

The data backup 1

  1. Full volume backup
    innobackupex ----defaults-file=/etc/my.cnf --user=root --password=root /root/back

Data recovery

  1. Shut down the database service
    service mysql stop

  2. Execute the data recovery command *( Be careful my.cnf Internally configured datadir Directory must be an empty directory , So before restoring data , First datadir To another directory , Then create an empty directory and perform the recovery )
    innobackupex --defaults-file=/etc/my.cnf --copy-back --rsync /path/to/backup

  3. Change permissions for the newly created directory
    chown -R mysql. /app/mysql/data

  4. start-up mysql service
    service mysql start

The data backup 2- Streaming backup

#!/bin/bash
defaults_file="/etc/my.cnf" # mysql Profile location

user=“root” #mysql account number

password=“aaaaaa” #mysql password

backup_dir="/mnt/database_backup/dir/" # The root directory that needs to be archived

name="$(date +"%Y%m%d")"

shell=‘innobackupex --defaults-file=‘ d e f a u l t s f i l e ′ − − u s e r = ′ defaults_file' --user=' defaultsfileuser=user’ --password=‘ p a s s w o r d ′ − − s t r e a m = t a r / m n t / s t o r a g e d a t a b a s e / t e m p ∣ s s h r o o t @ want Hair send Of i p " g z i p − > ′ password' --stream=tar /mnt/storage_database/temp | ssh [email protected] To send ip "gzip -> ' passwordstream=tar/mnt/storagedatabase/tempsshroot@ want Hair send Of ip"gzip>backup_dir$name’.tar.gz"’

eval $shell

原网站

版权声明
本文为[Anonymous s]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021428224191.html