MySQL數據庫備份與恢復 Part 5:Xtrabackup 企業級備份實戰 --- MySQL 8

1 關於MySQL8.0新的密碼認證方式

The caching_sha2_password and sha256_password authentication plugins provide more secure password encryption than the mysql_native_password plugin, and caching_sha2_password provides better performance than sha256_password. Due to these superior security and performance characteristics of caching_sha2_password, it is as of MySQL 8.0 the preferred authentication plugin, and is also the default authentication plugin rather than mysql_native_password.
 

用戶默認認證插件

mysql> show variables like '%auth%';
+-------------------------------+-----------------------+
| Variable_name                 | Value                 |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set (0.00 sec)


mysql> select user,plugin from mysql.user where user='backup';
+------------------+-----------------------+
| user             | plugin                |
+------------------+-----------------------+
| backup           | caching_sha2_password |
+------------------+-----------------------+
1 rows in set (0.00 sec)

2 Xtrabackup2.4 備份MySQL8數據庫問題

錯誤日誌如下

xtrabackup: recognized server arguments: --datadir=/app/mysql8/data --server-id=10 --innodb_buffer_pool_size=512M 
xtrabackup: recognized client arguments: --datadir=/app/mysql8/data --server-id=10 --innodb_buffer_pool_size=512M 
190904 10:22:22 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

190904 10:22:22  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/app/mysql8/tmp/mysql.sock' as 'backup'  (using password: YES).
Failed to connect to MySQL server: DBI connect(';mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/app/mysql8/tmp/mysql.sock','backup',...) failed: Authentication plugin 'caching_sha2_password
' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory at - line 1314.
190904 10:22:22 Connecting to MySQL server host: localhost, user: backup, password: set, port: 3306, socket: /app/mysql8/tmp/mysql.sock
Failed to connect to MySQL server: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/xtrabackup/plugin/caching_sha2_password.so: cannot open shared object file: No such file or 
directory.

 'caching_sha2_password'插件的驅動文件沒有被發現。搜索之後,服務器中爲發現此驅動程序(包括mysql8的相關目錄)。

3 Xtrabackup8備份

Percona公司針對mysql8數據庫推出了Xtrabackup8版本。此版本可成功備份MySQL8,雖然‘caching_sha2_password.so’扔沒有被找到,但可以備份成功。

xtrabackup: recognized server arguments: --datadir=/app/mysql8/data --server-id=10 --innodb_buffer_pool_size=512M 
xtrabackup: recognized client arguments: --user=backup --password=* --host=mysql8 --port=3306 --socket=/app/mysql8/tmp/mysql.sock --backup=1 --target-dir=/app/bak/xtra_inc_201909061027 
/usr/bin/xtrabackup version 8.0.7 based on MySQL server 8.0.16 Linux (x86_64) (revision id: 069e0e6)
190906 10:28:18  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=mysql8;port=3306;mysql_socket=/app/mysql8/tmp/mysql.sock' as 'backup'  (using p
assword: YES).
Failed to connect to MySQL server: DBI connect(';mysql_read_default_group=xtrabackup;host=mysql8;port=3306;mysql_socket=/app/mysql8/tmp/mysql.sock','backup',...) failed: Authentication plugin 'cachin
g_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory at - line 1535.
190906 10:28:18 Connecting to MySQL server host: mysql8, user: backup, password: set, port: 3306, socket: /app/mysql8/tmp/mysql.sock
Using server version 8.0.16
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /app/mysql8/data
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
Number of pools: 1
WARNING: unknown option --no-timestamp
WARNING: unknown option --no-timestamp
190906 10:28:18 >> log scanned up to (656642476)
xtrabackup: Generating a list of tablespaces
Directories to scan '.;./;.'
Scanning './'
Completed space ID check of 2 files.
Allocated tablespace ID 50 for tj_tasly/basic_attach, old maximum was 0
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
190906 10:28:18 [01] Copying ./tj_tasly/basic_dt_industry_disease_df.ibd to /app/bak/xtra_inc_201909061027/tj_tasly/basic_dt_industry_disease_df.ibd
190906 10:28:18 [01]        ...done
190906 10:28:18 [01] Copying ./ibdata1 to /app/bak/xtra_inc_201909061027/ibdata1
190906 10:28:18 [01]        ...done

.
.
.
.

190906 10:28:20 [01] Copying ./tj_tasly/basic_dt_industry_disease_cn.ibd to /app/bak/xtra_inc_201909061027/tj_tasly/basic_dt_industry_disease_cn.ibd
190906 10:28:20 [01]        ...done
190906 10:28:20 [01] Copying ./tj_tasly/basic_dt_industry_disease_detail.ibd to /app/bak/xtra_inc_201909061027/tj_tasly/basic_dt_industry_disease_detail.ibd
190906 10:28:20 [01]        ...done
190906 10:28:20 >> log scanned up to (656642476)
190906 10:28:20 [01] Copying ./undo_002 to /app/bak/xtra_inc_201909061027/undo_002
190906 10:28:20 [01]        ...done
190906 10:28:20 [01] Copying ./undo_001 to /app/bak/xtra_inc_201909061027/undo_001
190906 10:28:20 [01]        ...done
190906 10:28:20 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
190906 10:28:20 Executing FLUSH TABLES WITH READ LOCK...
190906 10:28:20 Starting to backup non-InnoDB tables and files
190906 10:28:20 [01] Copying mysql/general_log_201.sdi to /app/bak/xtra_inc_201909061027/mysql/general_log_201.sdi
190906 10:28:20 [01]        ...done
190906 10:28:20 [01] Copying mysql/general_log.CSM to /app/bak/xtra_inc_201909061027/mysql/general_log.CSM
190906 10:28:20 [01]        ...done

.
.
.
.

190906 10:28:22 [01] Copying tj_tasly/sys_role_menu.MYD to /app/bak/xtra_inc_201909061027/tj_tasly/sys_role_menu.MYD
190906 10:28:22 [01]        ...done
190906 10:28:22 [01] Copying tj_tasly/sys_user_470.sdi to /app/bak/xtra_inc_201909061027/tj_tasly/sys_user_470.sdi
190906 10:28:22 [01]        ...done
190906 10:28:22 Finished backing up non-InnoDB tables and files
190906 10:28:22 Executing FLUSH NO_WRITE_TO_BINLOG BINARY LOGS
190906 10:28:22 Selecting LSN and binary log position from p_s.log_status
190906 10:28:22 [00] Copying /app/mysql8/data/binlog.000007 to /app/bak/xtra_inc_201909061027/binlog.000007 up to position 155
190906 10:28:22 [00]        ...done
190906 10:28:22 [00] Writing /app/bak/xtra_inc_201909061027/binlog.index
190906 10:28:22 [00]        ...done
190906 10:28:22 [00] Writing /app/bak/xtra_inc_201909061027/xtrabackup_binlog_info
190906 10:28:22 [00]        ...done
190906 10:28:22 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '656642476'
xtrabackup: Stopping log copying thread at LSN 656642476.
.190906 10:28:22 >> log scanned up to (656642476)
190906 10:28:22 >> log scanned up to (656642476)

190906 10:28:22 Executing UNLOCK TABLES
190906 10:28:22 All tables unlocked
190906 10:28:22 [00] Copying ib_buffer_pool to /app/bak/xtra_inc_201909061027/ib_buffer_pool
190906 10:28:22 [00]        ...done
190906 10:28:22 Backup created in directory '/app/bak/xtra_inc_201909061027/'
MySQL binlog position: filename 'binlog.000007', position '155'
190906 10:28:22 [00] Writing /app/bak/xtra_inc_201909061027/backup-my.cnf
190906 10:28:22 [00]        ...done
190906 10:28:22 [00] Writing /app/bak/xtra_inc_201909061027/xtrabackup_info
190906 10:28:22 [00]        ...done
xtrabackup: Transaction log of lsn (656642476) to (656642476) was copied.
190906 10:28:22 completed OK!

注:修改備份用戶的認證方式可以消除報錯。

alter user 'backup'@'mysql8' identified with mysql_native_password by 'password';

4 Xtrabackup8 備份腳本

#!/bin/bash
# filename      : XtraBackup.sh
# Author        : liyang
day=`date +%w`
dt=`date +%Y%m%d`
lastday=`date -d '1 days ago' +%Y%m%d`
user=backup
pwd=password
port=3306
host=mysql8
sock=/app/mysql8/tmp/mysql.sock
log=backuplog.`date +%Y%m%d`

case $day in  
    0)  
        # Sunday Full backup
        find /app/bak -name "xtra_*" -mtime +31 -exec rm -rf {} \;
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_base_$dt > /app/b
ak/logs/$log 2>&1
        ;;  
    1)  
        # Monday Relatively Sunday's incremental backup  
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_in
c_$dt --incremental-basedir=/app/bak/xtra_base_$lastday > /app/bak/logs/$log 2>&1  
        ;;  
    2)  
        # Tuesday Compared with Monday's incremental backup  
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_i
nc_$dt --incremental-basedir=/app/bak/xtra_inc_$lastday > /app/bak/logs/$log 2>&1     
        ;;  
    3)  
        # Wednesday Full backup
        find /app/bak/ -name "xtra_*" -mtime +31 -exec rm -rf {} \;
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_base_$dt > /app/b
ak/logs/$log 2>&1   
        ;;  
    4)  
        # Thursday  Relatively Wednesday's incremental backup  
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_i
nc_$dt --incremental-basedir=/app/bak/xtra_base_$lastday > /app/bak/logs/$log 2>&1    
        ;;  
    5)  
        # Friday Compared with Thursday's incremental backup  
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_i
nc_$dt --incremental-basedir=/app/bak/xtra_inc_$lastday > /app/bak/logs/$log 2>&1    
        ;;  
    6)  
        # Saturday Compared with Friday's incremental backup  
        /usr/bin/xtrabackup --defaults-file=/app/mysql8/my.cnf  --user=$user --password=$pwd --port=$port --host=$host --socket=$sock --backup --target_dir=/app/bak/xtra_i
nc_$dt --incremental-basedir=/app/bak/xtra_inc_$lastday > /app/bak/logs/$log 2>&1   
        ;;  
esac 
find /app/bak/logs -mtime +31 -type f -name 'backuplog.*' -exec rm -rf {} \;

xtrabackup8移除了innobackupex命令,使用xtrabackup備份。xtrabackup8需要添加參數‘--host’、'--backup'、‘--target_dir’。

--host 指定訪問主機,與mysql.user的配置一致,否則無法登錄

--backup 備份操作,備份到target-dir指定的目錄

--target_dir 備份文件存儲目錄

5 Xtrabackup 恢復腳本

#!/bin/bash
# filename      : xtrabackup_recover.sh
# Author        : liyang 
day=`date +%w`
dt=`date +%Y%m%d`
lastday=`date -d '1 days ago' +%Y%m%d`
lasttwoday=`date -d '2 days ago' +%Y%m%d`
lastthreeday=`date -d '3 days ago' +%Y%m%d`
user=backup
pwd='backup1234'
rpwd='root1234'
log=recoverlog.`date +%Y%m%d`
MYSQL_BASE=/app/mysql8
MYSQL_DATA=/app/mysql8/data
BAK_BASE=/app/bak
BAK_LOG=/app/bak/logs
REC_DATA=/app/bak/mysqldata
REC_BIN_LOG=/app/bak/mysqllog
case $day in  
    0)  
        # Sunday Recover Database 
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$dt > $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$dt >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf &
        binlog=`cat $BAK_BASE/xtra_base_$dt/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$dt/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    1)  
        # Monday Recover Database 
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastday > $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastday/ --incremental-dir=$BAK_BASE/xtra_inc_$dt/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare $BAK_BASE/xtra_base_$lastday >> $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$lastday >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf &
        binlog=`cat $BAK_BASE/xtra_base_$lastday/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$lastday/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --no-defaults --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    2)  
        # Tuesday Recover Database
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday > $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday/ --incremental-dir=$BAK_BASE/xtra_inc_$lastday/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday/ --incremental-dir=$BAK_BASE/xtra_inc_$dt/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare $BAK_BASE/xtra_base_$lasttwoday >> $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$lasttwoday >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf &
        binlog=`cat $BAK_BASE/xtra_base_$lasttwoday/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$lasttwoday/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    3)  
        # Wednesday Recover Database 
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$dt > $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$BAK_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$dt >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf & 
        binlog=`cat $BAK_BASE/xtra_base_$dt/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$dt/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    4)  
        # Thursday  Recover Database 
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastday > $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastday/ --incremental-dir=$BAK_BASE/xtra_inc_$dt/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare $BAK_BASE/xtra_base_$lastday >> $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$lastday >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf & 
        binlog=`cat $BAK_BASE/xtra_base_$lastday/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$lastday/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    5)  
        # Friday Recover Database  
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday > $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday/ --incremental-dir=$BAK_LOG/xtra_inc_$lastday/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lasttwoday/ --incremental-dir=$BAK_LOG/xtra_inc_$dt/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare $BAK_BASE/xtra_base_$lasttwoday >> $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$lasttwoday >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf &
        binlog=`cat $BAK_BASE/xtra_base_$lasttwoday/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$lasttwoday/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
    6)  
        # Saturday Recover Database  
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastthreeday > $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastthreeday/ --incremental-dir=$BAK_BASE/xtra_inc_$lasttwoday/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastthreeday/ --incremental-dir=$BAK_BASE/xtra_inc_$lastday/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare --apply-log-only $BAK_BASE/xtra_base_$lastthreeday/ --incremental-dir=$BAK_BASE/xtra_inc_$dt/ >> $BAK_LOG/$log 2>&1
        /usr/bin/xtrabackup --prepare $BAK_BASE/xtra_base_$lastthreeday >> $BAK_LOG/$log 2>&1
        $MYSQL_BASE/bin/mysqladmin -uroot -p$rpwd -S $MYSQL_BASE/tmp/mysql.sock shutdown &
        rm -rf $MYSQL_DATA/*
        /usr/bin/xtrabackup --defaults-file=$MYSQL_BASE/my.cnf --copy-back $BAK_BASE/xtra_base_$lastthreeday >> $BAK_LOG/$log 2>&1
        chown -R mysql:mysql $BAK_BASE
        $MYSQL_BASE/bin/mysqld_safe --defaults-file=$MYSQL_BASE/my.cnf &
        binlog=`cat $BAK_BASE/xtra_base_$lastthreeday/xtrabackup_binlog_info|awk '{print $1}'`
        pos=`cat $BAK_BASE/xtra_base_$lastthreeday/xtrabackup_binlog_info|awk '{print $2}'`
        $MYSQL_BASE/bin/mysqlbinlog --defaults-file=$MYSQL_BASE/my.cnf --start-position=$pos $REC_BIN_LOG/$binlog | $MYSQL_BASE/bin/mysql -u$user -p$pwd
        ;;  
esac 
#find $BAK_LOG -mtime +6 -type f -name 'recoverlog.*' -exec rm -rf {} \;

參考 Changes Affecting Upgrades to MySQL 8.0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章