日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

bacula 的安装、配置和运行

發(fā)布時(shí)間:2024/9/20 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bacula 的安装、配置和运行 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

安裝bacula

1 bacula的幾種網(wǎng)絡(luò)備份拓?fù)?/strong>

前面文章介紹了bacula有5個(gè)組成部分,在實(shí)際的應(yīng)用中,沒(méi)有必要將5個(gè)部分分別放在不同的服務(wù)器上,它們之間的某些部分是可以合并的,常見(jiàn)的bacula部署結(jié)構(gòu)有如下幾種:

Director與SD以及Console在一臺(tái)機(jī)器上,而客戶端FD在另外一臺(tái)機(jī)器上,當(dāng)然客戶端FD可以有一臺(tái)或者多臺(tái)上。
Director與Console在一臺(tái)機(jī)器上,SD在一臺(tái)機(jī)器上,客戶端FD在一臺(tái)或者多臺(tái)上。
Director與客戶端FD、SD以及Console端都在一臺(tái)機(jī)器上,也就是服務(wù)器自己備份自己,數(shù)據(jù)保存在本機(jī)。

2 編譯與安裝bacula

這里對(duì)上一節(jié)的第一種bacula部署結(jié)構(gòu)進(jìn)行介紹。環(huán)境如表4-1所示。

表1 一個(gè)bacula部署結(jié)構(gòu)的環(huán)境

主機(jī)名 IP地址 操作系統(tǒng) 應(yīng)用角色 baculaServer 192.168.12.188 CentOS release 5.4 Director、SD、Console baculaClient 192.168.12.189 CentOS release 5.4 FD

整個(gè)拓?fù)浣Y(jié)構(gòu):


圖1 bacula實(shí)例的拓?fù)浣Y(jié)構(gòu)

在bacula服務(wù)器端安裝bacula

首先在http://www.bacula.org下載相應(yīng)的源碼,這里下載的是bacula-5.0.1.tar.gz,接著進(jìn)行編譯安裝,安裝過(guò)程如下:

# tar zxvf bacula-5.0.1.tar.gz # cd bacula-5.0.1 # ./configure --prefix=/opt/bacula --with-mysql=/opt/mysql # make # make install

bacula需要數(shù)據(jù)庫(kù)的 支持,這里采用Mysql數(shù)據(jù)庫(kù),并假定Mysql已經(jīng)在bacula服務(wù)器端安裝好了,且Mysql安裝路徑為/opt/mysql(bacula在編 譯時(shí)通過(guò)“--with-mysql”選項(xiàng)指定了Mysql數(shù)據(jù)庫(kù)的安裝路徑)。 bacula安裝完成后,所有配置文件默認(rèn)放在/opt/bacula/etc/目錄下。

在bacula客戶端安裝bacula

由于bacula客戶端只是是需要備份的客戶端,因而只需安裝相應(yīng)的客戶端組件即可,過(guò)程如下:

# tar zxvf bacula-5.0.1.tar.gz # cd bacula-5.0.1 # ./configure --prefix=/opt/bacula --enable-client-only # make # make install

3 初始化Mysql數(shù)據(jù)庫(kù)

在baculaServer上安裝完bacula后,還需要?jiǎng)?chuàng)建bacula對(duì)應(yīng)的Mysql數(shù)據(jù)庫(kù)以及訪問(wèn)數(shù)據(jù)庫(kù)的授權(quán),好在bacula已經(jīng)為用戶準(zhǔn)備好了這樣的腳本,接下來(lái)只要在bacula服務(wù)器端上執(zhí)行如下腳本即可。

#cd /opt/bacula/etc # ./grant_mysql_privileges # ./create_mysql_database Creation of bacula database succeeded.# ./make_mysql_tables Creation of Bacula MySQL tables succeeded.

接下來(lái)可以登錄Mysql數(shù)據(jù)庫(kù),查看bacula的數(shù)據(jù)庫(kù)和數(shù)據(jù)表是否已經(jīng)建立。在執(zhí)行上面三行Mysql初始代碼時(shí),默認(rèn)由空密碼的root用戶執(zhí)行,因此要請(qǐng)確保Mysql數(shù)據(jù)庫(kù)root密碼為空。

配置bacula備份系統(tǒng)

其實(shí)就是對(duì)Director端配置文件bacula-dir.conf、SD配置文件bacula-sd.conf、客戶端FD配置文件bacula-fd.conf以及Console端配置文件bconsole.conf進(jìn)行配置的過(guò)程。
根據(jù)上面的安裝部署,將Director端、SD、Console端集中在一臺(tái)服務(wù)器baculaServer(即192.168.12.188)上,而將客戶端FD部署在baculaClient(即192.168.12.189)服務(wù)器上,下面詳細(xì)講述配置過(guò)程。

1 配置bacula的Console端

Console端的配置文件是bconsole.conf,這個(gè)配置文件很簡(jiǎn)單,配置完的文件如下:

Director { Name = f10-64-build-dir #控制端名稱,在下面的bacula-dir.conf和bacula-sd.conf #文件中會(huì)陸續(xù)的被引用 DIRport = 9101 #控制端服務(wù)端口 address = 192.168.12.188 #控制端服務(wù)器IP地址 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #控制端密碼文件 }

2 配置bacula的Director端

bacula-dir.conf是Director端的配置文件,也是bacula的核心配置文件,這個(gè)文件非常復(fù)雜,共分為10個(gè)邏輯段,分別是:

  • Director,定義全局設(shè)置
  • Catalog,定義后臺(tái)數(shù)據(jù)庫(kù)
  • Jobdefs,定義默認(rèn)執(zhí)行任務(wù)
  • Job,自定義一個(gè)備份或者恢復(fù)任務(wù)
  • Fileset,定義備份哪些數(shù)據(jù),不備份哪些數(shù)據(jù)
  • Schedule,定義備份時(shí)間策略
  • Pool,定義供Job使用的池屬性
  • Client,定義要備份的主機(jī)地址
  • Storage,定義數(shù)據(jù)的存儲(chǔ)方式
  • Messages,定義發(fā)送日志報(bào)告和記錄日志的位置

代碼清單1是一個(gè)已經(jīng)配置好的文件,其中,“#”號(hào)后面的內(nèi)容為注釋。

代碼清單1 已經(jīng)設(shè)置好的Director端的配置文件

Director { #定義bacula的全局配置 Name = f10-64-build-dir DIRport = 9101 #定義Director的監(jiān)聽端口 QueryFile = "/opt/bacula/etc/query.sql" WorkingDirectory = "/opt/bacula/var/bacula/working" PidDirectory = "/var/run" Maximum Concurrent Jobs = 1 #定義一次能處理的最大并發(fā)數(shù)#驗(yàn)證密碼,這個(gè)密碼必須與bconsole.conf文件中對(duì)應(yīng)的Director邏輯段密碼相同 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t"#定義日志輸出方式,“Daemon”在下面的Messages邏輯段中進(jìn)行了定義 Messages = Daemon }Job { #自定義一個(gè)備份任務(wù) Name = "Client1" #備份任務(wù)名稱 Client = dbfd #指定要備份的客戶端主機(jī),“dbfd”在后面Client邏輯段中進(jìn)行定義 Level = Incremental #定義備份的級(jí)別,Incremental為增量備份。Level的取值#可為Full(完全備份)、Incremental(增量備份)和Differential(差異備份),如果第一#次沒(méi)做完全備份,則先進(jìn)行完全備份后再執(zhí)行Incremental Type = Backup #定義Job的類型,“backup”為備份任務(wù),可選的類型還有restore和verify等 FileSet = dbfs #指定要備份的客戶端數(shù)據(jù),“dbfs”在后面FileSet邏輯段中進(jìn)行定義 Schedule = dbscd #指定這個(gè)備份任務(wù)的執(zhí)行時(shí)間策略,“dbscd”在后面的Schedule邏輯段中進(jìn)行了定義 Storage = dbsd #指定備份數(shù)據(jù)的存儲(chǔ)路徑與介質(zhì),“dbsd” 在后面的Storage邏輯段中進(jìn)行定義 Messages = Standard Pool = dbpool #指定備份使用的pool屬性,“dbpool”在后面的Pool邏輯段中進(jìn)行定義。 Write Bootstrap = "/opt/bacula/var/bacula/working/Client2.bsr" #指定備份的引導(dǎo)信息路徑 }Job { #定義一個(gè)名為Client的差異備份的任務(wù) Name = "Client" Type = Backup FileSet = dbfs Schedule = dbscd Storage = dbsd Messages = Standard Pool = dbpool Client = dbfd Level = Differential #指定備份級(jí)別為差異備份 Write Bootstrap = "/opt/bacula/var/bacula/working/Client1.bsr" }Job { #定義一個(gè)名為BackupCatalog的完全備份任務(wù) Name = "BackupCatalog" Type = Backup Level = Full #指定備份級(jí)別為完全備份 Client = dbfd FileSet="dbfs" Schedule = "dbscd" Pool = dbpool Storage = dbsd Messages = Standard RunBeforeJob = "/opt/bacula/etc/make_catalog_backup bacula bacula" RunAfterJob = "/opt/bacula/etc/delete_catalog_backup" Write Bootstrap = "/opt/var/bacula/working/BackupCatalog.bsr" }Job { #定義一個(gè)還原任務(wù) Name = "RestoreFiles" Type = Restore #定義Job的類型為“Restore ”,即恢復(fù)數(shù)據(jù) Client=dbfd FileSet=dbfs Storage = dbsd Pool = dbpool Messages = Standard Where = /tmp/bacula-restores #指定默認(rèn)恢復(fù)數(shù)據(jù)到這個(gè)路徑 }FileSet { #定義一個(gè)名為dbfs的備份資源,也就是指定需要備份哪些數(shù)據(jù),需要排除哪些數(shù)據(jù)等,可以指定多個(gè)FileSet Name = dbfs Include { Options { signature = MD5; Compression=GZIP; } #表示使用MD5簽名并壓縮 File = /cws3 #指定客戶端FD需要備份的文件目錄 }Exclude { #通過(guò)Exclude排除不需要備份的文件或者目錄,可根據(jù)具體情況修改 File = /opt/bacula/var/bacula/working File = /tmp File = /proc File = /tmp File = /.journal File = /.fsck } }Schedule { #定義一個(gè)名為dbscd的備份任務(wù)調(diào)度策略 Name = dbscd Run = Full 1st sun at 23:05 #第一周的周日晚23:05分進(jìn)行完全備份 Run = Differential 2nd-5th sun at 23:05 #第2~5周的周日晚23:05進(jìn)行差異備份 Run = Incremental mon-sat at 23:05 #所有周一至周六晚23:05分進(jìn)行增量備份 }FileSet { Name = "Catalog" Include { Options { signature = MD5 } File = /opt/bacula/var/bacula/working/bacula.sql } }Client { #Client用來(lái)定義備份哪個(gè)客戶端FD的數(shù)據(jù) Name = dbfd #Clinet的名稱,可以在前面的Job中調(diào)用 Address = 192.168.12.189 #要備份的客戶端FD主機(jī)的IP地址 FDPort = 9102 #與客戶端FD通信的端口 Catalog = MyCatalog #使用哪個(gè)數(shù)據(jù)庫(kù)存儲(chǔ)信息,“MyCatalog”在后面的MyCatalog邏輯段中進(jìn)行定義 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #Director端與客戶端FD的驗(yàn)證密碼,這個(gè)值必須與客戶端FD配置文件bacula-fd.conf中密碼相同 File Retention = 30 days #指定保存在數(shù)據(jù)庫(kù)中的記錄多久循環(huán)一次,這里是30天,只影響數(shù)據(jù)庫(kù)中的記錄不影響備份的文件 Job Retention = 6 months #指定Job的保持周期,應(yīng)該大于File Retention指定的值 AutoPrune = yes #當(dāng)達(dá)到指定的保持周期時(shí),是否自動(dòng)刪除數(shù)據(jù)庫(kù)中的記錄,yes表示自動(dòng)清除過(guò)期的Job }Client { Name = dbfd1 Address = 192.168.12.188 FDPort = 9102 Catalog = MyCatalog Password = "Wr8lj3q51PgZ21U2FSaTXICYhLmQkT1XhHbm8a6/j8Bz" File Retention = 30 days Job Retention = 6 months AutoPrune = yes }Storage { # Storage用來(lái)定義將客戶端的數(shù)據(jù)備份到哪個(gè)存儲(chǔ)設(shè)備上 Name = dbsd Address = 192.168.12.188 #指定存儲(chǔ)端SD的IP地址 SDPort = 9103 #指定存儲(chǔ)端SD通信的端口 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #Director端與存儲(chǔ)端SD的驗(yàn)證密碼,這個(gè)值必須與存儲(chǔ)端SD配置文件bacula-sd.conf中Director邏輯段密碼相同 Device = dbdev #指定數(shù)據(jù)備份的存儲(chǔ)介質(zhì),必須與存儲(chǔ)端(這里是192.168.12.188)的bacula-sd.conf配置文件中的“Device” 邏輯段的“Name”項(xiàng)名稱相同 Media Type = File #指定存儲(chǔ)介質(zhì)的類別,必須與存儲(chǔ)端SD(這里是192.168.12.188)的bacula-sd.conf配置文件中的“Device” 邏輯段的“Media Type”項(xiàng)名稱相同 }Catalog { # Catalog邏輯段用來(lái)定義關(guān)于日志和數(shù)據(jù)庫(kù)設(shè)定 Name = MyCatalog dbname = "bacula"; dbuser = "bacula"; dbpassword = "" #指定庫(kù)名、用戶名和密碼 }Messages { # Messages邏輯段用來(lái)設(shè)定Director端如何保存日志,以及日志的保存格式,可以將日志信息發(fā)送到管理員郵箱,前提是必須開啟sendmail服務(wù) Name = Standard mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r" mail = dba.gao@gmail.com = all, !skipped operator = exitgogo@126.com = mount console = all, !skipped, !saved append = "/opt/bacula/log/bacula.log" = all, !skipped #定義bacula的運(yùn)行日志 append ="/opt/bacula/log/bacula.err.log" = error,warning, fatal #定義bacula的錯(cuò)誤日志 catalog = all }Messages { #定義了一個(gè)名為Daemon的Messages邏輯段,“Daemon”已經(jīng)在前面進(jìn)行了引用 Name = Daemon mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r" mail = exitgogo@126.com = all, !skipped console = all, !skipped, !saved append = "/opt/bacula/log/bacula_demo.log" = all, !skipped }Pool { #定義供Job任務(wù)使用的池屬性信息,例如,設(shè)定備份文件過(guò)期時(shí)間、是否覆蓋過(guò)期的備份數(shù)據(jù)、是否自動(dòng)清除過(guò)期備份等 Name = dbpool Pool Type = Backup Recycle = yes #重復(fù)使用 AutoPrune = yes #表示自動(dòng)清除過(guò)期備份文件 Volume Retention = 7 days #指定備份文件保留的時(shí)間 Label Format ="db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}" #設(shè)定備份文件的命名格式,這個(gè)設(shè)定格式會(huì)產(chǎn)生的命名文件為:db-2010-04-18-id139 Maximum Volumes = 7 #設(shè)置最多保存多少個(gè)備份文件 Recycle Current Volume = yes #表示可以使用最近過(guò)期的備份文件來(lái)存儲(chǔ)新備份 Maximum Volume Jobs = 1 #表示每次執(zhí)行備份任務(wù)創(chuàng)建一個(gè)備份文件 }Console { #限定Console利用tray-monitor獲得Director的狀態(tài)信息 Name = f10-64-build-mon Password = "RSQy3sRjak3ktZ8Hr07gc728VkZHBr0QCjOC5x3pXEap" CommandACL = status, .status }

3 配置bacula的SD

SD可以是一臺(tái)單獨(dú)的服務(wù)器,也可以和Director在一臺(tái)機(jī)器上,本例就將SD和Director端放在一起進(jìn)行配置,SD的配置文件是bacula-sd.conf,代碼清單2是一個(gè)已經(jīng)配置好的bacula-sd.conf文件。

代碼清單2 配置好的bacula-sd.conf文件

Storage { #定義存儲(chǔ),本例中是f10-64-build-sd Name = f10-64-build-sd #定義存儲(chǔ)名稱 SDPort = 9103 #監(jiān)聽端口 WorkingDirectory = "/opt/bacula/var/bacula/working" Pid Directory = "/var/run" Maximum Concurrent Jobs = 20 }Director { #定義一個(gè)控制StorageDaemon的Director Name = f10-64-build-dir #這里的“Name”值必須和Director端配置文件bacula-dir.conf中Director邏輯段名稱相同 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #這里的“Password”值必須和Director端配置文件bacula-dir.conf中Storage邏輯段密碼相同 }Director { #定義一個(gè)監(jiān)控端的Director Name = f10-64-build-mon #這里的“Name”值必須和Director端配置文件bacula-dir.conf中Console邏輯段名稱相同 Password = "RSQy3sRjak3ktZ8Hr07gc728VkZHBr0QCjOC5x3pXEap" #這里的“Password”值必須和Director端配置文件bacula-dir.conf中Console邏輯段密碼相同 Monitor = yes }Device { #定義Device Name = dbdev #定義Device的名稱,這個(gè)名稱在Director端配置文件bacula-dir.conf中的Storage邏輯段Device項(xiàng)中被引用 Media Type = File #指定存儲(chǔ)介質(zhì)的類型,File表示使用文件系統(tǒng)存儲(chǔ) Archive Device = /webdata #Archive Device用來(lái)指定備份存儲(chǔ)的介質(zhì),可以是cd、dvd、tap等,這里是將備份的文件保存的/webdata目錄下 LabelMedia = yes; #通過(guò)Label命令來(lái)建立卷文件 Random Access = yes; #設(shè)置是否采用隨機(jī)訪問(wèn)存儲(chǔ)介質(zhì),這里選擇yes AutomaticMount = yes; #表示當(dāng)存儲(chǔ)設(shè)備打開時(shí),是否自動(dòng)使用它,這選擇yes RemovableMedia = no; #是否支持可移動(dòng)的設(shè)備,如tap或cd,這里選擇no AlwaysOpen = no; #是否確保tap設(shè)備總是可用,這里沒(méi)有使用tap設(shè)備,因此設(shè)置為no }Messages { #為存儲(chǔ)端SD定義一個(gè)日志或消息處理機(jī)制 Name = Standard director = f10-64-build-dir = all }

4 配置bacula的FD端

客戶端FD運(yùn)行在一臺(tái)獨(dú)立的服務(wù)器上,在本例中是baculaclient主機(jī)(即192.168.12.189),它的配置文件是bacula-fd.conf,配置好的文件如下:

Director { #定義一個(gè)允許連接FD的控制端 Name = f10-64-build-dir #這里的“Name”值必須和Director端配置文件bacula-dir.conf中Director邏輯段名稱相同 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #這里的“Password”值必須和Director端配置文件bacula-dir.conf中Client邏輯段密碼相同 }Director { #定義一個(gè)允許連接FD的監(jiān)控端 Name = f10-64-build-mon Password = "RSQy3sRjak3ktZ8Hr07gc728VkZHBr0QCjOC5x3pXEap" Monitor = yes }FileDaemon { #定義一個(gè)FD端 Name = localhost.localdomain-fd FDport = 9102 #監(jiān)控端口 WorkingDirectory = /opt/bacula/var/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20 #定義一次能處理的并發(fā)作業(yè)數(shù) }Messages { #定義一個(gè)用于FD端的Messages Name = Standard director = localhost.localdomain-dir = all, !skipped, !restored }

啟動(dòng)bacula的Director daemon與Storage daemon

完成上面的配置后,就可以啟動(dòng)或關(guān)閉bacula了。在baculaserver上啟動(dòng)或關(guān)閉控制端的所有服務(wù),有如下兩種方式。

第一種方式如下:

[root@baculaserver etc]# /opt/bacula/sbin/bacula {start|stop|restart|status}

也可以通過(guò)分別管理bacula各個(gè)配置端的方式,依次啟動(dòng)或者關(guān)閉每個(gè)服務(wù):

[root@baculaserver etc]# /opt/bacula/etc/bacula-ctl-dir {start|stop|restart|status} [root@baculaserver etc]# /opt/bacula/etc/bacula-ctl-sd {start|stop|restart|status} [root@baculaserver etc]# /opt/bacula/etc/bacula-ctl-fd {start|stop|restart|status}

由于將客戶端FD配置到了另一個(gè)主機(jī)baculaclient上,因此無(wú)需在baculaserver上啟動(dòng)File daemon服務(wù)。啟動(dòng)bacula的所有服務(wù)后,通過(guò)netstat命令,觀察啟動(dòng)端口情況:

[root@localhost etc]# netstat -antl |grep 91 tcp 0 0 0.0.0.0:9101 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:9103 0.0.0.0:* LISTEN

其中,9101代表Director daemon;9102代表File daemon;9103代表Storage daemon。注意在啟動(dòng)bacula的所有服務(wù)前,必須啟動(dòng)MySQL數(shù)據(jù)庫(kù),如果MySQL數(shù)據(jù)庫(kù)沒(méi)有啟動(dòng),連接bacula的控制端時(shí)會(huì)報(bào)錯(cuò):

[root@baculaserver opt]# /opt/bacula/sbin/bconsole Connecting to Director 192.168.12.188:9101 19-04月 09:45 bconsole JobId 0: Fatal error: bsock.c:135 Unable to connect to Director daemon on 192.168.12.188:9101. ERR=拒絕連接

此時(shí),執(zhí)行netstat命令可以發(fā)現(xiàn),9101端口根本沒(méi)有啟動(dòng)。

在客戶端FD啟動(dòng)File daemon

最后 ,在客戶端FD(即baculaclient)上啟動(dòng)File daemon服務(wù),操作如下:

[root@baculaclient etc]# /opt/bacula/sbin/bacula start Starting the Bacula File daemon

管理客戶端FD的服務(wù),也可以通過(guò)以下方式完成:

[root@baculaclient etc]# /opt/bacula/sbin/bacula {start|stop|restart|status} [root@ baculaclient etc]# /opt/bacula/etc/bacula-ctl-fd {start|stop|restart|status}

轉(zhuǎn)載于:https://blog.51cto.com/fengjixuchui/1129407

總結(jié)

以上是生活随笔為你收集整理的bacula 的安装、配置和运行的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。