1.centos7 安裝(centos6 去官方下載相應(yīng)版本即可)
成都創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司與策劃設(shè)計(jì),王屋網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:王屋等地區(qū)。王屋做網(wǎng)站價(jià)格咨詢:18980820575
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.7-2.el7.x86_64.rpm yum localinstall percona-xtrabackup-24-2.4.7-2.el7.x86_64.rpm
2.使用備份(全備份)
innobackupex --user=root --password=123456 /home/backupdb/[root@master 2017-07-17_01-55-14]# pwd/home/backupdb/2017-07-17_01-55-14[root@master 2017-07-17_01-55-14]# lltotal 18456-rw-r----- 1 root root 417 Jul 17 01:55 backup-my.cnf-rw-r----- 1 root root 18874368 Jul 17 01:55 ibdata1drwxr-x--- 2 root root 4096 Jul 17 01:55 MySQLdrwxr-x--- 2 root root 4096 Jul 17 01:55 performance_schemadrwxr-x--- 2 root root 19 Jul 17 01:55 test-rw-r----- 1 root root 113 Jul 17 01:55 xtrabackup_checkpoints-rw-r----- 1 root root 432 Jul 17 01:55 xtrabackup_info-rw-r----- 1 root root 2560 Jul 17 01:55 xtrabackup_logfile[root@master 2017-07-17_01-55-14]# 生成備份日志 innobackupex --user=root --password=123456 --apply-log /home/backupdb/2017-07-17_01-52-14 [root@master 2017-07-17_01-55-14]# lltotal 49172-rw-r----- 1 root root 417 Jul 17 01:55 backup-my.cnf-rw-r----- 1 root root 18874368 Jul 17 01:56 ibdata1-rw-r----- 1 root root 5242880 Jul 17 01:56 ib_logfile0-rw-r----- 1 root root 5242880 Jul 17 01:56 ib_logfile1-rw-r----- 1 root root 12582912 Jul 17 01:56 ibtmp1drwxr-x--- 2 root root 4096 Jul 17 01:55 mysqldrwxr-x--- 2 root root 4096 Jul 17 01:55 performance_schemadrwxr-x--- 2 root root 19 Jul 17 01:55 test-rw-r----- 1 root root 113 Jul 17 01:56 xtrabackup_checkpoints-rw-r----- 1 root root 432 Jul 17 01:55 xtrabackup_info-rw-r----- 1 root root 8388608 Jul 17 01:56 xtrabackup_logfile
3.還原(全部還原)
[root@master 2017-07-17_01-55-14]# ps -ef |grep mysql mysql 2434 1 0 01:47 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mysql 2591 2434 0 01:47 ? 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock root 2879 2126 0 01:57 pts/0 00:00:00 grep --color=auto mysql [root@master 2017-07-17_01-55-14]# cd /var/lib/mysql/ [root@master mysql]# ls aria_log.00000001 aria_log_control ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock performance_schema test [root@master mysql]# ll total 28700 -rw-rw---- 1 mysql mysql 16384 Jul 17 01:47 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Jul 17 01:47 aria_log_control -rw-rw---- 1 mysql mysql 18874368 Jul 17 01:47 ibdata1 -rw-rw---- 1 mysql mysql 5242880 Jul 17 01:47 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 Jul 17 01:47 ib_logfile1 drwx------ 2 mysql mysql 4096 Jul 17 01:47 mysql srwxrwxrwx 1 mysql mysql 0 Jul 17 01:47 mysql.sock drwx------ 2 mysql mysql 4096 Jul 17 01:47 performance_schema drwx------ 2 mysql mysql 6 Jul 17 01:47 test [root@master mysql]# rm -rf test [root@master mysql]# [root@master mysql]# systemctl stop mariadb [root@master mysql]# rm -rf /var/lib/mysql/* 還原并啟動(dòng)數(shù)據(jù)庫 innobackupex --defaults-file=/etc/my.cnf --copy-back /home/backupdb/2017-07-17_01-55-14/ 默認(rèn)還原過來的數(shù)據(jù)是root權(quán)限 數(shù)據(jù)庫啟動(dòng)不起來 chown -R mysql.mysql /var/lib/mysql [root@master mysql]# systemctl start mariadb [root@master mysql]# mysql -uroot -p123456 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) MariaDB [(none)]> 數(shù)據(jù)全部回來
4.增量備份
mkdir -p /home/backupdb/{1,2,3} [root@master backupdb]# innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 /home/backupdb/1/ 如果數(shù)據(jù)庫有改動(dòng)可以增量備份 innobackupex --defaults-file=/etc/my.cnf --incremental /home/backupdb/2/ --incremental-basedir=/home/backupdb/1/2017-07-17_02-16-32/ --user=root --password=123456 --incremental 增量備份到那個(gè)目錄 --incremental-basedir 基于哪個(gè)目錄進(jìn)行增量備份 假如數(shù)據(jù)庫再次修改 innobackupex --defaults-file=/etc/my.cnf --incremental /home/backupdb/3/ --incremental-basedir=/home/backupdb/2/2017-07-17_02-19-47/ --user=root --password=123456
5.增量備份的數(shù)據(jù)恢復(fù)
先恢復(fù)第一次全被的數(shù)據(jù)
innobackupex --defaults-file=/etc/my.cnf --copy-back /home/backupdb/1/2017-07-17_02-16-32/
2.增量恢復(fù)
innobackupex --apply-log --redo-only /home/backupdb/1/2017-07-17_02-16-32/ innobackupex --apply-log --redo-only /home/backupdb/1/2017-07-17_02-16-32/ --incremental-dir=/home/backupdb/2/2017-07-17_02-19-47/ innobackupex --apply-log --redo-only /home/backupdb/1/2017-07-17_02-16-32/ --incremental-dir=/home/backupdb/3/2017-07-17_02-23-41/
3.恢復(fù)數(shù)據(jù)
innobackupex --copy-back /home/backupdb/1/2017-07-17_02-16-32/
4.可以看出數(shù)據(jù)已經(jīng)回來
[root@master mysql]# ll /var/lib/mysql/ total 18444 -rw-r----- 1 root root 18874368 Jul 17 02:41 ibdata1 drwxr-x--- 2 root root 4096 Jul 17 02:41 mysql drwxr-x--- 2 root root 4096 Jul 17 02:41 performance_schema drwxr-x--- 2 root root 19 Jul 17 02:41 test drwxr-x--- 2 root root 19 Jul 17 02:41 test02 -rw-r----- 1 root root 542 Jul 17 02:41 xtrabackup_info [root@master mysql]# chown -R mysql.mysql * [root@master mysql]#
5.啟動(dòng)數(shù)據(jù)庫
[root@master lib]# systemctl start mariadb [root@master lib]# mysql -uroot -p123456 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | test02 | +--------------------+ 5 rows in set (0.00 sec) MariaDB [(none)]>
extrabackup備份的時(shí)候 備份mysql的時(shí)候安裝不兼容 這次
我是備份的mariadb
當(dāng)前題目:extrabackup
網(wǎng)頁網(wǎng)址:http://m.newbst.com/article10/jicjdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、微信公眾號(hào)、虛擬主機(jī)、企業(yè)網(wǎng)站制作、ChatGPT、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)