1、oradb1创建应用
create tablespace test_data datafile '/home/oracle/oradata/oradb1/test_data01.dbf' size 500m autoextend off;
create user magy identified by magy default tablespace test_data temporary tablespace temp;
grant connect,resource to rcuser;
grant unlimited tablespace to rcuser;
conn magy/magy
create table t1(a number,b number);
begin
for i in 1..20000 loop
insert into t1 values(i,i);
end loop;
commit;
end;
/
select count(1) from t1;
COUNT(1)
----------
20000
conn / as sysdba
alter system switch logfile;
exit;
2、oradb2创建catalog表空间和用户
create tablespace rc_tbs datafile '/home/oracle/oradata/oradb2/ts_rc_data01.dbf' size 300m autoextend off;
create user rcuser identified by rcuser default tablespace rc_tbs temporary tablespace temp;
grant connect,resource to rcuser;
grant unlimited tablespace to rcuser;
--select GRANTED_ROLE from DBA_ROLE_PRIVS;
grant RECOVERY_CATALOG_OWNER to rcuser;
3、创建数据库连接
编辑oradb1的listener.ora文件,增加如下信息:
---------begin---------
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=139.0.0.12)(PORT=1521))
))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1)
(SID_NAME=oradb1)))
---------end---------
启动LISTENER:lsnrctl start LISTENER
编辑oradb2的tnsnames.ora文件,增加如下信息:
---------begin---------
oradb1_12=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=139.0.0.12)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=oradb1)
))
---------end---------
检测连接状态:tnsping oradb1_12
4、oradb2创建catalog
export ORACLE_SID=oradb2
rman catalog rcuser/rcuser
create catalog;
connect target /
register database;
exit;
rman catalog rcuser/rcuser sys/oracle@oradb1_12
register database;
5、oradb1配置归档
mkdir -p /home/oracle/backup/arch
mkdir -p /home/oracle/backup/rman
export ORACLE_SID=oradb1
sqlplus / as sysdba
alter system set log_archive_dest_1='location=/home/oracle/backup/arch' scope=spfile;
shutdown immediate
startup mount
alter database archivelog;
archive log list;
alter database open;
6、oradb2 catalog全库备份oradb1
rman catalog rcuser/rcuser
connect target sys/oracle@oradb1_12
show all;
CONFIGURE CONTROLFILE AUTOBACKUP on;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/backup/rman/%F';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/backup/rman/snapcf_oradb1.f';
backup database format '/home/oracle/backup/rman/%U';
exit;
7、oradb1损坏数据文件test_data01.dbf
cd /home/oracle/oradata/oradb1/
mv test_data01.dbf test_data01.dbfbak
sqlplus / as sysdba
alter system checkpoint;
conn magy/magy
select count(1) from t1;
select count(1) from t1
*
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time
ORA-01110: data file 4: '/home/oracle/oradata/oradb1/test_data01.dbf'
8、oradb2 catalog恢复数据文件
rman catalog rcuser/rcuser
connect target sys/oracle@oradb1_12
restore datafile 4;
recover datafile 4;
9、oradb1将datafile 4 online并检查恢复是否正确
sqlplus / as sysdba
alter database datafile 4 online;
conn magy/magy
select count(1) from t1;
COUNT(1)
----------
20000
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23382569/viewspace-753452/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23382569/viewspace-753452/