場景:周日全備份,周一,周二增量備份,周三出現(xiàn)問題,數(shù)分鐘后發(fā)現(xiàn);
數(shù)據(jù)庫的安裝: yum install mariadb-server -y systemctl start mariadb yum install percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm 在10.2的高版本上默認(rèn)即時(shí)innodb_file_per_table;這里的版本是5.5,暫時(shí)沒開啟,需要手動(dòng)寫到配置文件中。 [root@MySQL ~]$ vim /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 innodb_file_per_table log_bin
[root@mysql ~]$mysql < hellodb_InnoDB.sql 全備份: [root@mysql ~]$mkdir -pv /backups [root@mysql ~]$ll /backups total 0 [root@mysql ~]$innobackupex /backups/ 周一數(shù)據(jù)修改后;晚上對(duì)數(shù)據(jù)進(jìn)行增量備份; MariaDB [(none)]> use hellodb; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [hellodb]> insert students(name,age,gender) values('a','28','F'); Query OK, 1 row affected (0.01 sec) [root@mysql ~]$mkdir /backups/{inc1,inc2} -pv mkdir: created directory ‘/backups/inc1’ mkdir: created directory ‘/backups/inc2’ [root@mysql ~]$innobackupex --incremental /backups/inc1/ --incremental-basedir=/backups/2018-02-25_15-21-53/ --incremental /backups/inc1/是指這是增量備份,以及備份的位置; --incremental-basedir=/backups/2018-02-25_15-21-53/是指基于哪個(gè)全備份或者增量備份的增量備份; [root@mysql ~]$ll /backups/ total 0 drwxr-x--- 6 root root 187 Feb 25 15:21 2018-02-25_15-21-53 drwxr-xr-x 3 root root 33 Feb 25 15:31 inc1 drwxr-xr-x 2 root root 6 Feb 25 15:25 inc2 [root@mysql ~]$ll /backups/inc1/ total 0 drwxr-x--- 6 root root 213 Feb 25 15:31 2018-02-25_15-31-17 周二的時(shí)候修改數(shù)據(jù),并進(jìn)行增量備份; MariaDB [hellodb]> insert students(name,age,gender) values('b','28','F'); Query OK, 1 row affected (0.01 sec) [root@mysql ~]$innobackupex --incremental /backups/inc2/ --incremental-basedir=/backups/inc1/2018-02-25_15-31-17/ [root@mysql ~]$du -sh /backups/ 23M /backups/ [root@mysql ~]$scp -pr /backups/ 192.168.27.17:/app/ [root@mysql17 ~]$ls /app/backups/ 2018-02-25_15-21-53 inc1 inc2 [root@mysql17 ~]$
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名與空間、雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、明溪網(wǎng)站維護(hù)、網(wǎng)站推廣。
數(shù)據(jù)庫的還原與數(shù)據(jù)整理操作:
備份還原: 還原的過程中MySQL服務(wù)是不啟動(dòng)的; 數(shù)據(jù)預(yù)整理: [root@mysql17 ~]$innobackupex --apply-log --redo-only /app/backups/2018-02-25_15-21-53/ --redo-only表示有相應(yīng)的增量備份; 將第一次增量備份的數(shù)據(jù)合并到完全備份中; [root@mysql17 ~]$innobackupex --apply-log --redo-only /app/backups/2018-02-25_15-21-53/ --incremental-dir=/app/backups/inc1/2018-02-25_15-31-17/ 將第二次增量備份的數(shù)據(jù)合并到完全備份中; [root@mysql17 ~]$innobackupex --apply-log --redo-only /app/backups/2018-02-25_15-21-53/ --incremental-dir=/app/backups/inc2/2018-02-25_15-34-00/ 如果數(shù)據(jù)目錄非空,那么就可以刪除他; [root@mysql17 ~]$ls /var/lib/mysql/ 將整理后的數(shù)據(jù)復(fù)制到數(shù)據(jù)目錄中; [root@mysql17 ~]$innobackupex --copy-back /app/backups/2018-02-25_15-21-53/ [root@mysql17 ~]$ll /var/lib/mysql/ total 18444 drwxr-x--- 2 root root 146 Feb 25 02:48 hellodb -rw-r----- 1 root root 18874368 Feb 25 02:48 ibdata1 drwxr-x--- 2 root root 4096 Feb 25 02:48 mysql drwxr-x--- 2 root root 4096 Feb 25 02:48 performance_schema drwxr-x--- 2 root root 20 Feb 25 02:48 test -rw-r----- 1 root root 481 Feb 25 02:48 xtrabackup_info [root@mysql17 ~]$ [root@mysql17 ~]$chown -R mysql.mysql /var/lib/mysql/ [root@mysql17 ~]$ll /var/lib/mysql/ total 18444 drwxr-x--- 2 mysql mysql 146 Feb 25 02:48 hellodb -rw-r----- 1 mysql mysql 18874368 Feb 25 02:48 ibdata1 drwxr-x--- 2 mysql mysql 4096 Feb 25 02:48 mysql drwxr-x--- 2 mysql mysql 4096 Feb 25 02:48 performance_schema drwxr-x--- 2 mysql mysql 20 Feb 25 02:48 test -rw-r----- 1 mysql mysql 481 Feb 25 02:48 xtrabackup_info [root@mysql17 ~]$
啟動(dòng)數(shù)據(jù)庫,核對(duì)數(shù)據(jù)庫數(shù)據(jù):
[root@mysql17 ~]$systemctl start mariadb [root@mysql17 ~]$mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> select * from hellodb.students; +-------+---------------+-----+--------+---------+-----------+ | StuID | Name | Age | Gender | ClassID | TeacherID | +-------+---------------+-----+--------+---------+-----------+ | 1 | Shi Zhongyu | 22 | M | 2 | 3 | | 2 | Shi Potian | 22 | M | 1 | 7 | | 3 | Xie Yanke | 53 | M | 2 | 16 | | 4 | Ding Dian | 32 | M | 4 | 4 | | 5 | Yu Yutong | 26 | M | 3 | 1 | | 6 | Shi Qing | 46 | M | 5 | NULL | | 7 | Xi Ren | 19 | F | 3 | NULL | | 8 | Lin Daiyu | 17 | F | 7 | NULL | | 9 | Ren Yingying | 20 | F | 6 | NULL | | 10 | Yue Lingshan | 19 | F | 3 | NULL | | 11 | Yuan Chengzhi | 23 | M | 6 | NULL | | 12 | Wen Qingqing | 19 | F | 1 | NULL | | 13 | Tian Boguang | 33 | M | 2 | NULL | | 14 | Lu Wushuang | 17 | F | 3 | NULL | | 15 | Duan Yu | 19 | M | 4 | NULL | | 16 | Xu Zhu | 21 | M | 1 | NULL | | 17 | Lin Chong | 25 | M | 4 | NULL | | 18 | Hua Rong | 23 | M | 7 | NULL | | 19 | Xue Baochai | 18 | F | 6 | NULL | | 20 | Diao Chan | 19 | F | 7 | NULL | | 21 | Huang Yueying | 22 | F | 6 | NULL | | 22 | Xiao Qiao | 20 | F | 1 | NULL | | 23 | Ma Chao | 23 | M | 4 | NULL | | 24 | Xu Xian | 27 | M | NULL | NULL | | 25 | Sun Dasheng | 100 | M | NULL | NULL | | 26 | a | 28 | F | NULL | NULL | | 27 | b | 28 | F | NULL | NULL | +-------+---------------+-----+--------+---------+-----------+ 27 rows in set (0.01 sec)
新聞標(biāo)題:數(shù)據(jù)庫的備份與還原系列——全備份+兩增量的備份與還原
網(wǎng)站路徑:http://vcdvsql.cn/article24/iipcce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、商城網(wǎng)站、動(dòng)態(tài)網(wǎng)站、網(wǎng)站排名、網(wǎng)站內(nèi)鏈、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)