intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Hệ quản trị cơ sở dữ liệu Oracle 9i (Tập 2): Phần 2

Chia sẻ: _ _ | Ngày: | Loại File: PDF | Số trang:114

13
lượt xem
3
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Nối tiếp phần 1, phần 2 cuốn sách "Thành thạo Oracle 9i - Quản trị cơ sở dữ liệu (Tập 2)" hướng dẫn bạn sao lưu và phục hồi dữ liệu, quản lý hoạt động CSDL Oracle 91, thực hiện hiệu chỉnh hiệu suất thực thi và xử lý sự cố cho CSDL thực. Mời các bạn cùng tham khảo nội dung chi tiết!

Chủ đề:
Lưu

Nội dung Text: Hệ quản trị cơ sở dữ liệu Oracle 9i (Tập 2): Phần 2

  1. C h tfc fn g 13: Sao luu ca so dur lieu 123 a ® C h iic fn g 13: SAO Ll/U CO sd Dtf LIEU Chitctng nay de cap cdc va n de sau: V Sao luu C S D L Oracle. T ie n ich R M A N cua Oracle. s S ii d u n g lap quan ly phuang tien voi R M A N . V Sao luu bdng cdc lenh he dieu hanh. s N a n g cao kha nang bao ve dU lieu de khoi phuc. V S a i lac C S D L vd kiem tra cdc sao lUu. s Ky thudt vd x ii ly sU cd. s K et chuang. Chuang nky de cap ve viec sao luu C S D L Oracle. M ot trong nhtfng tdc vu ccf ban cua nhd quan tri C S D L (N Q T C S D L ) Oracle la dam bao C S D L dugc sao luu deu ddn. Sao luu la ccf so cho tat ca cdc phuc hoi CSD L, khong c6 sao luu thi khong c6 phuc hoi. M ot tron g nhting viec tot nhat ban co the lam cho chinh ban nhu mot N Q T C S D L la tap trung len chien luge thuf va k iem tra viec sao luu CSD L, bdi vi ban ton nhieu thdi gian cho ke hoach sao luu, ban se ton it thdi gian han de phuc hoi C SD L khi c6 sU co. C6 2 phuang phap khac nhau de thuc hien sao luu: dung trinh quan ly phuc hoi R ecovery M a n a g e r(R M A N ) cua Oracle va dung lenh cua he dieu hdnh. Cdc th iet bi bdng tU thudng dugc dung trong sao luu bdi vi su tien lgi cua chung va luu trU an toan. Neu ban muon dung R M A N vdi cac th iet bi bdng tU, ban can dung ldp quan ly phuang tien (M edia M anagem ent L a y er - M M L ) dugc cung cap bai nha cung cap thU 3 giup giao tiep giUa th iet bi bdng tti va R M A N d i dang han. Ban cung co the dung cong cu khac tron g do co san pham Legato Single S erver Version (L S S V ), m ien phi vdi Oracle server.
  2. [M | ® 124 P h a n I V : N a p , sao I1 1 va khoi phuc dtf ligu A 1. S A O L l/ U C S D L O R A C L E Sao luti C S D L dugc dung de trdnh m at dur li?u. B at cU dieu gi cung co the dan den m at duf lieu, vi the can th ie t phai c6 h§ th on g sao luu. Sao luu bao gom viec giU cdc ban sao cdc tap tin C S D L khac nhau de C S D L co the dugc tao lai khi can todn bo hodc tim g phdn. Sao luu Oracle lien quan den sao chep cdc tap tin C S D L Oracle. Thudng Id cdc tap tin dur lieu, tap tin dieu khien va cdc tap tin redo log. Ban cung co the' van hanh C S D L Oracle o 2 che do: arch ivelog vd noarchivelog. Neu CSDL r hoat dong d che do archivelog, Oracle se luu trtf ta t ca cac redo log trudc khi ghi de chung. Che do noarchivelog khong luu v e t nhumg thay doi cua C S D L do no ghi ta t ca nhufng thay doi vdo CSD L. 1.1. Cac thuat ngi? sao ltfu V iec sao ltfu C S D L la hoat dong then chot vd cdc kieu sao luu, c3c dieu kien ban thuc hien sao luu dong vai tro quan tron g tron g kha ndng phuc hoi CSD L. Hieu ro ve cdc kieu sao luu vd cdc khdi niem sao luu cue ky quan tron g cho sU thanh cong cua khoi phuc CSD L. 1.1.1. C dc che do a rc h ive lo g vd n o a rc h ive lo g Oracle ghi ta t ca nhufng thay doi vdi cdc khoi dur lieu tron g bo nhd vao cdc redo log true tuyen, thong thudng trudc khi chung dugc ghi vdo cdc tap tin CSD L. T ro n g qud trin h phuc hoi, O racle se suf dung nhufng thay doi dd ghi tron g cdc tap tin redo log de dua C S D L ve tra n g thdi mdi cap nhat gdn nhat. Oracle cd the quan ly cac tap tin redo log theo 2 cdch. T ron g che do archivelog, Oracle ltfu trtf cac redo log da ddy. Nhu vay khong co van de sao luu C S D L cu tdi mure do nao, neu ban dang d che do archivelog ban cd the phuc hoi C S D L tdi bat ctf diem thdi gian nao bdng cdc redo log da luu trtf. T ro n g che do noarchivelog, cac tap tin redo log day bi ghi de va khong dugc luu trtf. Che do n oarch ivelog ngu y rdng ban chi cd the phuc hoi ttf dtf lieu sao ltfu vd ban se m at ta t ca nhtfng th ay doi da thuc hien tdi C S D L sau thdi diem sao luu dugc thuc hien. Chi co hoat dong d che do archivelog dam bao nhtfng d ilu sau: • Ban cd the phuc hoi hoan toan C S D L ttf su hu hong th iet bi phucfng tien cung nhu the' hien cua CSD L. ■ Ban cd the phuc hoi tat ca dtf lieu tron g su kien hu hong 6 dia.
  3. C h tfc fn g 13: Sao ltfu ca sd dtf lieu 125 [ M ■ Ban c6 the duy tri tin h s in skng cao bdi vi C S D L dang chay a che do arch ivelog khong can phai dtfng hoat dong de sao luu. Ban c6 the sao luu true tuyen tron g che do nky. ■ Ban c6 the thuc hien sao luu md, nghia lk sao luu trong khi C SD L dang hoat d
  4. * 126__________________________________P h a n IV : N a p , sao ltfu v£ khoi phuc dtf li^u Be sao ltfu nhat qukn, C S D L c in dugc dong ( vdi l|nh shutdown hoac shutdown transactional, khong dugc dung l§nh shutdown abort) hoac d vi tri mount sau khi dugc khdi dong. 1.1.4. Sao ltfu d o n g vd m d Sao luu true tuyen hoac m a la nhting sao luu dugc thuc hien trong khi C S D L dang md vk co the dugc truy nhap doi vdi ngudi dung. Ban chi c6 the sao luu trUc tuyen khi C S D L chay d che dp archivelog. Sao luu dong con dugc goi la sao luu nguoi dugc thuc hien khi C S D L dtfng hoat dong. Sao luu d6ng luon n h at qukn m iin la CSDL khong bi dtfng bkng lenh shutdown abort. Liti khuyen: D ieu quan tro n g nen n h o la ni'u sao lilu trtfc tuyen hoAc sao ltfu dong nhtfng kh ong nhdt quan, ban co the dp dung cdc redo log dd ltfu trtf de la m cho C S D L nhdt quan. Quyet dinh thuc hien sao luu true tuyen hay sao luu dong lk quyet dinh phu thuoc vko ckc yeu cau giao dich. N eu h$ th on g doi hoi CSDL cua ban phai hoat dong 24/24 (24 tie'ng moi n ga y ) thi ban phai sao luu true tuyen. Tan suat sao luu dong vk so' redo log dugc sinh ra bdi CSDL 1a 2 nhan to” dong thdi dung de thuc hien phuc hoi CSD L. 1.2. Chien ltfcfc sao ltfu Ban khong the co m ot chi'nh sach sao luu tot neu khon g co it nhat mot chien luge ca ban lien quan den viec sao luu C SD L. Ban co the cho rang theo thdi gian se co m at m at dtf lieu. Ban can m ot chien ltfgc de ban co the skn sang cho tin h huong nky. Chien luge sao luu cua ban chu yeu phu thuoc vao loai S L A (Service L evel A greem en t) ban co. S L A thtfdng bao gom cac nhan to' sau: ■ Duy tri cac ctia sd lkm viec. • N a n g cap cac bieu thdi gian. ■ Cac thu tuc sao ltfu v a phuc hoi. ■ Thdi gian dap tfng cho cac hoat dong C S D L chinh. ■ Cac thong sd ve thdi gian chet cua server vk CSD L. 1.2.1. Htf&ng dan sao ltfu K hong de cap den S L A va cac yeu cku phuc hoi cua ban. mot sd htfdng dkn chung cho cac qua trin h sao luu se giup ban tranh viec phuc
  5. C h tfc fn g 13: Sao ltfu ca sd dtf li§u 127 [ M hoi tron g h iu h et ckc trudng hop. Sau cung, chien luge sao luu tot nhat cho phuc hoi lk trknh phai thuc hien phuc hoi bkng cach thuc hien sao luu vk h| thong bko v f dU lieu thich hop. Ckc hudng dan chung nhu sau: ■ X ay dung kha n&ng du ph6ng tron g he thong bkng ckch suf dung he thong luu trU dua tren R A ID . ■ Thuc hi§n sao luu thudng xuyen vk deu dan de giam thdi gian phuc hoi. ■ Bko tri ckc th ie t bi luu trU ckc sao luu cua ban. ■ Luon chay C S D L chUa dU lifu htiu dung cua to chUc d che do archivelog. ■ Luon dung co che m ultiplex cho ckc tap tin dieu khien tren ckc o dia khke nhau duoc quan ly bdi ckc bo dieu khien dia (disk con troller) khke nhau. M u ltiplex nghia lk Oracle tu dong duy tri nhieu hon m ot ban sao cua tap tin. Thuc hien tuang tu cho ckc redo log. ■ Sau m6i lan th ay doi cau true chinh cua CSD L, hay sao luu tap tin dieu khien. ■ T an dung thuan lg i cua tuy chon archivelog da thanh phan vk th iet lap tuy chon m in succeed D E S T gik tri toi thieu lk 2 hokc ldn han de dam bao rkng ban c6 nhieu tap arch ivelog tot. ■ Luon c6 nhieu han m ot ban sao cua C S D L khi no da dugc sao luu vko bkng tU. ■ Luon lap bieu sao luu deu dan cac tap tin khai tao, tap tin m ang vk tap tin m at khku. ■ H an che toi thieu viec suf dung ckc tuy chon khong ghi log va khong phuc hoi. ■ Suf dung cong cu R M A N de sao luu vk phuc hoi. R M A N duy tri tap tin log cua ta t ca cac hoat dong sao luu vk phuc hoi, vi the rat d l de truy v e t nhtfng hoat dong nky. ■ It nhat co 2 ban sao cac tap tin redo log, m5i ban ltfu tren mot dia de rut ngkn thdi gian phuc hoi neu th iet bi ltfu trtf chung co van de. ■ N e n gitf ban sao ltfu C S D L cu han de dtf phbng them tron g trudng hgp ckc ban sao ltfu hien thdi khong the dung dugc vi ly nao do.
  6. M 18 2 LluJ-------- P h ^ n I V : N a p , sao ltfu vft khoi phuc dfl li^u K hong lk y ttfcrng hay khi ghi dfe ngay ckc bkn g tti luu trti vi ly do chi phi. • Dam bao ting dung nkm tren ckc khong gian bang rien g b ift, de ban khong phki dting nhieu hon m pt ting dung neu c6 van de nghiem tron g ve phuong tipn ltfu trtf. ■ Xem x et sti dung ckc ky thuat sao luu dung he th on g luu trti bkng cong nghe snapshot giup sao luu nhanh ckc C S D L lorn. • Sti dung tien ich export de bao v£ them dti lieu. 1.2.2. K ie m tra cdc b a n sao litu Thudng N Q T C S D L gap phai lk chien luge sao luu c6 nhugc diem xay ra trong quk trin h phuc hoi CSD L. N gu yen nhan 1a do khong thich hop hoac tham chi khong c6 m ot ke hoach vk k iem tra chien luge sao luu vk phuc hoi. Thdi gian de biet C S D L cua ban c6 the dugc phuc hoi hay khong hau nhu khong xkc dinh cho tdi khi ban dang co gkng phuc hoi C S D L thuc. De tranh phai trai qua m ot quk trin h phuc hoi toi t# nhtf vay, moi N Q T C S D L nen th ie t lap ke hoach k iem tra sao luu vk phuc hoi C SD L. Sau day lk m ot so hudng dkn k iem tra ckc bkn sao luu C S D L cua ban: ■ K iem tra ta t ca cac tap tin sao luu. Luon k iem tra vk dam bao rkng ckc ban sao luu th at su doc dugc. K iem tra ckc khoi sai lac dti lifu tron g tap tin sao luu de viec phuc hoi khon g trd nen khong the thuc hien dugc do tap tin sao luu bi htf. T ie n ich R M A N va cac sao luu dugc quan ly bdi ngtfdi dung cung cap ckch k iem tra su sai lac tron g cac khoi. • Dinh ky khoi phuc thti ta t ca cac C S D L quan trong. ■ K iem tra su tokn ven cua ckc ban sao luu bkng cac tien ich nhtf d bverify va D B M S _R E P A IR . 1.3. Sao ltfu cac tap tin khac M ac du cac tap tin dtf lieu, tap tin log va tap tin dieu khien la nhtfng tap tin chinh can cho viec phuc hoi, van con nhtfng tap tin khac ban nen sao ltfu vk gitf chung an toan. Do la tap tin tham so initS/D.ora, tap tin sqlnet.ora, tnsnam es.ora vk tap tin pwdSZD.ora. Ban co the tao lai nhtfng tap tin nay neu ban m at nhung dieu nky se lan g phi thdi gian vk co kha nang ban gay loi tron g qua trin h tao lai chung. N h tfn g tap tin
  7. C h tfc fn g 13: Sao luu ca sa dd lieu 19 2 ( M nky chiem ra t it khong gian dia v i the ban nen co thoi quen luu trtf chung. 1.4. Cac phtfcfng phap sao ltfu Du ban thtfc hien sao luu true tuyen hay ngoai tuyen, sao ltfu toan phan hay ttfng phan, ban co 2 phuang phap co the thuc hien sao luu. Phuang phkp thtf nhat dtfgc goi 1a sao luu do ngudi dung quan ly, a do N Q T C S D L hokc ngudi quan trj he thong sti dung hoac cac tien ich cua he dieu hknh hokc cong cu sao luu cua hang thti 3 de thuc hien sao luu CSDL. Phuang phap khac la sti dung cong cu R M A N cua Oracle, no la thknh phan cua bo phan m em Oracle 9i server. Chuang nay chu yeu hudng dkn sti dung R M A N de thuc hien sao lUu. Sau day la tom tkt k et qua cua nhieu kieu sao luu C S D L ban co the' thuc hien: toan phan va tting phan, dong va mcf, nhat quan va khong nhat quan: ■ Neu C S D L duqc dong bkng lenh shutdown abort, no co the khong nhat quan. ■ Neu C S D L ma tron g khi sao luu, no luon khong nhat quan. ■ Neu ban dang chay C S D L d che do archivelog, ban co the thuc hien sao luu ma ma luon khong nhat quan va sao luu dong ma hoac nhat quan hoac khon g nhat quan tuy thuoc vao cach C S D L dugc dong. ■ Neu ban dang chay C S D L a che do noarchivelog, ban chi co the thuc hien phuc hoi dong. ■ Neu ban dang chay C S D L d che do noarchivelog, ban chi co the thuc hien sao luu toan phan. De co the sao luu mot tap tin dti lieu hoac m ot khon g gian bang, tron g hau h et cac trudng hgp, ban nen chay C S D L d che do archivelog. 2. T I E N IC H R M A N C U A O R A C L E N hu da noi trudc do ban co the thuc hien sao luu C S D L theo 2 cach. Thti nhat la phucfng phap sao luu do ngudi dung quan ly, bao gom viec sti dung cac lenh he dieu hanh de sao chep cac tap tin lien quan tai mot nai khac va/hoac th ie t bi bkng tti. Phuang phap khac la dung R M A N , dugc dong goi chung vdi bo phan mem Oracle 9 1 server. Vdi R M A N ban sao luu ckc tap tin C S D L tti tron g CSDL.
  8. [m 3 130 ® P h a n I V : N a p , sao ltfu va khoi phuc dfl li$u L it u y: S d dung R M A N co tot hon svC dung phuang phdp sao lifu do ngtfcn dung quan ly? Hau het doi vdi nhtfng N Q T C S D L O racle “cu ” thi quen dung lenh he didu hanh, tuy nhidn nhtfng N Q T C S D L moi hon co the thich stf dung R M A N vi dd dung, an todn id cd nhtfng tinh ndng md plitfang phdp truyen thong khong co. M ac du c6 nhting uu diem nhung R M A N cung co vai han che. V i du ban khong the doc hoac ghi trUc tiep vao th ie t bi bang tti bkng RMAN. Ban phai sti dung m ot cong cu h an g thti 3 lk M ed ia M an agem en t Layer (M M L ) de thuc hien sao luu vko bkng tti neu ban dung R M A N . Tuy nhien tron g hoat dong lau dai, R M A N co the don gian cac thu tuc sao luu bkng ckch sti dung cac script phuc hoi vk sao luu de ghi va manh. R M A N cung dua ra m ot so tin h nkng nhu do tim dti lieu sai lac tron g ckc khoi dti lieu vk kha nang chi sao luu ckc khoi da thay doi trong CSD L. Ban co the luu ckc script cua R M A N tron g C S D L hoac dung ngay mk khong can luu ra he dieu hanh. R M A N dam bao sao luu ta t ca tap tin C S D L vdi viec loai trti thanh phan loi do con ngudi gay ra co the gap phai nhu tron g sao luu bkng lenh he dieu hanh. 2.1. Ltfi ich cua R M A N Nhting loi ich mk R M A N dem lai khi so sknh vdi phucmg phap tru yln thong (dung lenh he dieu hanh): ■ Ban co the thuc hien sao luu tan g bkng R M A N . K ich thudc tap tin sao luu khong phu thuoc vao kich thudc C SD L. N o phu thuoc mtic do hoat dong tron g C S D L, bdi v i ckc khoi khong thay doi dUdc bo qua tron g sao luu tkng. Ban khon g the thuc hien sao luu tkng bkng bat cti phudng phap nao khac. ■ L oi do ngUdi dung dUdc giam toi thieu bdi vi R M A N giti duoc vet cua ta t ca cac tap tin vk v i tri. K h i ban hieu ckch dung tien ich R M A N , de dang cho ban tiep tuc hoat dong sao luu va phuc hoi ti/ mot N Q T C S D L khac. ■ M ot lenh don gian c h in g han nhu backup database co the sao ltfu toan bo C S D L mk khong can ckc script phtic tap. ■ De dang tu dong hoa qua trin h sao luu va phuc hoi bang R M A N . R M A N cung co the tu dong song hanh ckc phien lam viec sao luu va phuc hdi. ■ R M A N cung co the kiem tra ldi sao luu vk khoi phuc. nhu the dam bao rkng ckc tap tin sao luu khong bi loi. R M A N co kha
  9. C h tftfn g 13: Sao luu ca sd dtf lieu i3i m ndng phuc hoi bat cuf khoi duf lieu bi hu hong nao md khong can offline tap tin duf lieu. ■ T ro n g khi sao luu trUc tuyen, khong c6 redo log nao duoc sinh ra. K hon g gion g nhu sao luu true tuyen dang thuc hien dung lenh he dieu hanh, nhu the sU qud tai 1dm cham qud trinh sao luu trUc tuyen. ■ Neu ban sti dung recovery catalog, ban co the luu true tiep cac script sao luu vd khoi phuc tron g n6. ■ R M A N co the thuc hien gia lap sao luu vd khoi phuc. ■ R M A N cho phep ban thuc hien sao luu anh, tuang tu cdc sao luu tap tin dung lenh he dieu hanh. ■ RMAN co the de dang dugc tich hgp vdi san pham quan ly phuang tien cua h an g thti 3 de thuc hien sao luu vao bdng tti d i ddng. * R M A N dugc tich hgp tot vdi chtic ndng sao luu OEM, vi the ban co the lap bieu cho cdc job sao luu mot cdch d ! dang cho mot so ldn C S D L th on g qua m ot khung lam viec quan ly chung. ■ Ban c6 the de dang tao ban sao C S D L va duy tri C S D L du phong dung chtic ndng R M A N . 2.2. Kien true R M A N R M A N dugc cung cap m ien phi vdi phan mem Oracle server. Tien ich 1dm viec bdng cach md cdc phien lam viec server vdi C S D L dich la C SD L ban muon sao luu hoac phuc hoi. Tap hgp thong tin ve C S D L dich chdng han nhu thong tin ve gian do cua no, thong tin sao chep sao luu, th iet lap cau hinh vd script sao luu vd phuc hoi dugc goi la kho chtia cua R M A N . R M A N dung kho dti lieu nay ve C S D L dich de thuc hien cac hoat dong sao luu va phuc hoi. Cac phan tiep theo de cap cach R M A N quan ly. kho chtia quan tron g nay. 2.2.1. R e c o v e r y C a t a lo g Ban co 2 vi tri de luu trti kho dti lieu cua R M A N . Ban co the de R M A N luu trti dti lieu tron g tap tin dieu khien C SD L dich. hoac ban co the cau hinh vd sU dung tuy chon recovery catalog de quan ly kho dti lieu. Nhting y kien khon g tan dong vdi ban se lien quan den viec sti dung recovery catalog la rdn g no qua phtic tap de duy tri va can C S D L khac de quan ly no. Co mot sd lenh ban chi co the dung khi ban sti dung recovery
  10. M 132 llHlil-------- P h a n I V : N a p , sao ltfu v& khoi phuc dif li^u catalog. Neu ban suf dung tap tin dieu khien, c6 nguy ca m ot so duf li?u lich suf bi ghi de, nhung recovery catalog dam bao cho ta t ca dU li
  11. C h it o n g 13: Sao I1 1 ca sd duf lieu A 133 H Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. RMAN> connect target system/managerl connected to target database: GEN92 (DBID=3382846481) RMAN> exit Recovery Manager complete. C:\> K e t qua sau day tucfng duang vdfi ckc lenh trudc. T ro n g ca 2 trudng hcrp vi du, ban deu dang k et noi tdi C S D L dich la G E N 92 (C S D L dich of he thong ban co the co ten khac). N g a y khi ban k et noi tdi C S D L dich, sau dd ban c6 the phkt hanh cac lenh sao luu/phuc hoi tuang ting. Lenh exit se dua ban rdi khoi m oi trudng R M A N . C:\>rman target system/managerl Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database: GEN92 (DBID=3382846481) RMAN> exit Recovery Manager complete. C:\> 2.3.2. K et n oi tcfi R M A N d u n g xac thitc he dieu hanh Ban cung co the dkng nhap vao R M A N dung xac thuc he dieu hknh. T ro n g trudng hgp nky, ban khong can dung tai khoan va m at khau system /m anagerl. Ban co the thuc hien nhu sau: C:\>rman target/ Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database: GEN92 (DBID=3382846481) RA> MN
  12. M l® 134 P h a n I V : N a p , sao luu v& khoi phuc dQ li
  13. C h tfo fn g 13: Sao IiAj ca sd dtf lieu 135 (M J T a t ca script tron g R M A N co dang run [script] nhu ban se thay trong vi du dudi day. Cac script R M A N ban dau tron g hai kho hieu nhung chung cUc ky hieu qua va de viet. M ot script luon dugc thuc thi vdi lenh run va noi dung script luon dugc dong trong dau ngoac nhon ( ). Khi ban suf dung m ot so” ldn tham so cau hinh cho sao luu cua ban thi dung script se d l dang han. Cac script R M A N thuc thi cung chUc nang nhu ckc script tron g U N IX hoac SQ L: chung dugc luu trU d l dang han vd dugc thuc hien lai vdi cac tap lenh. Sau day la m ot script sao luu vdo buoi toi dan gian de thuc hien sao luu todn bo CSDL. Luu y bang cdch suf dung tU khoa S Q L ban co the dung cdc lenh S Q L thong thudng trong script R M A N . RMAN> create script test_script { 2> allocate channel c1 type disk; 3> backup database format 'e:\oracle\ora92\u%'; 4> SQ L 'alter database backup controlfile to trace'; 5> } created script test_script RMAN> De thuc thi m ot script, ban thuc hien nhu sau: RMAN> run { execute script test_backup;) Script tron g R M A N ra t manh va linh hoat, no cho phep ban thuc hien cac tdc vu phUc tap tron g vai dong lenh. V i du script sau day su dung 2 th iet bi bdng tU de thuc hien sao lUu toan phan CSDL. Script cap phat 2 kenh, hoan ta t sao luu trong dinh dang da xac dinh va sau do giai phong kenh. RMAN> run ( 2> allocate channel c1 type sbt_tape'; 3> allocate channel c2 type sb tja p e '; 4> backup 5> format ’full d%d_u°cu 6> filesperset 10 7> database;
  14. M]® 13fi P h a n I V : N a p , sao luu va khoi phuc dJ li$u 8> release channel c1; 9> release channel c2; 10 > ) 2.5. Cac thuat ngi? quan trong cua R M A N M ot so thuat ngti dugc dinh ngh ia tron g phan sau day lk dknh rien g cho R M A N . De dung R M A N hieu qua, ban can hieu ro ve cac thuat ngti nay. 2.5.1. M a u sao litu M au sao ltfu (Backup p iece) la m ot tap tin he dieu hanh chura sao luu ve tap tin duf lieu, tap tin dieu khien hoac tap tin redo log luu trU. 2.5.2. B o sao litu M ot bo sao luu (backup set) la m ot khki niem logic bao gom mot hoac nhieu mau sao luu. Neu ban sao luu m ot C S D L, tap tin dU lifu, khong gian bang, hoac log luu trU, bo day du cac mau sao luu lien quan hop lai vdi nhau thanh bo sao luu. K h i lenh backup dugc phat hanh, R M A N tao bo sao luu giti k et xuat. M o t bo sao luu la m ot tap tin hoac bp cac tap tin vdi dinh dang duy nhat chi co R M A N mdi hieu. N h u vay, chi co R M A N mdi co the sti dung cac bo sao luu de phuc hoi C SD L. 2.5.3. A n h sao chep An h sao chep (Im a ge copy) tuang tu nhu ban thuc hien lenh copy trong DOS. Ban co the tao cac anh sao chep cua cac tap tin dU lieu, tap tin dieu khien va cac tap tin redo log luu trU. Cac anh sao chep cua R M A N chi co the luu vao dia, chung khong the luu vao bang tU T h a t sU khong co sU khac nhau giUa cac anh sao chep cua R M A N va cac sao chep thong thudng dugc thuc hien bkng lenh copy, ngoai trU cac anh sao chep dugc thuc hien th on g qua cong cu R M A N vk vi the thong tin lien quan den chung dugc ghi vao tap tin dieu khien hoac recovery catalog, neu no dang dugc dung. Thuc te, ban co the su dung ckc tap tin dU lieu duac sao chep bkng tay tron g qua trin h phuc hoi neu trudc h et ban dung lenh catalog de dkng ky tap tin vdi R M A N . Sau do ban co the’ dung lenh restore va switch de dung cac sao chep tap tin dU lieu dugc thuc hien bdi ngudi dung.
  15. C h tfcfn g 13: Sao ltfu ca sd dil li§u 137 [M 2.5.4. P ro x y sao chep R M A N cung c6 the thuc hien m ot loai sao luu dac biet dugc goi la proxy copy, cr do trin h quan ly phuang ti$n luu trU dugc phep kiem soat quk trinh sao chep. 2.5.5. K en h M ot phien lam viec R M A N phai suf dung mot so loai ket noi tori server de thuc hien cong viec sao luu va phuc hoi, va cac kenh (channel) the hien nhting k et noi nay. Cac kenh chi ra th iet bi cu the, dia hoac bang tti se dugc dung cho hoat dong sao luu/ phuc hoi. Ban co the co cac kenh dugc cau hinh trudc (hai gion g nhu kenh mac dinh) hoac chi ra kenh bang tay tron g qua trinh R M A N thuc thi. Sau day la mot so vi du ve cap phat kenh. 2.5.5.1. Tii d
  16. M 138 P h a n I V : N a p , sao luu vft khoi phuc dQ li$u ■ Cdc lenh sao luu. ■ Cac lenh tac vu. • Cdc lenh sao chep. ■ Cdc lenh bao cao. ■ Cdc lenh lie t ke. ■ Cdc lenh k iem tra hup 1§. 2.6.1. C d c lenh sao litu Lenh sao luu quan tron g n hat la lenh backup. Ban co the chi ra kenh bdng tay d thcfi gian sao luu hodc de cho R M A N cap phdt kenh mdc dinh. Ban co the dung lenh backup de sao luu C S D L theo nhieu cdch khdc. Ban co the chon sao luu toan bo C S D L, m ot khong gian bang, hodc chi mot tap tin dU lieu. Ban cung co the dung lenh backup de sao luu cdc redo log luu trU. Sau day Id m ot so v i du: RMAN> backup database; RMAN> backup tablespace users; RMAN> backup datafile ‘e:\oracle\oradata\gen92\users01.dbf; 2.6.2. Sao litu ta ng T a t ca cac lenh sao luu tren la sao luu todn phan. Ban cung co the thuc hien sao luu tdng dung R M A N , va tron g thuc te, day la mot trong nhufng thuan lai ldn cua viec suf dung R M A N . Sao luu tdng se chi sao luu nhufng phan C S D L dd thay doi tU lan dau tien (mUc 0) hoac lan sao luu tdng gan nhat. Sao lUu mUc 0 tuung ting vdi sao luu toan phdn va no sao chep tat ca cac khoi dti lieu. Tuy nhien neu ban muon dung sao luu tdng ban phai thuc hien sao luu toan phan trudc h et nhu la co so phuc vu cho cdc sao luu tdng. T a t ca sao luu tdn g se chi sao luu nhting khoi dti lieu da thay doi. Sau day la cu phdp cho sao luu tdng. L en h dau tien thuc hien sao luu mtic 0, va lenh thti hai thuc hien sao luu tdn g mtic 1. RMAN> backup incremental level 0 database; RMAN> backup incremental level 1 database; Neu ban dang chay C S D L a che do archivelog, ban co the thi/c hien sao luu khi C S D L dong hoac md. Neu ban dang chay C S D L a che do n oarchivelog ban chi co the thuc hien sao luu dong.
  17. C h ift fn g 13: Sao lifu ccf sd dtf li§u 139 B 2.6.3. C d c l$nh tdc vu Ban khong the dung ckc lenh allocate channel vk switch nhu lenh dpc lap. Ban phai dung chung vdi lenh run nhu sau: RMAN> run 2> ( 3> allocate channel c1 device type sbt4> PARMS='ENV={NSR_GROUP=default)'; 4> backup datafile 1; 5> ) Lenh sw itch tucfng tu vdi lenh alter database rename datafile vk cho ph£p ban thay the tap tin dur lieu vdi tap tin sao chep duoc thuc hien bdi R M A N . 2.6.4. L$ nh copy L fn h copy tron g R M A N don thuan thuc hien sao chep tap tin duf li$u. Nhufng anh sao chep nay gion g vdi ckc sao chep duoc thuc hien bkng l$nh h f dieu hknh. Sau day 1a m inh hoa sur dung lenh copy: RMAI\I> copy datafile 1 to 'e:\oracle\admin\df1.copy'; Starting copy at 24-JU L-04 using channel 0RA_D ISK_1 channel 0RA _D ISK_1: copied datafile 1 output filename=E:\0RACLE\ADMIN\DF1 .COPY recid=1 stamp=532374856 Finished copy at 24-JUL-04 2.6.5. C d c len h b a o cao R M A N cung cap ckc lenh bao cao htfu dung cho phep ban kiem tra tien trin h sao ltfu va phuc hoi cua ban. Ban co the truy van de xem nhtfng tap tin nao can sao ltfu va nhtfng tap tin nao qua cu co the dugc loai bo. Lenh report schem a cho ban biet nhtfng khong gian bang nao va tap tin dtf lieu nao 1a thanh phan cua C S D L dich, nhu ban thay sau day: R A > re o schem M N p rt a;
  18. E S P 140 P h a n I V : N a p , sao ltfu va khoi phuc dJ ligu Report of database schema File K-bytes Tablespace RB segs Datafile Name 1 409600 SYST E M *** E:\ORACLE\ORADATA\GEN92\SYSTEM 01.DBF 2 204800 UND0TBS1 *** E:\ORACLE\ORADATA\GEN92\UNDOTBS01.DBF 3 20480 CW M LITE *** E:\ORACLE\ORADATA\GEN92\CW M LITE01.DBF 4 20480 D RSYS E:\ORACLE\ORADATA\GEN92\DRSYS01.DBF 5 152960 EXAM PLE *** E:\ORACLE\C1RADATA\GEN92\EXAMPLE01.DBF RMAN> Lenh report obsolete hien thi ta t ca nhtfng sao ltfu qua cu dua vao chinh sach luu gitf ban chon: RMAN> report obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of obsolete backups and copies Type Key Comp. Time F. name/Handle Backup Set 1 24-JUL-04 Backup Piece 1 24-JUL-04 E:\ORACLE\ORA92\DATABASE\01FRM L6A 1 1 Backup Set 2 24-JUL-04 Backup Piece 2 24-JUL-04 E:\0RACLE\0RA92\DATABASE\Q2FRM M JN 1 1 Backup Set 3 24-JUL-04 RMAN> 2.6.6. C d c le n h l i e t ke Lenh list backup cho ban xem tat ca cac sao luu da hoan tat duoc R M A N dang ky. Sau day la ket xuat cua lenh list backup: R A > list b ck p MN a u;
  19. C h t fd n g 13: Sao luu ca sa dur li§u i4 i m List of Backup Sets BS Key Type LV Size Device Type Elapsed Time Completion Time 1 Full 530M D ISK 00:01:33 24-JUL-04 BP Key: 1 Status: A V AILABLE Tag: TAG20040724T164353 Piece Name: E:\ORACLE\ORA92\DATABASE\01FFtML6A_1_1 SP FILE Included: Modification time: 02-N0v-03 List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name 1 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\SYSTEM 01.DBF 2 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\UNDOTBS01.DBF 3 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\CWMLITE01.DBF 4 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\DRSYS01.DBF 5 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\EXAM PLE01.DBF 6 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\INDX01.DBF 7 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEI\i92\ODMOI.DBF 8 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN 92\TOOLSOI.DBF 9 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\USERS01.DBF 10 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\GEN92\XDB01.DBF 11 Full 2931011 24-JUL-04 E:\ORACLE\ORADATA\TESTMJNDOTBSO 2 .DBF RMAN> Lenh lis t copy tuang tu nhu lenh list backup. Ban se nhan dugc mot. danh sach day du ta t ca cac sao chep duoc thuc hien bcri R M A N . RMAN> list copy: List of Datafile Copies
  20. g f 142 P h a n I V : N a p , sao luu va khoi phuc dJ li^u Key File S Completion Time Ckp SCN Ckp Time Name 1 1 A 24-JUL-04 2941700 24-JUL-04 E:\0RACLE\ADM IN\DF1.C0PY List of Archived Log Copies Key Thrd Seq S Low Time Name 27 1 38 A 14-MAY-04 E:\ORACLE\ORA92\RDBMS\ARC00038.001 28 1 39 A 16-MAY-04 E:\ORACLE\ORA92\RDBMS\ARC00039.001 29 1 40 A 16-MAY-04 E:\ORACLE\ORA92\RDBMS\ARC00040.001 30 1 41 A 16-MAY-04 E:\ORACLE\ORA92\RDBMS\ARC00041.001 31 1 42 A 16-MAY-04 E:\ORACLE\ORA92\RDBMS\ARC00042.001 RMAN> C ac l$nh kiem tra hgfp 1£ Ban co the dung lenh valid ate backupset de k iem tra su hgp le cua bo sao luu trugc khi ban co the dung chung de phuc hoi: RMAN> validate backupset 1; using channel 0RA_DISK_1 channel 0RA_D ISK_1: starting validation of datafile backupset RM AN-00571: =========================================== RMAN-00569: ====== ERRO R M ESSA G E STA CK FOLLOWS ====== RM AN-00571: =========================================== RMAN-03009: failure of validate command on 0RA_D ISK_1 channel at 07/24/2004 18:2 2:33 ORA-19505: failed to identify file "E:\ORACLE\ORA92\DATABASE\01FRM L6A_1_V ORA-27041: unable to open file OSD-04002: unable to open file
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
10=>1