close

現場(環境):CentOS 6.9   套件:Oracle RMAN

 

 


原因:

 

 

在測試機環境(硬體空間很小)使用 RMAN 很容意造成硬體空間不足。

 

 

所以必需寫好相對應的SHELL去進行清處理。

 

 

但在SHELL寫好前,硬體空間就先不足了

 


處理方式:

 

 

RMAN是記錄所有 list 交易過程的地方,

 

 

也就是所有SQL語法執行在這台資料庫的過程記錄。

 

跟一般寫Shell備份資料庫檔案內容是不一樣的東西。

 

他可以想成是一個服務在運作中,將所有對於這個服務的操作內容都記錄下來。

 

 

而記錄下來的檔案會被分成多個大小相同的TEMP(這也可以定義)

 

可以定義POOL(空間)有多大。

 

 

但是如果POOL用滿了,就會強制讓資料庫運作停下來,即使你的硬體空間還有。

 

 

他是不會自己彈性擴充的。

 

 

預設是8G。但很容易滿而造成服務掛掉,所以能夠自己手動修成符合自己修求的大小。

 

這麼危險的狀況,當然Oracle也能夠設定通知,當然前提是在你有設定的狀況之下。 DB警告訊息回告知(如果有設定)RMAN使用多少 %

 

這麼危險為什麼要用RMAN

 

 

重點在於它的災難復原,今天的架構是你有兩台主機,同時連接到一個共用的Storage

 

 

A主機是主要伺服器,運作時會將資料存到共用Storage當中。

 

 

B主機只是BYPASS而已。

 

 

而今天災難發生,A主機出狀況了。

 

 

B主機要即刻接手,但就算他能看到共用Storage內的資料,

 

 

也不會知道之前A主機到底運作了那些過程。

 

 

所以這時候RMAN就出現了,

 

 

他能把它紀錄內所有的操作指令還原到B主機上,讓B主機可以知道現在運行到哪裡了,而且能正常地接手下去。

 

 

所以 rman 是 伺服器運作的 備份/restore重要的一環。


 

 

操作:

 

 

# su - oracle

 

 

$ df -Th

 

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/vg_lv_root

ext4 45G 36G 7.2G 84% /

tmpfs tmpfs 1.9G 958M 959M 50% /dev/shm

/dev/sda1 ext4 477M 62M 390M 14% /boot

/dev/sdb1 ext4 50G 36G 12G 76% /u01

 

 

$ rman

.bash_history Documents/ .ICEauthority .pulse-cookie

.bash_logout Downloads/ .local/ .ssh/

.bash_profile .esd_auth .mozilla/ Templates/

.bashrc .gconf/ Music/ Videos/

.cache/ .gconfd/ .nautilus/ .viminfo

.config/ .gnome2/ Pictures/ .vnc/

.dbus/ .gtk-bookmarks Public/ .xsession-errors

Desktop/ .gvfs/ .pulse/

 

 

 

$ rman target /

rman target / 進入rman管理工具

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jul 3 00:08:48 2017

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

 

connected to target database: XXXXX (DBID=3794543512)

 

RMAN> delete archivelog all;

 

 

刪除所有TEMP的檔案資料。表示所有的操作紀錄都會直接刪掉不備份了。

 

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=498 device type=DISK

List of Archived Log Copies for database with db_unique_name XXXXX

=====================================================================

 

Key Thrd Seq S Low Time

 

 

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

4055 1 4062 A 22-JUN-17

Name: /u01/app/oracle/fast_recovery_area/XXXXX/archivelog/2017_06_23/o1_ mf_1_4062_dnqthnwc_.arc

 

4056 1 4064 A 22-JUN-17

 

選完delete後,他會跳出列表要你確認是否要刪除。

 

Do you really want to delete the above objects (enter YES or NO)? YES

 

打了YES後,就開始清除,在清理完成後,按exit離開。

 

RMAN> exit

 

清完,再用df –Th檢查一下狀況。


 

備註

 

 

打錯或者不完整的指令,直接按下enter時,會跑出提示訊息。

 

 

以協助你完成指令操作。 記得TAB是沒有用的。

 

$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jul 3 00:10:56 2017

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

 

connected to target database: XXXXX (DBID=3794541212)

 

RMAN> help

 

RMAN-00571: ===========================================================

 

 

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

 

 

RMAN-00571: ===========================================================

 

 

RMAN-00558: error encountered while parsing input commands

 

 

RMAN-01008: the bad identifier was: help

 

 

RMAN-01007: at line 1 column 1 file: standard input

 

RMAN> delete

2> ;

 

RMAN-00571: ===========================================================

 

 

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

 

 

RMAN-00571: ===========================================================

 

 

RMAN-00558: error encountered while parsing input commands

 

 

RMAN-01007: at line 2 column 1 file: standard input

 

(本篇完)

arrow
arrow
    全站熱搜

    IT001 發表在 痞客邦 留言(0) 人氣()