中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle冷備份腳本

發布時間:2020-06-22 03:30:45 來源:網絡 閱讀:1130 作者:whshurk 欄目:關系型數據庫

一、原理

  1. 冷備份

    數據庫在關閉狀態下完成所有物理系統文件拷貝的過程,也稱脫機備份

    適合于非歸檔模式下,數據庫處于一致性狀態

  1. 步驟

    首先在運行的庫中得到數據庫運行的所有的物理文件位置,然后在計劃內關閉數據庫(shutdown)

    再執行拷貝物理文家到備份路徑或備份設備

    備份完成后立即啟動數據庫讓其提供正常的服務

  2. 總結 - 優點

    冷備模式下概念易于理解,即將需要備份的文件復制到安全的位置

    操作比較簡單,不需要太多的干預

    容易恢復到某個時間點上(只需將文件再拷貝回去)

    能與歸檔方法相結合,作數據庫“最新狀態”的恢復。

4.總結 - 缺點

備份時,數據庫必須處于一致性關閉狀態

只能提供到某一時間點的恢復

備份時速度比較慢,尤其是數據量大性能影響比較大

不能實現基于表和用戶級別的數據恢復
二、案例

     首先應該在相關視圖里查出數據庫的數據文件,日志文件,控制文件,臨時文件所在的位置。注意:不要直接把oradata下的cp就行了,因為生產庫里各個文件通常分布在不同的磁盤,不同的地方,所以在去視圖里獲得真實路徑 。

1).查看數據庫是否為CDB
SYS@newtest>select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database;

NAME Multitenant Option OPEN_MODE CON_ID


NEWTEST Multitenant Option enabled READ WRITE 0
YES表示該數據庫是CDB,如果是NO表示是NO-CDB(普通數據庫)
2).查看實例和數據庫的相關信息
SYS@newtest>select instance_name,version,status,archiver,database_status from v$instance;

INSTANCE_NAME VERSION STATUS ARCHIVE DATABASE_STATUS


newtest 12.2.0.1.0 OPEN STARTED ACTIVE
SYS@newtest>select dbid,name,log_mode from v$database;

  DBID NAME      LOG_MODE

1779551310 NEWTEST ARCHIVELOG
SYS@newtest>set linesize 180
SYS@newtest>col guid format A40
SYS@newtest>col name format A20
SYS@newtest>select con_id, dbid, guid, name , open_mode from v$pdbs;

CON_ID       DBID GUID                                     NAME                 OPEN_MODE

     2  603865257 32CAC9A05E614355926257BE671D9AFC         PDB$SEED             READ ONLY
     3 3394996704 24549D14BBEB417BAB312BF19BC5259E         PDBTEST              READ WRITE
     4   50957894 D4B2FCAAC2B944CC8AF5864EC7CB853C         CLONEPDB_PLUG        READ WRITE

3). 查看數據文件及狀態信息

SYS@newtest>col file_name format A60
SYS@newtest>select file_name,tablespace_name,status,online_status from dba_data_files;

FILE_NAME TABLESPACENAME STATUS ONLINE


C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSTEM01.DBF SYSTEM AVAILABLE SYSTEM
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSAUX01.DBF SYSAUX AVAILABLE ONLINE
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\UNDOTBS01.DBF UNDOTBS1 AVAILABLE ONLINE
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\USERS01.DBF USERS AVAILABLE ONLINE
SYS@newtest>col con_id format 99
SYS@newtest>col name format A80
SYS@newtest>select con_id,FILE#,NAME,status,enabled from v$datafile order by 1;

CON_ID FILE# NAME STATUS ENABLED


 1          1 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSTEM01.DBF                        SYSTEM  READ WRITE
 1          3 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSAUX01.DBF                        ONLINE  READ WRITE
 1          5 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\UNDOTBS01.DBF                       ONLINE  READ WRITE
 1          7 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\USERS01.DBF                         ONLINE  READ WRITE
 2          2 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\SYSTEM01.DBF                SYSTEM  READ WRITE
 2          4 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\SYSAUX01.DBF                ONLINE  READ WRITE
 2          6 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\UNDOTBS01.DBF               ONLINE  READ WRITE
 3          8 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\SYSTEM01.DBF                SYSTEM  READ WRITE
 3         11 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\USERS01.DBF                 ONLINE  READ WRITE
 3         10 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\UNDOTBS01.DBF               ONLINE  READ WRITE
 3          9 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\SYSAUX01.DBF                ONLINE  READ WRITE

CON_ID FILE# NAME STATUS ENABLED


 4         42 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\UNDOTBS01.DBF         ONLINE  READ WRITE
 4         41 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\SYSAUX01.DBF          ONLINE  READ WRITE
 4         40 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\SYSTEM01.DBF          SYSTEM  READ WRITE
 4         43 C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\USERS01.DBF           ONLINE  READ WRITE

15 rows selected.
4).查看臨時文件
SYS@newtest>col name format A100
SYS@newtest>select name from v$tempfile;

NAME

C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\TEMP01.DBF
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\TEMP012017-12-13_17-23-31-944-PM.DBF
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\TEMP012017-12-13_17-23-31-944-PM.DBF
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\TEMP012017-12-13_17-23-31-944-PM.DBF

5).查看日志文件
SYS@newtest>col member format A60
SYS@newtest>select member from v$logfile;

MEMBER

C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO03.LOG
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO02.LOG
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO01.LOG
6).查看控制文件
SYS@newtest>select name from v$controlfile;

NAME

C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CONTROL01.CTL
C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CONTROL02.CTL
7).創建備份目錄
SYS@newtest>ho mkdir c:\oracleback
SYS@newtest>select 'ho mkdir '|| ' &dir\' ||NAME from v$pdbs;
Enter value for dir: C:\oracleback
old 1: select 'ho mkdir '|| ' &dir\' ||NAME from v$pdbs
new 1: select 'ho mkdir '|| ' C:\oracleback\' ||NAME from v$pdbs

'HOMKDIR'||'C:\ORACLEBACK\'||NAME

ho mkdir C:\oracleback\PDB$SEED
ho mkdir C:\oracleback\PDBTEST
ho mkdir C:\oracleback\CLONEPDB_PLUG
8).使用連接符生成復制文件命令
SYS@newtest>select 'ho copy ' || name || ' &dir' from v$controlfile
2 union all
3 select 'ho copy ' || member || ' &dir' from v$logfile
4 union all
5 select 'ho copy ' || file_name|| ' &dir' from dba_data_files
6 union all
7 select 'ho copy ' || vd.name || ' &dir\'|| vp.name as command from v$datafile vd join v$pdbs vp using(con_id)
8 union all
9 select 'ho copy ' || vt.name || ' &dir\'|| vp.name as command from v$tempfile vt join v$pdbs vp using(con_id)
10 /
Enter value for dir: C:\oracleback
old 1: select 'ho copy ' || name || ' &dir' from v$controlfile
new 1: select 'ho copy ' || name || ' C:\oracleback' from v$controlfile
Enter value for dir: C:\oracleback
old 3: select 'ho copy ' || member || ' &dir' from v$logfile
new 3: select 'ho copy ' || member || ' C:\oracleback' from v$logfile
Enter value for dir: C:\oracleback
old 5: select 'ho copy ' || file_name|| ' &dir' from dba_data_files
new 5: select 'ho copy ' || file_name|| ' C:\oracleback' from dba_data_files
Enter value for dir: C:\oracleback
old 7: select 'ho copy ' || vd.name || ' &dir\'|| vp.name as command from v$datafile vd join v$pdbs vp using(con_id)
new 7: select 'ho copy ' || vd.name || ' C:\oracleback\'|| vp.name as command from v$datafile vd join v$pdbs vp using(con_id)
Enter value for dir: C:\oracleback
old 9: select 'ho copy ' || vt.name || ' &dir\'|| vp.name as command from v$tempfile vt join v$pdbs vp using(con_id)
new 9: select 'ho copy ' || vt.name || ' C:\oracleback\'|| vp.name as command from v$tempfile vt join v$pdbs vp using(con_id)

'HOCOPY'||NAME||'C:\ORACLEBACK'

ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CONTROL01.CTL C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CONTROL02.CTL C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO03.LOG C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO02.LOG C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\REDO01.LOG C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSTEM01.DBF C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\SYSAUX01.DBF C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\UNDOTBS01.DBF C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\USERS01.DBF C:\oracleback
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\SYSTEM01.DBF C:\oracleback\PDB$SEED
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\SYSAUX01.DBF C:\oracleback\PDB$SEED

'HOCOPY'||NAME||'C:\ORACLEBACK'

ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\UNDOTBS01.DBF C:\oracleback\PDB$SEED
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\SYSTEM01.DBF C:\oracleback\PDBTEST
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\SYSAUX01.DBF C:\oracleback\PDBTEST
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\UNDOTBS01.DBF C:\oracleback\PDBTEST
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\USERS01.DBF C:\oracleback\PDBTEST
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\SYSTEM01.DBF C:\oracleback\CLONEPDB_PLUG
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\SYSAUX01.DBF C:\oracleback\CLONEPDB_PLUG
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\UNDOTBS01.DBF C:\oracleback\CLONEPDB_PLUG
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\USERS01.DBF C:\oracleback\CLONEPDB_PLUG
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBSEED\TEMP012017-12-13_17-23-31-944-PM.DBF C:\oracleback\PDB$SEED
ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\PDBTEST\TEMP012017-12-13_17-23-31-944-PM.DBF C:\oracleback\PDBTEST

'HOCOPY'||NAME||'C:\ORACLEBACK'

ho copy C:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\NEWTEST\CLONEPDB_PLUG\TEMP012017-12-13_17-23-31-944-PM.DBF C:\oracleback\CLONEPDB_PLUG

23 rows selected.
9).編寫相關腳本

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

敖汉旗| 岳阳县| 维西| 文水县| 临漳县| 蒙自县| 城口县| 禹城市| 嵩明县| 教育| 黑龙江省| 垦利县| 大关县| 称多县| 天镇县| 绩溪县| 沂水县| 仙游县| 古蔺县| 盐津县| 临夏市| 蒲江县| 蒙山县| 三明市| 尚义县| 从江县| 仁化县| 扎兰屯市| 湾仔区| 凉山| 镇平县| 五台县| 延安市| 长垣县| 墨脱县| 枣阳市| 高阳县| 潜江市| 红河县| 唐山市| 通化市|