catalog备份数据库及RMAN存储脚本

简介:

环境说明:


提前配置好两个库的监听与tnsnames.ora
IP:10.100.25.13 为目标数据库  
IP:10.100.25.14 为恢复目录数据库(catalog database)


以下操作全部都在恢复目录数据库下执行:


1.为恢复目录创建一个表空间,表空间名称是 catalogts。用户名是catalogdemo 密码是
oracle。给这个用户赋予恢复目录拥有者权限。


SQL> create tablespace catalogts datafile'/home/oracle/app/oradata/catalog01.dbf' size 50m autoextend on;


Tablespace created.


SQL> create user catalogdemo identified by oracle default tablespace catalogts quota unlimited on catalogts;


User created.


SQL> grant recovery_catalog_owner to catalogdemo;


Grant succeeded.




2.使用RMAN用catalogdemo用户连接到恢复目录数据库。在 catalogts 表空间中创建恢复目录。


[oracle@11g ~]$ rman catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:54:43 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to recovery catalog database


RMAN> create catalog tablespace catalogts;


recovery catalog created


3.使用RMAN,连接到目标数据库和恢复目录数据库。


[oracle@11g ~]$ rman target sys/oracle@10.100.25.13:1521/orcl catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:56:21 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: ORCL (DBID=1388303183)
connected to recovery catalog database


5.在恢复目录中注册目标数据库,执行resync catalog 命令来同步控制文件和恢复目录。


RMAN> register database;


database registered in recovery catalog
starting full resync of recovery catalog
full resync complete


RMAN> resync catalog;


starting full resync of recovery catalog
full resync complete




RMAN> list incarnation;




List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
2       21      ORCL     1388303183       PARENT  1          15-AUG-09
2       4       ORCL     1388303183       CURRENT 945184     09-OCT-14




RMAN> backup database;


Starting backup at 04-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/15ppb1kf_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/16ppb1pd_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-DEC-14


——————————————————————————————————————————————————
--  检查备份是否存在于目标数据库相应位置    (目标数据库执行)


[oracle@11g dbs]$ pwd
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@11g dbs]$ ll
total 1200476
-rw-r-----. 1 oracle oinstall 1209679872 Dec  4 15:17 15ppb1kf_1_1
-rw-r-----. 1 oracle oinstall    9830400 Dec  4 15:18 16ppb1pd_1_1




——————————————————————————————————————————————————










catalog RMAN存储脚本


脚本的分类
    local : 在rman连接的目标数据库下创建的脚本,此类脚本仅仅适用于当前目标数据库。即是针对特定的数据库创建的rman脚本
    global : 能够在恢复目录注册的任意目标数据库中执行
    如:create global script XXXX comment 'A script for full backup to be used with any database' {。。。。}


a:  创建rman本地存储脚本
RMAN> create script whole_backup { backup database; }


created script whole_backup


b:执行rman本地存储脚本
RMAN> run { execute  script whole_backup; }


executing script: whole_backup


Starting backup at 04-DEC-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/17ppb2rh_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:56
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/18ppb34q_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-DEC-14


c:  查看当前恢复目录内的脚本
list [global | all] script names
       
RMAN> list script names;


d:  更新脚本
    replace [global] script scrip_name {....}
    replace [global] script script_name from file '<dir>'  --从文件更新脚本


RMAN> replace  script whole_backup { allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }2> 3> 4> 5> 6> 7> 


replaced script whole_backup


e:  查看脚本内容
RMAN> print script whole_backup;


printing stored script: whole_backup
{ allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }


f: 删除脚本
delete [global] script script_name


OK,转载请标明出处。

文章可以转载,必须以链接形式标明出处。


本文转自 张冲andy 博客园博客,原文链接: http://www.cnblogs.com/andy6/p/6250430.html   ,如需转载请自行联系原作者
相关文章
|
26天前
|
存储 缓存 关系型数据库
鱼和熊掌如何兼得?一文解析RDS数据库存储架构升级
阿里云RDS率先推出新型存储类型通用云盘,提供低延迟、低成本、高持久性的用户体验。
鱼和熊掌如何兼得?一文解析RDS数据库存储架构升级
|
1月前
|
关系型数据库 MySQL 数据库
Python tk dos命令备份mysql数据库
Python tk dos命令备份mysql数据库
16 0
|
1月前
|
数据库 数据安全/隐私保护 Python
写一个定时备份数据库的脚本,且只保留最近3天
写一个定时备份数据库的脚本,且只保留最近3天
57 3
|
4天前
|
存储 NoSQL MongoDB
Python爬虫之非关系型数据库存储#5
MongoDB、Redis【2月更文挑战第18天】
35 1
|
3天前
|
关系型数据库 MySQL Linux
Linux环境下定时备份mysql数据库
Linux环境下定时备份mysql数据库
|
4天前
|
SQL 关系型数据库 MySQL
Python爬虫之关系型数据库存储#5
python MySQL 增删改查操作【2月更文挑战第17天】
21 1
|
4天前
|
数据库 对象存储 数据安全/隐私保护
在oceanbase数据库中,有没有遇到备份到oss环境,备份进度到98%就一直卡着的问题?
在oceanbase数据库中,有没有遇到备份到oss环境,备份进度到98%就一直卡着的问题?
13 6
|
11天前
|
SQL 存储 关系型数据库
备份数据库
备份数据库
16 9
|
25天前
|
SQL 存储 算法
【数据库SQL server】数据库系统概述与DBS结构
【数据库SQL server】数据库系统概述与DBS结构
54 0
【数据库SQL server】数据库系统概述与DBS结构
|
28天前
|
关系型数据库 MySQL Shell
linux shell脚本实现自动备份Mysql数据库脚本
linux shell脚本实现自动备份Mysql数据库脚本
129 3

热门文章

最新文章