揭祕ORACLE備份之--熱備份(也叫聯機備份)
熱備份(又叫聯機備份),資料庫必須處於歸檔模式。
[root@dg ~(19:47:15)]# su - oracle
e[oracle@dg ~(19:47:22)]$ export ORACLE_SID=wailon
[oracle@dg ~(19:47:28)]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat Sep 28 19:47:35 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-- 系統是否處於歸檔模式
19:47:35 SYS@wailon> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence 224
Next log sequence to archive 226
Current log sequence 226
19:48:12 SYS@wailon> select ts#,name from v$tablespace;
TS# NAME
---------- ----------------------------------------
4 USERS
2 UNDOTBS1
1 SYSAUX
0 SYSTEM
6 TBS_LRJ
7 TEMP01
6 rows selected.
19:50:37 SYS@wailon> select name,checkpoint_change# from v$database;
NAME CHECKPOINT_CHANGE#
---------------------------------------- ------------------
WAILON 2886703
19:50:59 SYS@wailon> select file#,checkpoint_change# from v$datafile;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 2886703
2 2886703
3 2886703
4 2886703
5 2886703
19:51:17 SYS@wailon> select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
TS# FILE# NAME CHECKPOINT_CHANGE# STATUS FUZ
---------- ---------- ---------------------------------------- ------------------ ------- ---
0 1 /u01/app/oracle/oradata/system01.dbf 2886703 ONLINE YES
1 2 /u01/app/oracle/oradata/sysaux01.dbf 2886703 ONLINE YES
2 3 /u01/app/oracle/oradata/undotbs01.dbf 2886703 ONLINE YES
4 4 /u01/app/oracle/oradata/users01.dbf 2886703 ONLINE YES
6 5 /u01/app/oracle/oradata/lrj.dbf 2886703 ONLINE YES
19:51:50 SYS@wailon> -- 手工備份時凍結檔案的SCN
19:51:50 SYS@wailon> -- 生成備份指令碼
19:52:07 SYS@wailon> select 'alter tablespace '||tablespace_name||' begin backup;'||chr(10)||
19:54:30 2 '!cp -v '||file_name||' /home/oracle/dbbackup'||chr(10)||
19:55:10 3 'alter system checkpoint;'||chr(10)||
19:55:58 4 'select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;'||chr(10)||
19:56:21 5 'select file#,status,change#,time from v$backup;'||chr(10)||
19:56:39 6 'alter tablespace '||tablespace_name||' end backup;'
19:57:07 7 from dba_data_files;
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'||CHR(10)||'!CP-V'||FILE_NAME||'/HOME/ORACLE/DBBACKUP'||CHR(10)||'ALTE
------------------------------------------------------------------------------------------------------------------------
alter tablespace TBS_LRJ begin backup;
!cp -v /u01/app/oracle/oradata/lrj.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
alter tablespace TBS_LRJ end backup;
alter tablespace SYSTEM begin backup;
!cp -v /u01/app/oracle/oradata/system01.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
alter tablespace SYSTEM end backup;
alter tablespace SYSAUX begin backup;
!cp -v /u01/app/oracle/oradata/sysaux01.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
alter tablespace SYSAUX end backup;
alter tablespace UNDOTBS1 begin backup;
!cp -v /u01/app/oracle/oradata/undotbs01.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace USERS begin backup;
!cp -v /u01/app/oracle/oradata/users01.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
alter tablespace USERS end backup;
-- 只備份USERS表空間
19:58:36 SYS@wailon> alter tablespace USERS begin backup;
!cp -v /u01/app/oracle/oradata/users01.dbf /home/oracle/dbbackup
alter system checkpoint;
select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
select file#,status,change#,time from v$backup;
Tablespace altered.
19:58:41 SYS@wailon> `/u01/app/oracle/oradata/users01.dbf' -> `/home/oracle/dbbackup/users01.dbf'
19:58:44 SYS@wailon> alter system checkpoint;
System altered.
-- 4號檔案即USERS表空間的SCN比其他表空間小
19:58:44 SYS@wailon>
TS# FILE# NAME CHECKPOINT_CHANGE# STATUS FUZ
---------- ---------- ---------------------------------------- ------------------ ------- ---
0 1 /u01/app/oracle/oradata/system01.dbf 2886703 ONLINE YES
1 2 /u01/app/oracle/oradata/sysaux01.dbf 2886703 ONLINE YES
2 3 /u01/app/oracle/oradata/undotbs01.dbf 2886703 ONLINE YES
4 4 /u01/app/oracle/oradata/users01.dbf 2887859 ONLINE YES
6 5 /u01/app/oracle/oradata/lrj.dbf 2886703 ONLINE YES
-- v$backup顯示正在備份的檔案
19:58:44 SYS@wailon> select file#,status,change#,time from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 ACTIVE 2887859 28-SEP-13
5 NOT ACTIVE 0
19:58:44 SYS@wailon> alter tablespace USERS end backup;
Tablespace altered.
19:58:49 SYS@wailon> select file#,status,change#,time from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 2887859 28-SEP-13
5 NOT ACTIVE 0
19:59:04 SYS@wailon> select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
TS# FILE# NAME CHECKPOINT_CHANGE# STATUS FUZ
---------- ---------- ---------------------------------------- ------------------ ------- ---
0 1 /u01/app/oracle/oradata/system01.dbf 2886703 ONLINE YES
1 2 /u01/app/oracle/oradata/sysaux01.dbf 2886703 ONLINE YES
2 3 /u01/app/oracle/oradata/undotbs01.dbf 2886703 ONLINE YES
4 4 /u01/app/oracle/oradata/users01.dbf 2887859 ONLINE YES
6 5 /u01/app/oracle/oradata/lrj.dbf 2886703 ONLINE YES
19:59:13 SYS@wailon> alter system checkpoint;
System altered.
19:59:40 SYS@wailon> select ts#,file#,name,checkpoint_change#,status,fuzzy from v$datafile_header;
TS# FILE# NAME CHECKPOINT_CHANGE# STATUS FUZ
---------- ---------- ---------------------------------------- ------------------ ------- ---
0 1 /u01/app/oracle/oradata/system01.dbf 2887895 ONLINE YES
1 2 /u01/app/oracle/oradata/sysaux01.dbf 2887895 ONLINE YES
2 3 /u01/app/oracle/oradata/undotbs01.dbf 2887895 ONLINE YES
4 4 /u01/app/oracle/oradata/users01.dbf 2887895 ONLINE YES
6 5 /u01/app/oracle/oradata/lrj.dbf 2887895 ONLINE YES
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/429786/viewspace-776440/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle聯機熱備份的原理(轉)Oracle
- oracle資料庫備份之exp增量備份Oracle資料庫
- Oracle OCP(62):熱備份Oracle
- mysql的冷備份與熱備份MySql
- 熱備份/冷備份/ 冷啟動/熱啟動
- ORACLE 備份表Oracle
- MySQL的冷備份和熱備份概念理解(轉)MySql
- Oracle 備份恢復之 FlashbackOracle
- oracle 如何不備份已經備份的歸檔Oracle
- ORACLE備份策略(轉)Oracle
- ORACLE備份指令碼Oracle指令碼
- Networker備份oracle racOracle
- RAC備份恢復之Voting備份與恢復
- 備份集和備份片之間的關係
- 揭秘ORACLE備份之----RMAN之五(CATALOG)Oracle
- ORACLE備份策略二(轉)Oracle
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- Oracle OCP(60):冷備份Oracle
- OPPO手機備份
- Oracle 備份恢復篇之RMAN catalogOracle
- oracle邏輯備份之--資料泵Oracle
- 初探MySQL資料備份及備份原理MySql
- Mysql備份與恢復(1)---物理備份MySql
- alias 備份
- 備份dockerDocker
- 備份命令
- Oracle 備份 與 恢復 概述Oracle
- Oracle磁帶備份模擬Oracle
- ORACLE備份&恢復案例(轉)Oracle
- Networker備份oracle單節點Oracle
- Mysql備份與恢復(2)---邏輯備份MySql
- ManagerDB 備份檔案管理與異地備份
- 群暉NAS備份建議及備份方式
- 天翼云云主機快照、雲硬碟備份、雲主機備份之間的區別硬碟
- GitLab的自動備份、清理備份與恢復Gitlab
- redis不重啟,切換RDB備份到AOF備份Redis
- 【RMAN】同時建立多個備份(建立多重備份)
- 雙機熱備與資料備份的關係說明一二