oracle数据库备份恢复篇-恢复目录数据库的创建和管理

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:582

[font=Tahoma,][size=26px]oracle数据库备份恢复篇-恢复目录数据库的创建和管理[font=Tahoma,][color=rgb(70, 70, 70)]恢复目录数据库主要特点
1.恢复目录可以做到集中管理,一台机器作为恢复目录数据库,管理多台机器上的数据库,每台机器就是一个target
2.只有使用恢复目录可以创建和使用脚本script
3.恢复目录数据库可以保证恢复需要的元数据(metadata)保留更长的时间。
4.缺省情况下,oracle会使用本地数据库(target db)的控制文件作为恢复目录使用,[color=rgb(70, 70, 70)]在本测试中,使用了两台机器,每台机器上有一个oracle 11g数据库,其中一台作为目标数据库,另外一个作为恢复目录数据库[color=rgb(70, 70, 70)]目标数据库(target db)
redhat5 oracle11.2.0.3 ip:192.168.1.15 主机名称:asm11g asm存储方法[color=rgb(70, 70, 70)]恢复目录数据库(catalog db)
redhat5 oracle11.2.0.1 ip:192.168.1.110 主机名称:oracle11g 文件系统存储[color=rgb(70, 70, 70)]
在作为恢复目录数据上(本例中数据库是文件系统),ip地址192.168.1.110
执行如下操作,创建表空间rman_tbs,创建用户tj,使用表空间rman_tbs,授予权限[color=rgb(70, 70, 70)]SQL> conn / as sysdba
Connected.
SQL> select tablespace_name,contents from dba_tablespaces;[color=rgb(70, 70, 70)]TABLESPACE_NAME CONTENTS
------------------------------ ---------
SYSTEM PERMANENT
SYSAUX PERMANENT
UNDOTBS1 UNDO
TEMP TEMPORARY
USERS PERMANENT
EXAMPLE PERMANENT[color=rgb(70, 70, 70)]6 rows selected.[color=rgb(70, 70, 70)]SQL> create tablespace rman_tbs
2 datafile '/u01/app/oracle/oradata/db01/rman_tbs01.dbf' size 200m;[color=rgb(70, 70, 70)]Tablespace created.[color=rgb(70, 70, 70)]SQL> @/home/oracle/workshop/tspace[color=rgb(70, 70, 70)]Tablespace Total Size Free Size Pct Free Pct Used FSFI
------------ ---------- ---------- ---------- ---------- ----------
SYSTEM 700 15.375 2 98 83.06
USERS 5 .8125 16 84 100
SYSAUX 540 31.1875 6 94 100
EXAMPLE 100 21.25 21 79 71.49
UNDOTBS1 100 91.875 92 8 52.06
RMAN_TBS 200 199 100 1 100[color=rgb(70, 70, 70)]6 rows selected.[color=rgb(70, 70, 70)]SQL> create user tj identified by tj
2 default tablespace rman_tbs
3 temporary tablespace temp
4 quota unlimited on rman_tbs;[color=rgb(70, 70, 70)]User created.[color=rgb(70, 70, 70)]SQL> grant connect ,resource to tj;[color=rgb(70, 70, 70)]Grant succeeded.[color=rgb(70, 70, 70)]SQL> grant recovery_catalog_owner to tj; [color=rgb(70, 70, 70)]Grant succeeded.[color=rgb(70, 70, 70)]
使用用户tj登陆,目前在这个用户下没有任何的对象存在。
SQL> conn tj/tj
Connected.
SQL> select * from tab;
no rows selected[color=rgb(70, 70, 70)]单独打开一个命令窗,连接到目标数据库所在机器(192.168.1.15),首先配置连接到恢复目录数据库的网络
配置结果如下,客户端连接字符串使用catalogdb[color=rgb(70, 70, 70)][oracle@asm11g ~]$ more /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.[color=rgb(70, 70, 70)]DB01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = asm11g)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db01)
)
)[color=rgb(70, 70, 70)]CATALOGDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db01)
)
)[color=rgb(70, 70, 70)][oracle@asm11g ~]$ rman catalog [color=#286446]mailto:tj/tj@catalogdb#tc_qz_original=460811474]tj/tj@catalogdb[color=rgb(70, 70, 70)]Recovery Manager: Release 11.2.0.3.0 - Production on Thu May 10 21:59:24 2012[color=rgb(70, 70, 70)]Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.[color=rgb(70, 70, 70)]connected to recovery catalog database[color=rgb(70, 70, 70)]RMAN> create catalog;
recovery catalog created[color=rgb(70, 70, 70)]回到恢复目录数据库,在SQLPLUS窗口下确认,oracle其实创建datalog就是在用户tj下,建一些表,当然表里是没有数据的[color=rgb(70, 70, 70)]SQL> select * from tab;[color=rgb(70, 70, 70)]TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
AL TABLE
BCB TABLE
BCF TABLE
BCR TABLE
BDF TABLE
BP TABLE
BRL TABLE
BS TABLE
........................
...中间部分节略..........
........................
TSATT TABLE
VPC_DATABASES TABLE
VPC_USERS TABLE
XAL TABLE
XCF TABLE
XDF TABLE[color=rgb(70, 70, 70)]77 rows selected.
[color=rgb(70, 70, 70)]SQL> select name from RC_DATAFILE;[color=rgb(70, 70, 70)]no rows selected
[color=rgb(70, 70, 70)]再次到目标数据库,注册数据库
RMAN> connect target /
connected to target database: DB01 (DBID=1413747133)[color=rgb(70, 70, 70)]RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
[color=rgb(70, 70, 70)]
在目标数据库执行register之后回到恢复目录数据库所在机器,再来观察,已经有数据同步过来了。[color=rgb(70, 70, 70)]SQL> select name from RC_DATAFILE;[color=rgb(70, 70, 70)]NAME
--------------------------------------------------------------------------------
+DG1/db01/datafile/system.256.782478969
+DG1/db01/datafile/sysaux.257.782478969
+DG1/db01/datafile/undotbs1.258.782478971
+DG1/db01/datafile/users.259.782478971
+DG1/db01/datafile/example.265.782479149[color=rgb(70, 70, 70)]
到这里 恢复目录数据库基本创建完毕,你可以在目标数据库上执行下面的操作。[color=rgb(70, 70, 70)]
比如管理脚本script,这个操作使用控制文件作为恢复目录是实现不了的,一定要使用恢复目录数据库
[oracle@asm11g ~]$ RMAN TARGET / CATALOG [color=#286446]mailto:tj/tj@catalogdb#tc_qz_original=460811474]tj/tj@catalogdb
-bash: RMAN: command not found
[oracle@asm11g ~]$ rman TARGET / CATALOG [color=#286446]mailto:tj/tj@catalogdb#tc_qz_original=460811474]tj/tj@catalogdb[color=rgb(70, 70, 70)]Recovery Manager: Release 11.2.0.3.0 - Production on Thu May 10 22:05:11 2012[color=rgb(70, 70, 70)]Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.[color=rgb(70, 70, 70)]connected to target database: DB01 (DBID=1413747133)
connected to recovery catalog database[color=rgb(70, 70, 70)]RMAN> exit[color=rgb(70, 70, 70)]
Recovery Manager complete.
[oracle@asm11g ~]$ rman target / catalog [color=#286446]mailto:tj/tj@catalogdb#tc_qz_original=460811474]tj/tj@catalogdb[color=rgb(70, 70, 70)]Recovery Manager: Release 11.2.0.3.0 - Production on Thu May 10 22:05:33 2012[color=rgb(70, 70, 70)]Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.[color=rgb(70, 70, 70)]connected to target database: DB01 (DBID=1413747133)
connected to recovery catalog database[color=rgb(70, 70, 70)]RMAN> create script backuptest
2> {
3> allocate channel c1 type disk;
4> backup tablespace users;
5> }[color=rgb(70, 70, 70)]created script backuptest[color=rgb(70, 70, 70)]RMAN> print script backuptest;[color=rgb(70, 70, 70)]printing stored script: backuptest
{
allocate channel c1 type disk;
backup tablespace users;
}[color=rgb(70, 70, 70)]RMAN> list script names;[color=rgb(70, 70, 70)]List of Stored Scripts in Recovery Catalog[color=rgb(70, 70, 70)]
Scripts of Target Database DB01[color=rgb(70, 70, 70)] Script Name
Description
-----------------------------------------------------------------------
backuptest[color=rgb(70, 70, 70)]RMAN> run{execute script backuptest;}[color=rgb(70, 70, 70)]executing script: backuptest[color=rgb(70, 70, 70)]starting full resync of recovery catalog
full resync complete
released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=68 device type=DISK[color=rgb(70, 70, 70)]Starting backup at 10-MAY-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=+DG1/db01/datafile/users.259.782478971
channel c1: starting piece 1 at 10-MAY-12
channel c1: finished piece 1 at 10-MAY-12
piece handle=+FRADATA/db01/backupset/2012_05_10/nnndf0_tag20120510t225336_0.270.782952819 tag=TAG20120510T225336 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
Finished backup at 10-MAY-12
released channel: c1

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】