Embed
Email

Backup

Document Sample
Backup
Shared by: pptfiles
Categories
Tags
Stats
views:
29
posted:
1/3/2012
language:
pages:
16
ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





วิธีการใช้ เครื่อง Tape Library Backup



1. ลักษณะทาง Hardware

เครื่ อง Tape Library ประกอบด้วยส่ วนสาคัญที่ใช้ในการทางาน 3 ส่ วนคือ Tape Drive

ที่เป็ นอุปกรณ์สาหรับอ่านเขียนข้อมูลจากเทป ส่ วนที่สองคือ Slot ที่ใช้ใส่ เทปจานวนหนึ่ ง

และส่ วนสุ ดท้ายคือ Robot หรื อแขนกลที่ให้ในการหยิบเทปจาก Slot เข้า-ออกจาก Tape Drive



2. การติดตั้งเข้ากับ Linux Server

2.1 เตรี ยมเครื่ อง Linux Server ที่จะใช้ในการติดตั้ง โดยแนะนาให้ใช้ Linux Redhat



เวอร์ชน 7.2 ขึ้นไป

2.2 ต่อเครื่ อง Tape Library เข้ากับเครื่ อง Linux Server ผ่านทางอินเตอร์เฟสแบบ

SCSI

2.3 ทาการเปิ ดสวิตช์เครื่ อง Tape Library และ Linux Server ตามลาดับ

2.4 สังเกตหน้าจอของเครื่ อง Linux Server ในขณะกาลัง boot ว่า Linux

สามารถค้นหาและตรวจสอบ Tape Library ที่ได้ติดตั้งกับอินเตอร์ เฟส SCSI

อย่างเรี ยบร้อย ดังตัวอย่าง



scsi1 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.4



aic7899: Ultra160 Wide Channel B, SCSI Id=7, 32/253 SCBs



Vendor: COMPAQ Model: MSL5000 Series Rev: 0311

Type: Medium Changer ANSI SCSI revision: 02

(scsi0:A:0): 20.000MB/s transfers (10.000MHz, offset 15, 16bit)

Vendor: COMPAQ Model: SuperDLT1 Rev: 2323

Type: Sequential-Access ANSI SCSI revision: 02

(scsi0:A:1): 80.000MB/s transfers (40.000MHz, offset 62, 16bit)









จากตัวอย่างจะเห็นว่า Linux ตรวจพบอุปกรณ์ COMPAQ MSL5000 Series และ



SuperDLT1 ซึ่งเป็ น Robot และ Tape Drive ที่อยูใน Tape Library ตามลาดับ

จากนั้นสังเกตต่ออีกว่า Linux กาหนด device name ใดให้แก่อุปกรณ์สองตัวนี้

โดยปกติ Tape Drive จะมีชื่อขึ้นต้นด้วย “st” (t ย่อมาจาก tape) ขณะที่ Robot

จะมีชื่อขึ้นต้นด้วย “sg” (g ย่อมาจาก generic) ดังนั้นจากตัวอย่างข้างล่างนี้จะพบว่า

Tape Drive มีชื่อว่า “/dev/st0” และ Robot มีชื่อว่า “/dev/sg0”



st: Version 20020205, bufsize 32768, wrt 30720, max init. bufs 4, s/g segs 1

6

Attached scsi tape st0 at scsi0, channel 0, id 1, lun 0

Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 8







3/1/2012 1

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03









2.5 ั

ในกรณี ที่ Linux Server ไม่สามารถตรวจพบอุปกรณ์ท้ งสองได้ ให้ update SCSI driver

ั ้ ั

จากบริ ษทผูผลิต หรื อเปลี่ยนเวอร์ ชนของ Linux ให้ใหม่ข้ ึน

2.6 หลังจากที่ boot เครื่ องเสร็ จแล้ว ให้ login โดยใช้ root



จากนั้นทาการทดสอบอุปกรณ์ดงกล่าวโดยใช้คาสั่ง mt และ mtx ดังตัวอย่างต่อไปนี้





# mtx -f /dev/sg0 inquiry

Product Type: Medium Changer

Vendor ID: 'COMPAQ '

Product ID: 'MSL5000 Series '

Revision: '0311'

Attached Changer: No



# mt -f /dev/st0 status

SCSI 2 tape drive:

File number=0, block number=0, partition=0.

Tape block size 0 bytes. Density code 0x48 (no translation).

Soft error count since last status=0

General status bits on (41010000):

BOT ONLINE IM_REP_EN



# mtx -f /dev/sg1 inquiry

Product Type: Tape Drive

Vendor ID: 'COMPAQ '

Product ID: 'SuperDLT1 '

Revision: '2323'

Attached Changer: No









โปรแกรม mtx ที่ใช้ในคาสั่งแรกเป็ นคาสั่งที่ใช้สาหรับควบคุมอุปกรณ์ของ Tape

Library เช่น Robot ส่ วนโปรแกรม mt ที่ใช้ในคาสั่งที่ 2 ใช้สาหรับควบคุม Tape Drive



ส่ วนในคาสั่งที่ 3 จะเห็นว่ามีการใช้โปรแกรม mtx เรี ยกดูขอมูลจากอุปกรณ์ /dev/sg1

ซึ่ งก็คือ Tape Drive /dev/st0 นันเอง เพียงแต่ Linux ใช้งาน sg1 และ st0



ในเงื่อนไขการทางานที่ต่างกัน (อย่างไรก็ตาม Linux จะไม่แสดงชื่ออุปกรณ์ /dev/sg1

ได้ในขั้นตอน boot เครื่ องข้างต้น )



3. การควบคุมเครื่ อง Tape Library โดยใช้ LCD panel



ผูใช้สามารถตั้งค่าและควบคุมการทางานของ Tape Library โดยผ่านทางจอ LCD



ที่อยูหน้าเครื่ องได้เช่น

 การเปิ ด-ปิ ดประตูตเู้ พื่อเปลี่ยนตลับเทป

 การสั่งให้ Robot ทาการ load และ unload เทปเข้า-ออกจาก Tape Drive

 การสั่งให้ Robot ทาการย้ายเทปจาก slot หนึ่งไปยังอีก slot หนึ่ง

 ดูสถานะการทางานของเครื่ อง Tape Library



3/1/2012 2

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





โปรดศึกษารายละเอียดเพิ่มเติมจากคู่มือการใช้งาน Tape Library ที่ให้มากับเครื่ อง



4. การควบคุม Tape Library เพื่อใช้อ่านและเขียนข้อมูลเบื้องต้น

4.1 login เข้าไปใน Linux Server โดยใช้ user ที่มีสิทธิ์ ในการอ่านและเขียนไฟล์ /dev/st0

และ /dev/sg0

4.2 การ load/unload เทปเข้า-ออกจาก Tape Drive

เราสามารถใช้ LCD Panel ในการควบคุม Robot โดยตรง ให้ทาการย้ายเทปจาก Slot

ใด Slot หนึ่งเข้าสู่ Tape Drive ได้ หรื อจะใช้โปรแกรม mtx ในการควบคุม Robot

(/dev/sg0) โดยผ่านทาง Linux ก็ได้ เช่น

# mtx -f /dev/sg0 status

Storage Changer /dev/sg0:1 Drives, 25 Slots ( 0 Import/Export )

Data Transfer Element 0:Full (Storage Element 6 Loaded):VolumeTag = FOJ940

Storage Element 1:Full :VolumeTag=FOJ935

Storage Element 2:Full :VolumeTag=FOJ936

Storage Element 3:Full :VolumeTag=FOJ937

Storage Element 4:Full :VolumeTag=FOJ938

Storage Element 5:Full :VolumeTag=FOJ939

Storage Element 6:Empty

Storage Element 7:Full :VolumeTag=FOJ941

Storage Element 8:Full :VolumeTag=FOJ942

Storage Element 9:Full :VolumeTag=FOJ943

Storage Element 10:Full :VolumeTag=FOJ944

Storage Element 11:Empty

Storage Element 12:Empty

Storage Element 13:Empty

Storage Element 14:Empty

Storage Element 15:Empty

Storage Element 16:Empty

Storage Element 17:Empty

Storage Element 18:Empty

Storage Element 19:Empty

Storage Element 20:Empty

Storage Element 21:Empty

Storage Element 22:Empty

Storage Element 23:Empty

Storage Element 24:Empty

Storage Element 25:Empty

Storage Element 26 IMPORT/EXPORT:Empty









่ ้

เป็ นการเรี ยกดูสถานะของ Slot ว่าช่องใดมีเทปใส่ อยูบาง ส่ วนคาสั่ง

# mtx -f /dev/sg0 transfer 10 26





เป็ นการย้ายเทปจาก Slot ที่ 10 ไปยัง Slot ที่ 26



สาหรับการ load เทปจาก slot หมายเลข 9 เข้าTape Drive และการ unload เทปกลับสู่

slot เดิม ใช้คาสังดังต่อไปนี้ตามลาดับ



# mtx -f /dev/sg0 load 9



# mtx -f /dev/sg0 unload









3/1/2012 3

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03









4.3 การเขียนข้อมูลลงในเทป

เราสามารถใช้โปรแกรม tar, cat, ฯลฯ ที่ทางานกับไฟล์ธรรมดา มาทางานกับ Tape

Drive ได้โดยการอ้างถึงอุปกรณ์ชื่อ /dev/st0 แทนการเรี ยกชื่อไฟล์

เช่นถ้าเราต้องการเขียนข้อมูลจาก /home ลงในเทปโดยใช้คาสั่ง tar

# tar -cvf /dev/st0 /home











จะทาการเขียนข้อมูลลงในเทปที่ถูก load อยูใน Tape Drive ในขณะนั้นในรู ปแบบของ

tar และเมื่อเขียนเสร็ จแล้วจะทาการ rewind เทปกลับมายังหัวเทปโดยอัตโนมัติ





ในการเรี ยกดูรายชื่อไฟล์หรื อเรี ยกคืนข้อมูลที่เก็บอยูในเทปก็ให้ใช้คาสังต่อไปนี้ตามลา



ดับ

# tar -tvf /dev/st0

# tar -xvf /dev/st0









4.4 การใช้คาสัง mt ควบคุม Tape Drive ในการอ่านและเขียนข้อมูล



ในการอ่าน-เขียนข้อมูลกับอุปกรณ์ /dev/st0 นั้นเป็ นการกาหนดให้ทา rewind

แบบอัตโนมัติหลังจากเสร็ จสิ้ นการทางาน นันคือเทปจะถูก rewind



กลับมายังหัวเทปเสมอ ถ้าเราต้องการทางานแบบไม่มีการ rewind

เราจะต้องใช้อุปกรณ์ที่ชื่อ /dev/nst0 ซึ่งเป็ นชื่อแทนอุปกรณ์ Tape Drive



ตัวเดียวกันเพียงแต่เป็ นการกาหนดให้ไม่ตองทา rewind

ทาให้เราสามารถเขียนข้อมูลได้หลายครั้ง (track) ในเทปตลับเดียวกัน เช่น

# tar -cvf /dev/nst0 /home

# tar -cvf /dev/nst0 /usr









จะเขียนข้อมูล /home ใน track แรกแล้วต่อด้วย /usr ใน track ถัดไป เมื่อเราต้องการทา

rewind จะใช้คาสั่ง

# mt -f /dev/nst0 rewind











เนื่องจากในเทปมีขอมูลเก็บไว้มากกว่าหนึ่ง track



ดังนั้นในการเรี ยกใช้ขอมูลเราจาเป็ นต้องหมุนเทปไปยัง track





3/1/2012 4

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





ของข้อมูลที่ถูกต้องเสี ยก่อน มิฉะนั้นคาสั่ง cat หรื อ tar จะอ่านข้อมูลจนถึงแค่สิ้นสุ ด

ั ่

track ปั จจุบน เช่นสมมติวาจะเรี ยกคืนข้อมูล /usr จากเทป เราจะต้องหมุนเทปไปยัง

track ที่ 2 ที่เป็ นส่ วนของ /usr เสี ยก่อนดังตัวอย่าง

# mt -f /dev/nst0 fsf

# tar -xvf /dev/nst0









4.5 ศึกษาชุดคาสั่งของ mtx และ mt เพิ่มเติมได้จาก

# man mtx

# man mt









5. การ Backup โดยใช้โปรแกรม Amanda



ในหัวข้อที่ผานมาจะเป็ นการแสดงวิธีการใช้งาน Tape Library ในเบื้องต้นโดยใช้ tools ต่างๆ



ที่มีอยูแล้วใน Linux เช่นโปรแกรม tar อย่างไรก็ตามการทางานแบบนี้ไม่ได้ใช้ความสามารถของ

Tape Library ได้อย่างเต็มประสิ ทธิ ภาพนัก เช่นถ้าข้อมูลที่จะทาการ backup



มีขนาดมากกว่าเทปหนึ่งตลับ เมื่อเขียนข้อมูลจนเต็มแล้วผูใช้จะต้องทาการเทปเองทาให้ไม่สะดวก

ดังนั้นในหัวข้อนี้จะกล่าวถึงการใช้งาน software ที่ทาหน้าที่เฉพาะกับ Tape Library



ซึ่ งมีอยูหลายตัวเช่น Amanda, afBackup, หรื อ commercial software อื่นๆ ข้อดีของการใช้ software

เหล่านี้คือ

 เพื่อช่วยอานวยความสะดวกในการจัดการกับเทปทั้งการ load, unload, ฯลฯ

 เพิมประสิ ทธิ ภาพในการ backup ข้อมูลเพราะ software



จะถูกเขียนขึ้นมาให้เหมาะกับลักษณะการทางานของเทปโดยเฉพาะ

ในหัวข้อนี้จะกล่าวถึงการติดตั้งและการปรับแต่งค่าของโปรแกรม Amanda ซึ่งเป็ น Free software

ั ่ ั

ที่ใช้กนอยูอย่างแพร่ หลายตัวหนึ่งในปั จจุบน

5.1 การติดตั้งโปรแกรม Amanda



สาหรับผูใช้ Redhat Linux โปรแกรม Amanda มีมาให้ในรู ปของ rpm package

้ ่

ซึ่ งผูใช้สามารถตรวจสอบดูได้วาใน Linux มีโปรแกรม Amanda



อยูหรื อไม่โดยใช้คาสั่ง

# rpm -q amanda

amanda-2.4.2p2-4









เนื่องจากโปรแกรม Amanda ทางานในลักษณะของ client/server โดยที่ server

คือเครื่ อง Linux ที่มี Tape Library ต่ออยู่ เครื่ อง client คือ Linux ที่จะทาการ Backup



3/1/2012 5

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03







ข้อมูล ทั้ง client และ server จะต้องมีโปรแกรม Amanda ลงอยูและเปิ ดเป็ น service



ให้ทางานได้ภายใต้ xinetd (ดู /sbin/chkconfig เพื่อดูวธีการเปิ ด/ปิ ด service) service

ที่จาเป็ นสาหรับการทางานของ Amanda มี amanda, amandaidx และ amidxtape

# chkconfig --add amanda

# chkconfig --add amandaidx

# chkconfig --add amidxtape









อย่างไรก็ตามควรตรวจสอบ security setting ของเครื่ องด้วยเช่นจาก /etc/hosts.allow,

/etc/hosts.deny, ipchains หรื อ iptable ว่ามีการจากัดหรื อปฏิเสธการใช้งาน service

ของ Amanda หรื อไม่ โดยดูหมายเลข service ได้จากไฟล์ /etc/services



นอกจากนี้ โปรแกรม Amanda เองยังมีส่วนของการตั้ง security เองด้วย



โดยจะอยูในไฟล์ /var/lib/amanda/.amandahosts ในเครื่ อง client แต่ละเครื่ อง

้ ้

ผูใช้ตองใส่ ชื่อของเครื่ อง server และ user (ปกติคือ amanda)



ที่จะอนุญาตให้เข้ามาดึงข้อมูลในเครื่ อง client ได้ดงตัวอย่าง

localhost amanda

localhost.localdomain amanda

localhost.localdomain root









5.2 ั

การตั้งค่าการทางานให้กบโปรแกรม Amanda

ก่อนที่เราสามารถใช้งานโปรแกรม Amanda ได้น้ น ั

จะต้องทาการตั้งค่าการทางานให้เหมาะกับอุปกรณ์ Tape Library ที่เรามีอยูก่อน เพราะ



Amanda ไม่สามารถตรวจสอบอุปกรณ์แบบอัตโนมัติได้ โปรแกรม Amanda

เก็บค่าการทางานเอาไว้ภายได้ไดเรกตอรี /etc/amanda/ โดยที่

คือชื่อของไดเรกตอรี ของค่าเริ่ มต้นแต่ละชุด เช่น /etc/amanda/DailySet1

เป็ นตัวอย่างของค่าการทางานที่ให้มากับ Redhat Linux



ภายในจะมีไฟล์อยูสองไฟล์คือ amanda.conf และ disklist





สมมติวาเราจะสร้างค่าการทางานชุดใหม่ชื่อ newconfig



ให้ทาการสร้างไดเรกตอรี ข้ ึนภายใต้ /etc/amanda และทาการ copy ไฟล์ตวอย่างใน

DailySet1 มาไว้ใน newconfig ดังนี้

# su - amanda

$ cd /etc/amanda

$ mkdir newconfig







3/1/2012 6

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03



$ copy DailySet1/* newconfig









จากนั้นสร้างไดเรกตอรี ที่ใช้เก็บสถานะของการทางานของโปรแกรม Amanda

ภายใต้ไดเรกตอรี /var/lib/amanda/ เพื่อที่จะให้การทางานของโปรแกรม

Amanda ในครั้งถัดไปเป็ นไปอย่างถูกต้อง นอกจากนี้ภายใต้ไดเร็ กตอรี

/var/lib/amanda/ ยังใช้เก็บดัชนีของไฟล์ต่างๆ ที่ได้ทาการ Backup



ไว้ดวยโปรแกรม Amanda

$ mkdir /var/lib/Amanda/newconfig









แก้ไขไฟล์ amanda.conf ดังนี้

General Parameters

org "Your Organization" # your organization name for reports

mailto "amanda" # space separated list of operators at your site

dumpuser "amanda" # the user to run dumps under



netusage 10 mbytes # maximum net bandwidth for Amanda











ประกอบด้วย org คือชื่อที่จะใช้ระบุอยูในรายงานที่ส่งให้ผดูแล, mailto

ู้



คือรายชื่อของผูดูแลที่โปรแกรม Amanda จะส่ งรายงานไปให้ทางอีเมล์, dumpuser

คือชื่อของ user ในระบบ unix (ค่าปกติคือ amanda) ที่ Amanda

จะทางานด้วยสิ ทธิ์ ของ user นี้เวลาทาการ Backup ดังนั้น user

นี้จะต้องมีสิทธิ์ ในการอ่านไฟล์ที่จะ Backup, netusage

ระบุถึงอัตราการส่ งข้อมูลสู งสุ ดที่อนุญาตให้ Amanda ใช้



Dump Cycle Parameters

dumpcycle 14 days # the number of days in the normal dump cycle

runspercycle 2 # the number of amdump runs in dumpcycle days

tapecycle 10 tapes # the number of tapes in rotation

runtapes 5 # number of tapes to be used in a single run





dumpcycle คือระยะเวลาที่แต่ละไดเรกตอรี จะถูกทา Full Backup อย่างน้อยหนึ่งครั้ง,

runspercycle คือจานวนครั้งที่เราจะให้ Amanda

ทางานในช่วงระยะเวลาตามที่กาหนดใน dumpcycle, ส่ วน runtapes

คือจานวนเทปสู งสุ ดที่กาหนดให้ Amanda ใช้ต่อการทางานหนึ่งครั้ง

และสามารถมีค่ามากกว่า 1 ได้ถามีการใช้ Tape Library, สุ ดท้ายคือ tapecycle



มีค่าเท่ากับ runspercycle*runtapes



3/1/2012 7

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





คือจานวนเทปทััั้งหมดสาหรับค่าการทางานชุดนี้

่ ่

อย่างไรก็ตามเพือความปลอดภัยก็ควรจะมีเทปสารองเผือให้ในระบบอีกอย่

างน้อยเท่ากับจานวน runtapes ดังนั้นค่า tapecycle

ที่ได้รวมการสารองเทปแล้วจะมีค่าเท่ากับ (runspercycle+1)*runtapes



Tape Device and Changer Parameters

tpchanger "chg-scsi" # the tape-changer glue script

tapedev "0" # the no-rewind tape device to be used

changerfile "/etc/amanda/newconfig/chg-scsi-linux.conf"

tapetype SDLT110 # what kind of tape it is (see tapetypes below)

labelstr "^tape[0-9][0-9]$" # label constraint regex:

# all tapes must match

define tapetype SDLT110 {

comment "SuperDLT 110"

length 109 gbytes

}





ในกรณี ที่ใช้แต่ Tape Drive เราจะตั้งค่าให้ tapedev เป็ น /dev/nst0 (Tape Drive แบบ

ไม่ทาการ rewind) แต่ในกรณี ของเราที่ใช้ Tape Library นั้น tapedev คือหมายเลข

config ที่เราจะกาหนดไว้ใน changerfile, tpchanger มีค่าดังแสดงในตัวอย่าง

และจะกาหนดให้ changerfile คือไฟล์กาหนดค่าการทางานของ Tape Library

ที่เราใช้อยู่ ซึ่ งจะกล่าวในอันดับต่อไป, tapetype

จะระบุชนิดของเทปที่จะใช้งานในการทางานนี้ และจะต้องมีชนิดตรงกับที่กาหนดอยูใ ่

นส่ วนของ define tapetype ในตัวอย่างเป็ นการกาหนดเทปชนิด Super DLT 110

ให้มีความจุขนาด 109 Gbytes, ส่ วน labelstr เป็ นการกาหนดให้ Amanda ใช้เทปที่มี

label ตรงกับที่กาหนดไว้ในการ Backup นี้เท่านั้น ไม่ให้ใช้ปะปนกับ Backup ชุดอื่น

โปรแกรม Amanda จาตรวจสอบเทปกับ labelstr โดยใช้ reqular expression



Holding Disk

holdingdisk hd1 {

comment "main holding disk"

directory "/tmp" # where the holding disk is

use -1000 Mb # how much space can we use on it

# a negative value mean:

# use all space except that value

}





เนื่องจากอุปกรณ์ Tape Drive มักมีความเร็ วในการเขียน-อ่านข้อมูลช้ากว่า network

่ ั

และฮาร์ ดดิสก์ที่มีอยูในปั จจุบน ดังนั้นโปรแกรม Backup

ที่ดีควรจะเขียนข้อมูลลงในเทปได้อย่างต่อเนื่ องตลอดเวลาไม่ให้เกิดการหยุดชะงัก

โปรแกรม Amanda





3/1/2012 8

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





่ ่

เป็ นโปรแกรมที่ออกแบบมาให้สามารถนาพื้นที่วางที่มีอยูในฮาร์ ดดิสก์มาช่วยทา

buffer สาหรับข้อมูลที่กาลังรอเขียนเข้าไปในเทป

ทาให้ใช้ประโยชน์จากเทปได้อย่างเต็มประสิ ทธิ ภาพเพราะข้อมูลที่ Backup

จะถูกส่ งมาพักใน Holding Disk ก่อนแล้วก็จะถูกส่ งต่อไปยัง Tape Drive

อย่างต่อเนื่ องตลอดเวลา ดังนั้น Holding Disk

ที่มีขนาดใหญ่เพียงพอจึงมีผลอย่างมากต่อความเร็ วในการ Backup ขนาดของ Holding

Disk ที่แนะนาควรมากกว่าขนาดของไดเรกตอรี ที่ใหญ่ที่สุดที่จะทาการ Backup



อย่างไรก็ตามโปรแกรม Amanda สามารถทางานได้ดีกบระบบที่มี Holding Disk

น้อยหรื อที่ไม่มี Holding Disk เลย



Dumptype Strategies

define dumptype always-full {

comment "Full dump of this filesystem always"

program "GNUTAR"

record no

compress none

index yes

priority high

dumpcycle 0

}



define dumptype nocomp {

comment "backup without compression, no /etc/dumpdates recording"

compress none

record no

priority high

program "GNUTAR"

index yes

exclude ".[0-9a-zA-Z]*"

}



define dumptype comp {

nocomp

comment "backup with compression, no /etc/dumpdates recording"

compress client fast

priority high

index yes

}









dumptype เป็ นการกาหนดวิธีการ Backup ในแบบต่างๆ เช่นแบบ always-full

เป็ นการใช้โปรแกรม gnu-tar ในการ copy ไฟล์แบบ Full Backup ในทุกๆ

ครั้งโดยไม่ใช้ Software compression และมีการบันทึก index ของไฟล์ที่ Backup ไว้,

nocomp เป็ นการ Backup โดยใช้ gnu-tar ภายใต้เงื่อนไข Full หรื อ incremental

Backup ตามที่คานวณจากโปรแกรม Amanda มีการบันทึก index แต่ไม่มีการใช้

Software compression และไม่ตองทาการ Backup ไฟล์ที่ซ่อนเอาไว้ (ขึ้นต้นด้วย “.”),



ส่ วน comp เป็ นการ Backup แบบเดียวกับ nocomp ยกเว้นว่าใช้ Software compression

ด้วย





3/1/2012 9

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03









Logging and Reporting parameters

infofile "/var/lib/amanda/newconfig/curinfo" # database filename

logdir "/var/lib/amanda/newconfig" # log directory

indexdir "/var/lib/amanda/newconfig/index" # index directory





เป็ นการกาหนดที่ที่ใช้เก็บไฟล์สถานะ, index และ log ไฟล์ของโปรแกรม Amanda

ซึ่งเราได้สร้างไดเรกตอรี ไว้ในตอนแรกแล้ว



Network Parameters



define interface local {

comment "a local disk"

use 10 mbytes

}



define interface eth0 {

comment "100 Mbps ethernet"

use 10 mbytes

}



เป็ นการกาหนดค่าสู งสุ ดของ network bandwidth ที่อนุญาตให้ Amanda ใช้ใน

interface นั้น โดยจะต้องทาการระบุ interface ไว้ในไฟล์ disklist ด้วย



5.3 ั

การกาหนดค่าการทางานให้กบ Tape Library

ตามที่ได้กล่าวไว้ในหัวข้อที่แล้วว่าถ้าอุปกรณ์ที่ใช้เป็ น Tape Library



เราจะต้องกาหนดค่าให้กบตัวแปร tpchanger และ changerfile ดังนี้

tpchanger "chg-scsi" # the tape-changer glue script

changerfile "/etc/amanda/newconfig/chg-scsi-linux.conf"









เราจะต้องสร้างไฟล์ /etc/amanda/newconfig/chg-scsi-linux.conf

ขึ้นมาเพื่อเก็บค่าการทางานของ Tape Libraryดังนี้

number_configs 1

eject 0 # Tapedrives need an eject command

sleep 5 # Seconds to wait until the tape gets ready

cleanmax 100 # How many times could a cleaning tape get used

changerdev /dev/sg0

#

# Next comes the data for drive 0

#

config 0

drivenum 0

dev /dev/nst0

scsitapedev /dev/sg1

startuse 0

enduse 24

statfile /var/lib/amanda/rdc/nst0-slot

cleancart 15

cleanfile /var/lib/amanda/rdc/nst0-clean







3/1/2012 10

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03



usagecount /var/lib/amanda/rdc/totaltime

tapestatus /var/lib/amanda/rdc/tapestatus

havebarcode 1

labelfile /var/lib/amanda/rdc/labelfile









number_configs บอกจานวนของ config ที่ถูกกาหนดไว้ในไฟล์น้ ี, eject ถ้าให้ค่าเป็ น 1

หมายถึง Tape Drive นั้นต้องการคาสั่ง eject โดยตรงจาก software เมื่อต้องการ unload

tape, sleep จะระบุเวลาเป็ นวินาทีที่โปรแกรม amanda รอก่อนที่จะทางานกับเทป,

cleanmax คือจานวนครั้งที่ cleaning เทปหนึ่งๆ จะใช้ได้, changerdev

คือชื่อของอุปกรณ์ของ Robot ในกรณี ของตัวอย่างนี้คือ /dev/sg0, config

ระบุถึงส่ วนของ config หมายเลข 0, drivenum คือหมายเลขของ Tape Drive ที่อยูใน ่

Tape Library เริ่ มจาก 0 (ใน Tape Library บางรุ่ นมี Tape Drive มากกว่าหนึ่งตัว), dev

คือชื่อของ Tape Drive นี้ใน Linux ในที่น้ ีคือ /dev/nst0, scsitapedev

เป็ นชื่อของอุปกรณ์ SCSI แบบ generic ที่เป็ นตัวเดียวกันกับ Tape Drive ในที่น้ ีคือ

/dev/sg1, startuse คือหมายเลขต่าสุ ดของ slot ใน Tape Library เริ่ มจาก 0, enduse

คือหมายเลขสู งสุ ดของ slot ใน Tape Library (สังเกตว่าหมายเลขต่าสุ ดของ slot



ที่ได้จากคาสั่ง mtx –f /dev/sg0 status นั้นเริ่ มจาก 1), cleancart เพื่อระบุวา cleaning



tape เก็บอยูใน slot ที่เท่าไหร่ , และ cleanfile, statfile, usagecount, tapestatus, labelfile

ใช้เก็บสถานะการทางานของ Tape Library, ส่ วน havebarcode

นั้นไม่พบว่ามีผลต่อการทางาน



5.4 การกาหนดตาแหน่งของข้อมูลที่จะทาการ backup (การกาหนด disklist)



ไฟล์ disklist ที่อยูใต้ /etc/amanda/ นั้นใช้กาหนดสิ่ งที่จะ Backup

ตามรู ปแบบต่อไปนี้

hostname diskdev dumptype [spindle [interface]]









hostname ระบุชื่อของเครื่ อง client ที่จะทาการ Backup, diskdev ระบุ filesystem

หรื อไดเรกตอรี ที่จะ Backup, dumptype คือวิธีการ Backup ที่กาหนดไว้ใน

amanda.conf,

ส่ วน spindle นั้นยังไม่พบคาอธิ บายในเอกสารใดๆ ของ Amanda (ค่าปกติคือ –1),

interface คือชื่อของ interface ที่ถูกกาหนดไว้แล้วใน amanda.conf เพื่อใช้จากัด

network bandwidth







3/1/2012 11

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





ตัวอย่างของไฟล์ disklist

localhost /home nocomp

localhost /usr /local comp



www /var/html always-full

www /home nocomp









5.5 ั

การกาหนดเทปที่จะใช้กบโปรแกรม Amanda

ก่อนทาการ Backup จะต้องเตรี ยมเทปที่มี label ตรงกับที่ระบุไว้ในตัวแปร labelstr

ในไฟล์ amanda.conf โดยจะต้องใส่ เทปเข้าไปใน slot ของ Tape Library

จากนั้นสั่งคาสั่งเช่น

$ amlabel newconfig tape01 slot 1

$ amlabel newconfig tape02 slot 2









5.6 การทาการ Backup

ใช้คาสั่งที่เครื่ อง server

$ amdump newconfig





เพื่อเริ่ มทาการ Backup



ในขณะที่กาลัง Backup เราสามารถเรี ยกดูสถานะของการ Backup ได้ที่เครื่ อง server

โดยใช้คาสัง



$ amstatus newconfig

Using /var/lib/amanda/newconfig/amdump from Tue Oct 29 10:27:44 ICT 2002



localhost:/home getting estimate

localhost:/usr/local getting estimate

www:/var/html getting estimate

www:/home getting estimate



SUMMARY part real estimated

size size

partition : 8

estimated : 0 0k

failed : 0 0k ( 0.00%)

wait for dumping: 0 0k ( 0.00%)

dumping to tape : 0 0k ( 0.00%)

dumping : 0 0k 0k ( 0.00%) ( 0.00%)

dumped : 0 0k 0k ( 0.00%) ( 0.00%)

wait for writing: 0 0k 0k ( 0.00%) ( 0.00%)

writing to tape : 0 0k 0k ( 0.00%) ( 0.00%)

failed to tape : 0 0k 0k ( 0.00%) ( 0.00%)

taped : 0 0k 0k ( 0.00%) ( 0.00%)

all dumpers active

taper idle









3/1/2012 12

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03





เมื่อโปรแกรม Amanda ทางานเสร็ จสิ้ นเราจะได้รับเมล์รายงานการ Backup ของ

Amanda ที่ส่งให้ผดูแลตามที่ได้กาหนดค่าไว้ใน mailto ในไฟล์ amanda.conf

ู้

ดังตัวอย่างต่อไปนี้







$ STATISTICS:

Total Full Daily

-------- -------- --------

Dump Time (hrs:min) 5:03 3:23 0:33 (0:14 start,

0:53

idle)

Output Size (meg) 20434.4 17960.0 2474.4

Original Size (meg) 20434.4 17960.0 2474.4

Avg Compressed Size (%) -- -- --

Tape Used (%) 137.4 120.0 17.4 (level:#disks

...)

Filesystems Dumped 90 21 69 (1:64 2:2 3:3)

Avg Dump Rate (k/s) 1036.5 1304.3 416.2

Avg Tp Write Rate (k/s) 1477.6 1511.2 1271.9









5.7 การตั้งให้ Amanda ทางานแบบอัตโนมัติ

เราสามารถตั้งให้ Amanda ทางานแบบอัตโนมัติโดยผ่านทาง cron

ซึ่ งเป็ นโปรแกรมการจัดการทางานของโปรแกรมต่างๆ ตามเวลาที่ได้ระบุไว้

โดยการใช้คาสั่งต่อไปนี้ที่เครื่ อง server

$crontab -e









เราจะเห็น editor ของ cron

ขึ้นมาในหน้าจอเพื่อทาการปรับการทางานของโปรแกรมต่างๆ ดังตัวอย่างนี้

(ขอให้ศึกษารู ปแบบการ config ของ cron จาก “man 5 crontab”)

# amanda backup every weekend

0 1 * * Sat /usr/sbin/amdump newconfig





จากตัวอย่างจะเป็ นการ config ให้ Amanda ทางานกับ newconfig ทุกๆ 01:00

น.ของวันเสาร์ ซ่ ึ งสอดคล้องกับที่กาหนดไว้ใน amanda.conf ให้มี dumpcycle เป็ น 14

วันและ

Runspercycle เป็ น 2 ครั้ง



6. การ Restore ด้วยโปรแกรม Amanda

สิ่ งที่สาคัญที่สุดในเรื่ องของการ Backup คือข้อมูลที่ถูก Backup ไว้สามารถถูก Restore



กลับมาใหม่ได้ โปรแกรม Amanda มีคาสั่งที่ใช้ในการ Restore อยูสองคาสั่งคือ amrestore และ



3/1/2012 13

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03







amrecover คาสั่ง amrestore มีลกษณะการทางานคล้ายกับคาสั่ง tar จึงเหมาะกับการ Restore

้ ่

ไฟล์ขอมูลทั้งหมดที่อยูใน track ใด track หนึ่ง ส่ วนคาสั่ง amrecover

ั ้ ู้

มีลกษณะการทางานเหมือนกับคาสั่ง restore ที่ตองให้ผใช้เข้าไปดูไฟล์จาก index ที่ Amanda



บันทึกไว้ในขณะการทา Backup, เลือกไฟล์ที่ตองการจนครบ แล้วจึงสังให้ทาการ Restore



ไฟล์เหล่านี้



6.1 การใช้คาสั่ง amrestore

$amrestore -p /dev/nst0 | tar -xvf -









ั ั

เป็ นการอ่านข้อมูลจาก track ปั จจุบนแล้วส่ งข้อมูลต่อให้กบโปรแกรม tar

ในการจัดการ extract ข้อมูลใส่ ในฮาร์ ดดิสก์ เราสามารถระบุ options ต่างๆ



ที่มีอยูในโปรแกรม tar เพิ่มเติมได้





ในการค้นหาว่าข้อมูลล่าสุ ดที่เราต้องการเก็บอยูที่เทปม้วนใดเราใช้คาสั่ง

amadmin newconfig info localhost /home



Current info for localhost /home:

Stats: dump rates (kps), Full: 1344.0, 1344.0, -1.0

Incremental: 1344.0, -1.0, -1.0

compressed size, Full: -100.0%,-100.0%,-100.0%

Incremental: -100.0%,-100.0%,-100.0%

Dumps: lev datestmp tape file origK compK secs

0 20021025 tape02 1 1330 1344 1









6.2 การใช้คาสั่ง amrecover

การทางานของคาสั่ง amrecover จะอาศัย index ของไฟล์ที่ Amanda

้ ้

ได้ทาการบันทึกไว้ในขณะทาการ Backup โดยใช้ amdump ดังนั้นผูใช้ตองระบุ “index

yes” ภายในส่ วนของ dumptype ในไฟล์ amanda.conf ด้วย และการใช้คาสั่ง amrecover

นี้จะต้องทาด้วย user root เสมอ

$su - root



#amrecover newconfig

AMRECOVER Version 2.4.2p2. Contacting server on localhost ...

220 localhost AMANDA index server (2.4.2p2) ready.

200 Access OK

Setting restore date to today (2002-10-29)

200 Working date set to 2002-10-29.

200 Config set to newconfig.

200 Dump host set to localhost.

amrecover>









3/1/2012 14

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03









ู้ ั

ในขั้นตอนนี้ผใช้สามารถเรี ยกดู help เพื่อดูชุดคาสั่งที่ใช้กบ amrecover ได้

amrecover> help

valid commands are:



add path1 ... - add to extraction list (shell wildcards)

addx path1 ... - add to extraction list (regular expressions)

cd directory - change cwd on virtual file system

clear - clear extraction list

delete path1 ... - delete from extraction list (shell wildcards)

deletex path1 ... - delete from extraction list (regular expressions)

extract - extract selected files from tapes

exit

help

history - show dump history of disk

list [filename] - show extraction list, optionally writing to file

lcd directory - change cwd on local file system

ls - list directory on virtual file system

lpwd - show cwd on local file system

mode - show the method used to extract SMB shares

pwd - show cwd on virtual file system

quit

setdate {YYYY-MM-DD|--MM-DD|---DD} - set date of look

setdisk diskname [mountpoint] - select disk on dump host

sethost host - select dump host

settape [host:][device|default] - select tape server and/or device

setmode smb|tar - select the method used to extract SMB shares



amrecover>











จากนั้นผูใช้จะต้องทาการเลือกชื่อเครื่ อง, ไดเรกตอรี และเวลาที่ทาการ Backup



ของข้อมูลที่ตองการ

amrecover> sethost localhost

200 Dump host set to localhost.

amrecover> setdisk /home

Scanning /home...

20021022: found Amanda directory.

20021029: found Amanda directory.

200 Disk set to /home.

amrecover> ls

2002-10-25 .

2002-10-25 guest/

2002-10-25 webmast/

amrecover> setdate 2002-10-22

200 Working date set to 2002-10-22.

amrecover> ls

2002-10-22 .

2002-10-22 guest/

2002-10-22 webmast/









จากนั้นผูใช้สามารถใช้คาสั่ง ls หรื อ cd ในการเข้าไปดูไฟล์หรื อไดเร็ กตอรี ต่างๆ





ที่เก็บไว้ และใช้คาสั้ง add ในการเลือกไฟล์หรื อไดเร็ กตอรี ที่ตองการ

amrecover> cd guest

/home/guest

amrecover> ls

2002-10-22 .

2002-10-22 Linux/

2002-10-22 public_html/

amrecover> cd public_html

/home/guest/public_html

amrecover> ls







3/1/2012 15

ปรับปรุ งล่าสุดเมื่อวันที่ 2012/01/03



2002-10-22 .

2002-10-22 amanda_documents/

2002-10-22 index.html

2002-10-22 index.css

amrecover> add index.*

Added /guest/public_html/index.html

Added /guest/public_html/index.css

Amrecover> add manda_documents

Added dir /guest/public_html/gen_admin at date 2002-10-22

Amrecover>









้ ้

เมื่อเราได้ขอมูลที่ตองการจนครบแล้ว ก็จะสังให้ amrecover ทาการ extract



ไฟล์ลงในไดเรกตอรี ปัจจุบน ั

amrecover> extract



Extracting files using tape drive 0 on host localhost.

The following tapes are needed: tape01



Restoring files into directory /tmp

Continue? [Y/n]: y



Load tape tape01 now

Continue? [Y/n]: y

set owner/mode for '.'? [yn] n

amrecover> quit









3/1/2012 16


Shared by: pptfiles
Other docs by pptfiles
Memovorlage Xella International(1)
Views: 0  |  Downloads: 0
Memovorlage Xella International
Views: 0  |  Downloads: 0
Members of the International Roundtable
Views: 0  |  Downloads: 0
ME-FA International Sp
Views: 0  |  Downloads: 0
Medical Records International(1)
Views: 0  |  Downloads: 0
Medical Records International
Views: 0  |  Downloads: 0
Related docs
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!