久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔
站長百科 | 數(shù)字化技能提升教程 數(shù)字化時代生存寶典
首頁
數(shù)字化百科
電子書
建站程序
開發(fā)
服務(wù)器
辦公軟件
開發(fā)教程
服務(wù)器教程
軟件使用教程
運營教程
熱門電子書
WordPress教程
寶塔面板教程
CSS教程
Shopify教程
導(dǎo)航
程序頻道
推廣頻道
網(wǎng)賺頻道
人物頻道
網(wǎng)站程序
網(wǎng)頁制作
云計算
服務(wù)器
CMS
論壇
網(wǎng)店
虛擬主機
cPanel
網(wǎng)址導(dǎo)航
WIKI使用導(dǎo)航
WIKI首頁
最新資訊
網(wǎng)站程序
站長人物
頁面分類
使用幫助
編輯測試
創(chuàng)建條目
網(wǎng)站地圖
站長百科導(dǎo)航
站長百科
主機偵探
IDCtalk云說
跨境電商導(dǎo)航
WordPress啦
站長專題
網(wǎng)站推廣
網(wǎng)站程序
網(wǎng)站賺錢
虛擬主機
cPanel
網(wǎng)址導(dǎo)航專題
云計算
微博營銷
虛擬主機管理系統(tǒng)
開放平臺
WIKI程序與應(yīng)用
美國十大主機
編輯“
CentOS/數(shù)據(jù)庫的自動備份與恢復(fù)
”
人物百科
|
營銷百科
|
網(wǎng)賺百科
|
站長工具
|
網(wǎng)站程序
|
域名主機
|
互聯(lián)網(wǎng)公司
|
分類索引
跳轉(zhuǎn)至:
導(dǎo)航
、?
搜索
警告:
您沒有登錄。如果您做出任意編輯,您的IP地址將會公開可見。如果您
登錄
或
創(chuàng)建
一個賬戶,您的編輯將歸屬于您的用戶名,且將享受其他好處。
反垃圾檢查。
不要
加入這個!
{{CentOS top}} 當(dāng)[[數(shù)據(jù)庫]]服務(wù)器建立好以后,我們首先要做的不是考慮要在這個支持數(shù)據(jù)庫的[[服務(wù)器]]運行哪些受[[MySQL]]提攜的程序,而是當(dāng)數(shù)據(jù)庫遭到破壞后,怎樣安然恢復(fù)到最后一次正常的狀態(tài),使得數(shù)據(jù)的損失達到最小。 或者說,僅僅是數(shù)據(jù)庫服務(wù)器的建立,只能說明它能做些什么,并不代表它能穩(wěn)定的做些什么。災(zāi)難恢復(fù)的效率及全面性,也是系統(tǒng)的穩(wěn)定性的一個準因素,尤其對于一個服務(wù)器系統(tǒng)。 本條目介紹數(shù)據(jù)庫自動備份以及數(shù)據(jù)庫被破壞后的恢復(fù)的方法。在這里,我們使用mysqlhotcopy,并且定義一段Shell[[腳本]]來實現(xiàn)數(shù)據(jù)庫的自動備份,并且,讓整個數(shù)據(jù)自動備份與數(shù)據(jù)恢復(fù)過程都基于Shell。 ==建立數(shù)據(jù)庫備份所需條件== [1] 建立自動備份腳本 在這里,為了使數(shù)據(jù)庫備份和恢復(fù)的符合我們的實際要求,用一段符合要求的Shell腳本來實現(xiàn)整個備份過程的自動化。 <pre>[root@sample ~]# vi mysql-backup.sh ← 建立數(shù)據(jù)庫自動備份腳本,如下: #!/bin/bash PATH=/usr/local/sbin:/usr/bin:/bin # The Directory of Backup BACKDIR=/backup/mysql # The Password of MySQL ROOTPASS=******** ← 將星號替換成MySQL的root密碼 # Remake the Directory of Backup rm -rf $BACKDIR mkdir -p $BACKDIR # Get the Name of Database DBLIST=`ls -p /var/lib/mysql | grep / | tr -d /` # Backup with Database for dbname in $DBLIST do mysqlhotcopy $dbname -u root -p $ROOTPASS $BACKDIR | logger -t mysqlhotcopy done</pre> [2] 運行數(shù)據(jù)庫自動備份腳本 <pre>[root@sample ~]# chmod 700 mysql-backup.sh ← 改變腳本屬性,讓其只能讓root用戶執(zhí)行 [root@sample ~]# ./mysql-backup.sh ← 運行腳本 [root@sample ~]# ls -l /backup/mysql/ ← 確認一下是否備份成功 total 8 drwxr-x--- 2 mysql mysql 4096 Sep 1 16:54 mysql ← 已成功備份到/backup/mysql目錄中</pre> [3] 讓數(shù)據(jù)庫備份腳本每天自動運行 <pre>[root@sample ~]# crontab -e ← 編輯自動運行規(guī)則(然后會出現(xiàn)編輯窗口,操作同vi) 00 03 * * * /root/mysql-backup.sh ← 添加這一行到文件中,讓數(shù)據(jù)庫備份每天凌晨3點進行</pre> ==備份恢復(fù)的方法== 當(dāng)數(shù)據(jù)庫被刪除后的恢復(fù)方法: 首先建立一個測試用的數(shù)據(jù)庫。 <pre>[root@sample ~]# mysql -u root -p ← 用root登錄到MySQL服務(wù)器 Enter password: ← 輸入MySQL的root用戶密碼 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database test; ← 建立一個測試用的數(shù)據(jù)庫test Query OK, 1 row affected (0.00 sec) mysql> use test ← 連接到這個數(shù)據(jù)庫 Database changed mysql> create table test(num int, name varchar(50)); ← 在數(shù)據(jù)庫中建立一個表 Query OK, 0 rows affected (0.07 sec) mysql> insert into test values(1,'Hello,BSD'); ← 插入一個值到這個表(這里以“Hello,BSD”為例) Query OK, 1 row affected (0.02 sec) mysql> select * from test; ← 查看數(shù)據(jù)庫中的內(nèi)容 +------+-------------+ | num | name | +------+-------------+ |1 | Hello,BSD | ← 確認剛剛插入到表中的值的存在 +------+-------------+ 1 row in set (0.01 sec) mysql> exit ← 退出MySQL服務(wù)器 Bye</pre> 然后,運行剛才建立的數(shù)據(jù)庫備份腳本,備份剛剛建立的測試用的數(shù)據(jù)庫。 <pre>[root@sample ~]# cd ← 回到腳本所在的root用戶的根目錄 [root@sample ~]# ./mysql-backup.sh ← 運行腳本進行數(shù)據(jù)庫備份</pre> 接下來,我們再次登錄到MySQL服務(wù)器中,刪除剛剛建立的測試用的數(shù)據(jù)庫test,以便于測試數(shù)據(jù)恢復(fù)能否成功。 <pre>[root@sample ~]# mysql -u root -p ← 用root登錄到MySQL服務(wù)器 Enter password: ← 輸入MySQL的root用戶密碼 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use test ← 連接到測試用的test數(shù)據(jù)庫 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 mysql> drop table test; ← 刪除數(shù)據(jù)中的表 Query OK, 0 rows affected (0.04 sec) mysql> drop database test; ← 刪除測試用數(shù)據(jù)庫test Query OK, 0 rows affected (0.01 sec) mysql> show databases; +-------------+ | Database | +-------------+ | mysql | ← 確認測試用的test數(shù)據(jù)庫已不存在、已被刪除 +-------------+ 1 row in set (0.01 sec) mysql> exit ← 退出MySQL服務(wù)器 Bye</pre> 以上,我們就等于模擬了數(shù)據(jù)庫被破壞的過程。接下來,是數(shù)據(jù)庫被“破壞”后,用備份進行恢復(fù)的方法。 <pre>[root@sample ~]# /bin/cp -Rf /backup/mysql/test/ /var/lib/mysql/ ← 復(fù)制備份的數(shù)據(jù)庫test到相應(yīng)目錄 [root@sample ~]# chown -R mysql:mysql /var/lib/mysql/test/ ← 改變數(shù)據(jù)庫test的歸屬為mysql [root@sample ~]# chmod 700 /var/lib/mysql/test/ ← 改變數(shù)據(jù)庫目錄屬性為700 [root@sample ~]# chmod 660 /var/lib/mysql/test/* ← 改變數(shù)據(jù)庫中數(shù)據(jù)的屬性為660</pre> 然后,再次登錄到MySQL服務(wù)器上,看是否已經(jīng)成功恢復(fù)了數(shù)據(jù)庫。 <pre>[root@sample ~]# mysql -u root -p ← 用root登錄到MySQL服務(wù)器 Enter password: ← 輸入MySQL的root用戶密碼 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; ← 查看當(dāng)前存在的數(shù)據(jù)庫 +-------------+ | Database | +-------------+ | mysql | | test | ← 確認剛剛被刪除的test數(shù)據(jù)庫已經(jīng)成功被恢復(fù)回來! +------------+ 2 rows in set (0.00 sec) mysql> use test ← 連接到test數(shù)據(jù)庫 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 mysql> show tables; ← 查看test數(shù)據(jù)庫中存在的表 +-------------------+ | Tables_in_test | +-------------------+ | test | +-------------------+ 1 row in set (0.00 sec) mysql> select * from test; ← 查看數(shù)據(jù)庫中的內(nèi)容 +------+--------------+ | num | name | +------+--------------+ | 1 | Hello,BSD | ← 確認數(shù)據(jù)表中的內(nèi)容與刪除前定義的“Hello,BSD”一樣! +------+--------------+ 1 row in set (0.01 sec) mysql> exit ← 退出MySQL服務(wù)器 Bye</pre> 以上結(jié)果表示,數(shù)據(jù)庫被刪除后,用備份后的數(shù)據(jù)庫成功的將數(shù)據(jù)恢復(fù)到了刪除前的狀態(tài)。 ==參考來源== http://www.centospub.com/make/mysqlbackup.html {{CentOS}} [[category:CentOS|S]]
摘要:
請注意,您對站長百科的所有貢獻都可能被其他貢獻者編輯,修改或刪除。如果您不希望您的文字被任意修改和再散布,請不要提交。
您同時也要向我們保證您所提交的內(nèi)容是您自己所作,或得自一個不受版權(quán)保護或相似自由的來源(參閱
Wordpress-mediawiki:版權(quán)
的細節(jié))。
未經(jīng)許可,請勿提交受版權(quán)保護的作品!
取消
編輯幫助
(在新窗口中打開)
本頁使用的模板:
模板:CentOS
(
編輯
)
模板:CentOS top
(
編輯
)
取自“
http://kktzf.com.cn/wiki/CentOS/數(shù)據(jù)庫的自動備份與恢復(fù)
”