Choc-Net!
【amanda】バックアップサーバ構築
最終更新:
choc-net
-
view
【amanda】バックアップサーバ構築
フリーのバックアップサーバである「amanda」を利用したバックアップシステムの構築メモ。
amandaはサーバとクライアントに分かれており、複数サーバのバックアップを一元管理できる。
それ以外にもテープローダーへの対応、完全・差分・増分バックアップへの対応が備わっており、
設定を極めればそこらへんのバックアップソフトにも負けないと思う。
ただ、デメリットとしては転がっている情報が少ないので、初期構築には苦労するかも。
amandaはサーバとクライアントに分かれており、複数サーバのバックアップを一元管理できる。
それ以外にもテープローダーへの対応、完全・差分・増分バックアップへの対応が備わっており、
設定を極めればそこらへんのバックアップソフトにも負けないと思う。
ただ、デメリットとしては転がっている情報が少ないので、初期構築には苦労するかも。
サーバの設定(amanda.conf)
共通
org "DailySet1" # your organization name for reports mailto "amanda" # space separated list of operators at your site dumpuser "amanda" # the user to run dumps under inparallel 4 # maximum dumpers that will run in parallel netusage 1000 Kbps # maximum net bandwidth for Amanda, in KB per sec
- org
- バックアップ用の設定名を指定。
- /etc/amanda/ や、/var/lib/amanda/ の配下に作成されるディレクトリ名と同一である必要がある。
- mailto
- amandaの処理で異常や警告が発生した場合にメールを送る先を指定。
- 複数の宛先を指定する場合は、,(カンマ)で区切る。
- ;(セミコロン)で指定した場合、2件目以降のアドレスにメールが飛ばない場合があります。
- dumpuser
- ダンプを実行するユーザ名を指定。
- inparallel
- 一度に実行できるバックアップの数を制限する。
- テープサーバに負荷がかかる場合以外、設定する必要なし。
- netusage
- ネットワークの最大通信速度を指定。
バックアップのサイクルの設定
dumpcycle 0 weeks # the number of days in the normal dump cycle runspercycle 0 days # the number of amdump runs in dumpcycle days tapecycle 2 tapes # the number of tapes in rotation
- dumpcycle
- 完全バックアップをとる間隔を設定する。
- この値が、ダンプサイクルの期間を意味します。
- runspercycle
- 1ダンプサイクル期間のバックアップ(差分バックアップ)回数を指定します。
- tapecycle
- この値は、runspercycle + 1((なぜ、+1かというと、前回の完全バックアップを消さないようにするためです。というのも、もし完全バックアップ時にバックアップエラーになって、前回の完全バックアップが消えてしまうと、全くバックアップが無い状態になってしまうからです。))以上の値を設定します。
- つまり、完全バックアップであれ、増分バックアップであれ、必ず1回のバックアップで1本のテープを利用します。
- dumpcycleとrunspercycleの関係
- 説明しずらいので、例をいくつかあげておきます。
- 毎回完全バックアップ
dumpcycle 0 weeks # the number of days in the normal dump cycle runspercycle 0 days # the number of amdump runs in dumpcycle days tapecycle 2 tapes # the number of tapes in rotation
- 毎日実行し、週1回だけ完全バックアップ
dumpcycle 1 weeks # the number of days in the normal dump cycle runspercycle 7 days # the number of amdump runs in dumpcycle days tapecycle 8 tapes # the number of tapes in rotation
- 火~土にバックアップ実行し、一回だけ完全バックアップ
dumpcycle 1 weeks # the number of days in the normal dump cycle runspercycle 4 days # the number of amdump runs in dumpcycle days tapecycle 5 tapes # the number of tapes in rotation
テープ装置の設定
runtapes 1 # number of tapes to be used in a single run of amdump #tpchanger "chg-manual" # the tape-changer glue script tapedev "/dev/nst0" # the no-rewind tape device to be used #tapedev "/dev/st0" # the no-rewind tape device to be used #rawtapedev "/dev/null" # the raw device to be used (ftape only) #changerfile "/var/lib/amanda/DailySet1/changer" #changerfile "/var/lib/amanda/DailySet1/changer-status" #changerfile "/etc/amanda/DailySet1/changer.conf" #changerdev "/dev/null" tapetype BNCHMARK # what kind of tape it is (see tapetypes below) labelstr "^chocnet01_[0-9][0-9]*$" # label constraint regex: all tapes must match # tapetypes define tapetype BNCHMARK { comment "BNCHMARK DLT-1" length 34472 mbytes filemark 11 kbytes speed 1292 kps }
- runtapes
- 一度に利用出来るテープの本数を指定。
- テープチェンジャを利用していなければ、このまま。
- tpchanger
- テープチェンジャを使っている場合に設定。
- tapedev
- 非リワインドテープデバイス名を設定。
- rawtapedev
- 設定する必要なし。((ftapeドライバを利用している場合も、ドライバ側でファイルマーカーが完全にエミュレートされるようになってきているので設定の必要が無いらしい。))
- tapetype
- 後述の'''define tapetype''で指定したテープタイプ名を設定。
- labelstr
- ラベル名のフォーマットを設定
- define tapetype
- テープドライブのパフォーマンスを設定。
- amandaのベンチマークで出力される値を参考にする。
- 実行する前にハードウェア圧縮をOFFにする。
$ mt -f /dev/st0 compression 0 $ /usr/sbin/amtapetype -f /dev/st0
- changerfile
- テープチェンジャを使っている場合に設定。
- changerdev
- テープチェンジャを使っている場合に設定。
バックアップ用領域
holdingdisk hd1 { comment "main holding disk" directory "/backup" # where the holding disk is use 20 Gb # how much space can we use on it }
- この領域の利用目的
- 余裕を持って領域を取っておく必要があります。
- バックアップの作業領域
- テープが入っていない場合の一時保存領域
- 正しいテープが入っていない場合(テープをかえるのを忘れていた場合)の一時保存領域
- directory
- 領域のパス名を指定。
- use
- 領域のサイズを指定。このサイズは、決して実サイズ以上割り当てないこと!
各種ファイルの格納場所
infofile "/var/lib/amanda/DailySet1/curinfo" # database filename logdir "/var/lib/amanda/DailySet1/log" # log directory indexdir "/var/lib/amanda/DailySet1/index" # index directory #tapelist "/var/lib/amanda/DailySet1/tapelist" # list of used tapes # tapelist is stored, by default, in the directory that contains amanda.conf
- infofile
- amandaで利用しているデータベースディレクトリ名。
- コメントには、ファイル名ってありますが、実際には階層の深いディレクトリが作成されます。
- logdir
- amandaから出力されるログ置き場。
- indexdir
- amandaで作成&利用するindexファイル。
- 利用時に作成されます。
- tapelist
- テープ情報が格納されています。
- amlabelでラベル付けを行うと、ここに書かれます。
- amandaのテープチェンジで指定するラベル名は、ここの情報を基にしてるようです。
バックアップ方法の設定
# dumptypes define dumptype global { comment "Global definitions" } define dumptype always-full { global comment "Full dump of this filesystem always" compress none priority high dumpcycle 0 }
- 記述フォーマット
- define dumptype定義名 {
- global
- program "GNUTAR"
- comment "root partitions dumped with tar"
- compress none
- index
- exclude list "/usr/local/lib/amanda/exclude.gtar"
- priority low
- dumpcycle 0
- }
- 定義名
- ダンプタイプの名称指定します。
- オプション
- 定義名
- ベースとする定義名を指定できます。
- 変更するオプションを別途指定することで、オプションの上書きがされます。
- program
- バックアップに利用する形式を指定します。
- dump,samba,xfsdumpなどが使えるらしいです。
- デフォルトはdump
- compress
- 圧縮オプション。
- 圧縮なし
- ''compress none''
- 圧縮あり
- ''compress client fast'' … クライアント側で、高速アルゴリズムを使用しバックアップデータを圧縮。
- ''compress client best'' … クライアント側で、最高圧縮
- ''compress server fast'' … 後日追記
- ''compress server best'' … 後日追記
- index
- amrecoverを利用したリストアを利用したい場合は、このオプションを指定する。
- exclude list
- バックアップ除外リスト。
- ここで指定したファイルに記述されてるファイルは、バックアップ対象外とする。
- ただ、調べてみると、圧縮方法がgnutarの場合のみ有効となるそうです。
- dumpやsamba経由だと適用されないらしいです。(確証は取れてません。)
- priority
- 圧縮処理の優先度
- 高 … ''priority high''
- 中 … ''priority medium''
- 低 … ''priority low''
- 優先度を上げると、何がどう優先されるかは不明。
- dumpcycle
- たとえば、常に完全バックアップを取りたいディレクトリやデバイスがある場合に
- ''dumpcycle 0''と指定することで、スケジュールに依存せず完全バックアップが取れる。
初期値のまま
bumpsize 20 Mb # minimum savings (threshold) to bump level 1 -> 2 bumpdays 1 # minimum days at each level bumpmult 4 # threshold = bumpsize * bumpmult^(level-1) etimeout 300 # number of seconds per filesystem for estimates. # reserve 30 # percent reserve 0
その他準備および設定
テープの設定
テープにラベル付けを行う。(バックアップ用ユーザで実行)
$ /usr/sbin/amlabel -f DailySet1 nsdlsv01_01
※ -f は、強制上書きパラメータです。既存のテープでラベルが既についている場合などは、忘れずに付けてください。
- 実行例
- $ /usr/sbin/amlabel -f DailySet1 chocnet01_01
- rewinding, reading label chocnet01_01, tape is active
- rewinding, writing label chocnet01_01, checking label, done.
バックアップ退避領域の設定
上記の「バックアップ用領域」で指定したサイズ以上の空きがあるパスを指定する。
保存対象の設定(disklist編集)
リストは、/etc/amanda/<設定名>/disklistにある。
localhost /dkmnt1/pgsql_bak root-tar localhost /etc root-tar localhost /var/lib/amanda root-tar localhost /var/www root-tar localhost /dev/vg00/lvol5 root-tar
- 1列目
- バックアップ端末名
- バックアップ対象のサーバが、amandaの入ったサーバと同一である場合は、localhostと指定すればよい。
- 2列目
- デバイス(パス)名
- 3列目
- ダンプタイプ
- 上記の「[[バックアップ方法の設定」で定義されたダンプタイプを指定する。
設定ファイルの確認
バックアップ用ユーザで以下のコマンドを実行し、エラーが出ていないことを確認。
$ /usr/sbin/amcheck DailySet1
- 実行例
$ /usr/sbin/amcheck DailySet1 Amanda Tape Server Host Check ----------------------------- Holding disk /backup: 4918036 KB disk space available, that's plenty NOTE: skipping tape-writable test Tape chocnet01_01 label ok NOTE: info dir /var/lib/amanda/DailySet1/curinfo/localhost/_dev_vg00_lvol15: does not exist NOTE: index dir /var/lib/amanda/DailySet1/index/localhost/_dev_vg00_lvol15: does not exist Server check took 5.263 seconds Amanda Backup Client Hosts Check -------------------------------- Client check: 1 host checked in 10.036 seconds, 0 problems found (brought to you by Amanda 2.4.4p1)
定期バックアップの設定(crontab)
バックアップ用ユーザで以下のコマンドを実行
$ crontab -e
テープチェック
毎週金曜日の16:00にテープチェックを行う。
0 16 * * 5 /usr/sbin/amcheck -m <設定名>
- 例
- 0 16 * * 5 /usr/sbin/amcheck -m DailySet1
バックアップ
毎週土曜日の0:00からバックアップを行う。
0 0 * * 6 /usr/sbin/amdump <設定名>
- 例
- 0 0 * * 6 /usr/sbin/amdump DailySet1