OCP-1Z0-052-V8.02-79题

79. You are working on a database that must be functioning 24 hours a day, 7 days a week. The database

is configured in ARCHIVELOG mode. 

Which two options do you have for performing user-managed backups? (Choose two.)

A.You can perform consistent backups only.

B.You can perform a complete database backup without shutting down the database instance.

C.You can back up data files only when all data files have the same SCN recorded in the control file.

D.You can back up only those data files whose headers are frozen by using ALTER TABLESPACE BEGIN

BACKUP or ALTER DATABASE BEGIN BACKUP commands.

Answer: BD  

 

归档模式:可以进行一致性备份(冷备)和非一致性备份(热备)。
非归档模式:一致性备份(冷备)
 
一致性备份(冷备份):在数据库正常关闭情况下做备份,数据库处于一致性状态。
(可以用于归档和非归档),所有SCN号一致。缺点:数据库需要关闭。
非一致性备份(热备份):数据库在open状态下备份(用于归档模式),
使用alter database/tablespace xxx begin backup开始备份。
优点:数据库不需要关闭,用于7x24事务处理的数据库。
 
一般手工备份主要备份控制文件,数据文件,以及参数文件等。
首先查看控制文件,数据文件,以及参数文件的位置:
sys@TEST0910> select name from v$controlfile;
 
NAME
------------------------------------------------------------
/u01/app/oracle/oradata/test0910/control01.ctl
/u01/app/oracle/fast_recovery_area/test0910/control02.ctl
 
sys@TEST0910> select file#,name from v$datafile;
 
     FILE# NAME
---------- ------------------------------------------------------------
         1 /u01/app/oracle/oradata/test0910/system01.dbf
         2 /u01/app/oracle/oradata/test0910/sysaux01.dbf
         3 /u01/app/oracle/oradata/test0910/undotbs01.dbf
         4 /u01/app/oracle/oradata/test0910/users01.dbf
         5 /u01/app/oracle/oradata/test0910/example01.dbf
 
sys@TEST0910> col file_name for a50
sys@TEST0910> col tablespace_name for a10
sys@TEST0910> select file_id,file_name,tablespace_name,bytes/1024/1024 m from dba_data_files;
 
   FILE_ID FILE_NAME                                          TABLESPACE          M
---------- -------------------------------------------------- ---------- ----------
         4 /u01/app/oracle/oradata/test0910/users01.dbf       USERS               5
         3 /u01/app/oracle/oradata/test0910/undotbs01.dbf     UNDOTBS1          100
         2 /u01/app/oracle/oradata/test0910/sysaux01.dbf      SYSAUX            650
         1 /u01/app/oracle/oradata/test0910/system01.dbf      SYSTEM            720
         5 /u01/app/oracle/oradata/test0910/example01.dbf     EXAMPLE       345.625
 
 
sys@TEST0910> show parameter spfile;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/spfiletest0910.o
                                                 ra
 
热备份必须在归档模式下进行,不然会报错。
先来看看数据库是否为归档模式:
sys@TEST0910> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     24
Next log sequence to archive   26
Current log sequence           26
sys@TEST0910> select log_mode from v$database;
 
LOG_MODE
------------
ARCHIVELOG
 
手工热备份步骤:
开库备份只用于归档模式,而且热备之前先执行命令:
热备步骤:
alter database/tablespace  XXX begin backup 这句话会导致锁块头,scn号不会变化。
cp files
alter database/tablespace XXX end backup
 
实验备份users表空间,并测试删除文件并恢复:
1、首先开始备份users表空间
sys@TEST0910> alter tablespace users begin backup;
 
Tablespace altered.
 
2、操作系统命令拷贝文件:
[oracle@rtest ~]$ cd /u01/app/oracle
[oracle@rtest oracle]$ mkdir hot_dir
[oracle@rtest oracle]$ cp /u01/app/oracle/oradata/test0910/users01.dbf  /u01/app/oracle/hot_dir/users01.dbf
 
3、结束users表空间的备份:
sys@TEST0910> alter tablespace users end backup;
 
Tablespace altered.
 
4、此时删除users01.dbf文件
[oracle@rtest oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf
ls: /u01/app/oracle/oradata/test0910/users01.dbf: No such file or directory
 
5、关库,再启库,报错:
sys@TEST0910> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@TEST0910> startup
ORACLE instance started.
 
Total System Global Area 2505338880 bytes
Fixed Size                  2230952 bytes
Variable Size             587203928 bytes
Database Buffers         1895825408 bytes
Redo Buffers               20078592 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/test0910/users01.dbf'
 
6、通过操作系统拷贝到正确的位置,(也可以通过rman恢复,这里用拷贝方式)
[oracle@rtest oracle]$ cp /u01/app/oracle/hot_dir/users01.dbf /u01/app/oracle/oradata/test0910/users01.dbf
[oracle@rtest oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf
/u01/app/oracle/oradata/test0910/users01.dbf
 
7、再开库,报错,需要介质恢复:
sys@TEST0910> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/u01/app/oracle/oradata/test0910/users01.dbf'
 
8、介质恢复:
sys@TEST0910> recover datafile 4;
Media recovery complete.
 
9、再开库,成功:
sys@TEST0910> alter database open;
 
Database altered.
 
恢复成功

你可能感兴趣的:(OCP-1Z0-052-V8.02-79题)