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   ,如需转载请自行联系原作者
相关文章
|
2月前
|
存储 关系型数据库 MySQL
mysql数据库备份与恢复
MySQL数据库的备份与恢复是确保数据安全性和业务连续性的关键操作。
77 4
|
25天前
|
关系型数据库 MySQL 数据库连接
python脚本:连接数据库,检查直播流是否可用
【10月更文挑战第13天】本脚本使用 `mysql-connector-python` 连接MySQL数据库,检查 `live_streams` 表中每个直播流URL的可用性。通过 `requests` 库发送HTTP请求,输出每个URL的检查结果。需安装 `mysql-connector-python` 和 `requests` 库,并配置数据库连接参数。
122 68
|
12天前
|
关系型数据库 MySQL Linux
Linux环境下MySQL数据库自动定时备份实践
数据库备份是确保数据安全的重要措施。在Linux环境下,实现MySQL数据库的自动定时备份可以通过多种方式完成。本文将介绍如何使用`cron`定时任务和`mysqldump`工具来实现MySQL数据库的每日自动备份。
31 3
|
12天前
|
监控 关系型数据库 MySQL
Linux环境下MySQL数据库自动定时备份策略
在Linux环境下,MySQL数据库的自动定时备份是确保数据安全和可靠性的重要措施。通过设置定时任务,我们可以每天自动执行数据库备份,从而减少人为错误和提高数据恢复的效率。本文将详细介绍如何在Linux下实现MySQL数据库的自动定时备份。
26 3
|
26天前
|
存储 定位技术 数据库
介绍一下数据库的备份和恢复策略
【10月更文挑战第21】介绍一下数据库的备份和恢复策略
|
1月前
|
SQL 关系型数据库 MySQL
|
12天前
|
数据库
【赵渝强老师】数据库的备份方式
备份数据库是指将数据库中的数据及相关信息保存起来,以便在系统故障时恢复。备份对象不仅限于数据本身,还包括数据库对象、用户权限等。根据备份策略、类型和模式的不同,可分为整体/部分备份、完全/增量备份、一致/非一致备份。文中还附有相关视频讲解。
|
1月前
|
存储 关系型数据库 MySQL
PACS系统 中 dicom 文件在mysql 8.0 数据库中的 存储和读取(pydicom 库使用)
PACS系统 中 dicom 文件在mysql 8.0 数据库中的 存储和读取(pydicom 库使用)
32 2
|
11天前
|
SQL 关系型数据库 MySQL
12 PHP配置数据库MySQL
路老师分享了PHP操作MySQL数据库的方法,包括安装并连接MySQL服务器、选择数据库、执行SQL语句(如插入、更新、删除和查询),以及将结果集返回到数组。通过具体示例代码,详细介绍了每一步的操作流程,帮助读者快速入门PHP与MySQL的交互。
26 1
|
13天前
|
SQL 关系型数据库 MySQL
go语言数据库中mysql驱动安装
【11月更文挑战第2天】
29 4
下一篇
无影云桌面