安装步骤
2.1 安装TSM服务器
创建/usr/Tivoli/tsm 文件系统,大小1G左右
放入安装介质,smit installp
安装如下组件
tivoli.tsm.server.aix5.rte64
tivoli.tsm.server.com
tivoli.tsm.server.webcon
tivoli.tsm.server.aix5.rte64
tivoli.tsm.server.com
2.2 安装TSM备份归档客户机
放入AIX client 安装介质,smit installp
安装如下组件
tivoli.tsm.client.api.64bit
tivoli.tsm.client.api.jfs2
tivoli.tsm.client.ba.jfs2.base
tivoli.tsm.client.ba.jfs2.common
tivoli.tsm.client.ba.jfs2.image
tivoli.tsm.client.ba.jfs2.nas
tivoli.tsm.client.ba.jfs2.web
2.3 安装ORACLE TDP
放入tivoli data protection for oracle 安装介质,smit installp
安装如下组件
tivoli.tsm.client.oracle.aix51.64bit
tivoli.tsm.client.oracle.tools.aix51.64bit
2.4 安装SAN Agent
放入SAN Agent 安装介质,smit installp
安装如下组件
tivoli.tsm.StorageAgent.rte
tivoli.tsm.devices.aix5.rte
三、配置步骤
3.1 配置TSM 服务端
1 修改环境变量
在TSM Server的.profile文件增加如下内容:
export DSMSERV_DIR=/usr/tivoli/tsm/server/bin
export DSMSERV_CONFIG=/usr/tivoli/tsm/server/bin/dmserv.opt
2注册license , register lic file=* number=20
审核license audit lic
3定义库以及库路径
define library lib3582 libtype=SCSI SERial=AUTODetect AUTOLabel=no SHARED=yes RESETDrives=Yes
define path tsm lib3582 srctype=server desttype=library device=/dev/smc0 online=yes
4定义驱动器以及驱动器路径
define drive lib3582 drv0 online=yes element=256
define drive lib3582 drv1 online=yes element=257
define path tsm drv0 srctype=server desttype=drive library=lib3582 device=/dev/rmt0 online=yes
define path tsm drv1 srctype=server desttype=drive library=lib3582 device=/dev/rmt1 online=yes
5定义设备类
define devclass lto2dev library=lib3582 devtype=lto
6 检入库卷
label libvolume lib3582 search=yes checkin=scratch LABELSource=Barcode
OVERWRITE=yes VOLRange=zy9580,zy9599
7 定义TSM DB卷,并扩展
define dbvolume /usr/tivoli/tsm/server/db1.dsm f=500
extend db 500
8 定义 TSM LOG卷,并扩展
define logvolume /usr/tivoli/tsm/server/log1.dsm f=256
extend log 500
9 定义存储池
define stgpool P5_FS_POOL lto2dev maxscratch=0
define volume P5_FS_POOL zy9582
define volume P5_FS_POOL zy9583
define stgpool P5_ORA_POOL lto2dev maxscratch=0
define volume P5_ORA_POOL zy9595
define volume P5_ORA_POOL zy9596
define volume P5_ORA_POOL zy9597
define volume P5_ORA_POOL zy9598
define volume P5_ORA_POOL zy9599
10 定义策略域
define domain P5_FS_DOMAIN
define policyset P5_FS_DOMAIN P5_FS_SET
define mgmtclass P5_FS_DOMAIN P5_FS_SET P5_FS_CLASS
define copygroup P5_FS_DOMAIN P5_FS_SET P5_FS_CLASS standard type=backu destination=P5_FS_POOL
assign defmgmtclass P5_FS_DOMAIN P5_FS_SET P5_FS_CLASS
activate policyset P5_FS_DOMAIN P5_FS_SET
define domain P5_ORA_DOMAIN
define policyset P5_ORA_DOMAIN P5_ORA_SET
define mgmtclass P5_ORA_DOMAIN P5_ORA_SET P5_ORA_CLASS
define copygroup P5_ORA_DOMAIN P5_ORA_SET P5_ORA_CLASS standard type=backu destination=P5_ORA_POOL VERExists=1 VERDeleted=0 RETExtra=0 RETOnly=0
assign defmgmtclass P5_ORA_DOMAIN P5_ORA_SET P5_ORA_CLASS
activate policyset P5_ORA_DOMAIN P5_ORA_SET
11 注册客户机
register node P570_FS p570_fs domain=P5_FS_DOMAIN backdelete=yes archdelete=yes passe=0
register node P550_FS p550_fs domain= P5_FS_DOMAIN backdelete=yes archdelete=yes passe=0
register node P570_TDPO p570_tdpo domain=P5_ORA_DOMAIN backdelete=yes archdelete=yes passe=0
register node P550_TDPO p550_tdpo domain= P5_ORA_DOMAIN backdelete=yes archdelete=yes passe=0
12 定义管理调度
DEFine SCHedule bkupdb Type=Administrative CMD=’backup db type=full devclass=lto2dev volumenames=zy9580 scratch=no’ ACTIVE=yes STARTTime=12:00:00
DEFine SCHedule delvolhist Type=Administrative CMD=’DELete VOLHistory TODate=today-1 type=dbbackup’ ACTIVE=Yes STARTTime=11:50:00
13 启动TSM 服务器
到/usr/tivoli/tsm/server/bin
nohup dsmserv&
3.2 配置TSM 客户端
1 修改环境标量
在TSM Client的.profile文件增加如下内容:
export DSM_DIR=/opt/tivoli/tsm/client/ba/bin
export DSM_CONFIG=/opt/tivoli/tsm/client/ba/bin/dsm.opt
export DSM_LOG=/opt/tivoli/tsm/client/ba/bin
export DSMI_CONFIG=/opt/tivoli/tsm/client/api/bin64/dsm.opt
export DSMI_DIR=/opt/tivoli/tsm/client/api/bin64
export DSMI_LOG=/opt/tivoli/tsm/client/api/bin64
2修改/usr/tivoli/tsm/client/ba/bin 目录下的dsm.opt 以及dsm.sys 文件如下
dsm.opt
dsm.sys
3 用命令dsmc 启动命令行客户机,连接TSM 服务器看是否成功
3.3 配置ORACLE TDP
1修改tdpo.opt 如下:
2 修改/usr/tivoli/tsm/client/api/bin64 目录下的dsm.opt 以及dsm.sys 文件如下:
dsm.opt
dsm.sys
3 生成密码文件
tdpoconf password –tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt
4. 链接libobk.a
ln –s /usr/lib/libobk.a $ORACLE_HOME/lib64/libobk.a
链接完后重新启动数据库
5 sbttest 测试是否TDP和ORACLE 链接成功
$ORACLE_HOME/bin/sbttest test
6 安装Catalog 数据库
6.1为恢复目录单独创建表空间catalog_tbs,
6.2创建恢复目录用户
CREATE USER rman IDENTIFIED BY rman DEFAULT TABLESPACE catalog_tbs;
6.3 为用户rcat_user 赋予角色
GRANT connect,resource,recovery_catalog_owner TO rman;
6.4 使用RMAN 连接恢复目录
RMAN catalog=rman/rman@rman9i
6.5 在RMAN 提示符下创建catalog
create catalog tablespace catalog_tbs;
6.5 使用RMAN 同时连接目标数据和恢复目录
set ORACLE_SID=nc31
RMAN target / catalog=rman/rman@rman9i
6.6使用恢复目录注册数据库
RMAN>Register database;
7.如果sbttest 不成功 需要执行这一步
7.1添加errorlogname /oracle/mytdpo.log 到DSMI_DIR下的 dsm.sys文件
7.2重新运行tdpo password 命令生成密码
7.3进入/oracle 目录确认生成了mytdpo.log 文件
7.4更改mytdpo.log 的权限,
chmod 666 /oracle/mytdpo.log
chown oracle:dba /oracle/mytdpo.log
3.4 配置SAN Agent
1 修改/usr/tivoli/tsm/StorageAgent/bin/dsmsta.opt 增加一行
DEVCONFIG devconfig.out
2 使用如下命令
dsmsta setstorageserver myname=storagent mypassword=storagent myhladdress=172.16.1.12 servername=tsm serverpassword=tsm hladdress=172.16.1.21 lladdress=1500
这条命令在devconfig.txt 文件产生如下行:
这条命令在dsmsta.opt 产生如下行:
SERVERNAME TSM
3 在TSM server 上发出如下命令
set servername TSM
set serverpassword tsm
set serverhladdress 172.16.1.21
set serverlladdress 1500
set crossdefine on
设置完可以用q status 查看结果
4 在TSM server 上为san agent 定义服务器
define server storagnt serverpassword=storagnt hladdress=172.16.1.12 lladdress=1500 validateprotocol=all
6 在TSMserver 上定义源服务器为storagnt 的驱动器路径
define path storagnt drv0 srctype=server desttype=drive library=lib3582 device=/dev/rmt0
define path storagnt drv1 srctype=server desttype=drive library=lib3582 device=/dev/rmt1
7 为启用lan-free 修改客户机的dsm.sys 文件增加
LANFREECOMMMETHOD TCPIP
LANFREECOMMMETHOD SHAREDMEM
LANFREETCPPORT 1500
LANFREESHMPORT 1510
enablelanfree yes
8 启动san agent
nohup dsmsta&
四、TSM 策略域,存储池配置列表
4.1 策略域概要配置
Policy Domain Name | Policy Set | Management Class | Default (Y/N) | Backup Copy Group | Archive Copy Group | Storage Pool |
P5_FS_DOMAIN | standard | standard | Y | standard | standard | P5_FS_POOL |
P5_ORA_DOMAIN | standard | standard | Y | standard | standard | P5_ORA_POOL |
4.2 策略域详细配置
策略域: P5_FS_DOMAIN | ||
备份副本组 | ||
Type | BACKUP | 副本组的类型是备份. |
DESTINATION | P5_FS_POOL | 目标存储池是(请参考存储池定义表). |
FREQUENCY | 0 | 可以立即备份刚刚备份过的文件 |
VEREXISTS | 2 | 在客户机文件系统上存在的文件最多保留的2个备份版本 |
VERDELETED | 1 | 在客户机文件系统上不存在的文件最多保留的1个备份版本 |
RETEXTRA | 30 | 当备份版本到期后30天删除. |
RETONLY | 60 | 从客户机上删除的文件保留最新的版本60天 |
MODE | Absolute | 不管上次备份的文件是否改变都进行备份 |
SERIALIZATION | Static | 备份没有正在被修改文件并仅尝试一次 |
策略域: P5_ORA_DOMAIN | ||
备份副本组 | ||
Type | BACKUP | 副本组的类型是备份. |
DESTINATION | P5_ORA_POOL | 目标存储池是(请参考存储池定义表). |
FREQUENCY | 0 | 可以立即备份刚刚备份过的文件 |
VEREXISTS | 1 | 在客户机文件系统上存在的文件最多保留的2个备份版本 |
VERDELETED | 0 | 在客户机文件系统上不存在的文件最多保留的1个备份版本 |
RETEXTRA | 0 | 当备份版本到期后立即删除. |
RETONLY | 0 | 从客户机上删除的文件保留最新的版本60天 |
MODE | Absolute | 不管上次备份的文件是否改变都进行备份 |
SERIALIZATION | Static | 备份没有正在被修改文件并仅尝试一次 |
4.3节点配置
Node name |
password |
Policy domain |
note |
P550_FS | p550_fs | P5_FS_DOMAIN | 550文件系统备份 |
P550_TDPO | p550_tdpo | P5_ORA_DOMAIN | 550 Oracle备份 |
P570_FS | p570_fs | P5_FS_DOMAIN | 570文件系统备份 |
P570_TDPO | p570_tdpo | P5_ORA_DOMAIN | 570 Oracle备份 |
4.4存储池配置
POOL name |
VOLUME |
P5_FS_POOL | ZY9582,ZY9583 |
P5_ORA_POOL | ZY9595,ZY9596,ZY9597,ZY9598,ZY9599 |
五、Oracle 备份策略,调度和备份脚本
5.1 备份策略和调度
每周日凌晨1点增量0 备份,周4 凌晨1点增量1备份,周一,二,三,五,六凌晨1点做增量2备份 。每天每隔4个小时做一次归档日志的备份。
每天凌晨5点删除15天以前的归档,每天凌晨6点删除15天前的DB备份。
查看oracle 用户的调度 crontab –l
0 1 * * 0 /oracle/rmanscript/incr0.sh &
0 1 * * 4 /oracle/rmanscript/incr1.sh &
0 1 * * 1,2,3,5,6 /oracle/rmanscript/incr2.sh &
0 5 * * * /oracle/rmanscript/dele_arch.sh &
0 6 * * * /oracle/rmanscript/dele_tape.sh &
0 4,8,12,16,20 * * * /oracle/rmanscript/arch.sh &
5.2 备份脚本
5.2.1 incr0.sh 增量0备份
. /oracle/.profile
target=’target /’
rcvcat=’catalog rman/rman@rman9i’
# Get the current time for constructing a fairly unique filename in /tmp:
time=`date ‘+%m%d%H’`
# Construct filenames using $time for uniqueness:
cmdfile=/oracle/rmanscript/log/incr0_$time.rcv
msglog=/oracle/rmanscript/log/incr0_$time.log
cat <<EOF >$cmdfile
run{
allocate channel sbt1 type ‘SBT_TAPE’;
resync catalog;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1);
backup
format ‘cf_%s_%p’
(current controlfile);
backup
incremental level 0
filesperset 10
tag ‘incr_level_0’
format ‘incr0_%u_%p_%c’
database;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1)
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
5.2.2 incr1.sh 增量1备份
. /oracle/.profile
target=’target /’
rcvcat=’catalog rman/rman@rman9i’
# Get the current time for constructing a fairly unique filename in /tmp:
time=`date ‘+%m%d%H’`
# Construct filenames using $time for uniqueness:
cmdfile=/oracle/rmanscript/log/incr1_$time.rcv
msglog=/oracle/rmanscript/log/incr1_$time.log
cat <<EOF >$cmdfile
run{
allocate channel sbt1 type ‘SBT_TAPE’;
resync catalog;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1);
backup
format ‘cf_%s_%p’
(current controlfile);
backup
incremental level 1
filesperset 10
tag ‘incr_level_1’
format ‘incr1_%u_%p_%c’
database;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1);
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
5.2.3 incr2.sh 增量2备份
. /oracle/.profile
target=’target /’
rcvcat=’catalog rman/rman@rman9i’
# Get the current time for constructing a fairly unique filename in /tmp:
time=`date ‘+%m%d%H’`
# Construct filenames using $time for uniqueness:
cmdfile=/oracle/rmanscript/log/incr2_$time.rcv
msglog=/oracle/rmanscript/log/incr2_$time.log
cat <<EOF >$cmdfile
run{
allocate channel sbt1 type ‘SBT_TAPE’;
resync catalog;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1);
backup
format ‘cf_%s_%p’
(current controlfile);
backup
incremental level 2
filesperset 10
tag ‘incr_level_2’
format ‘incr2_%u_%p_%c’
database;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1)
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
5.2.4 arch.sh 归档日志备份
. /oracle/.profile
target=’target /’
rcvcat=’rcvcat rman/rman@rman9i’
# Get the current time for constructing a fairly unique filename in /tmp:
time=`date ‘+%m%d%H’`
# Construct filenames using $time for uniqueness:
cmdfile=/oracle/rmanscript/log/arch_$time.rcv
msglog=/oracle/rmanscript/log/arch_$time.log
cat <<EOF >$cmdfile
run{
allocate channel sbt1 type ‘SBT_TAPE’ ;
resync catalog;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘arch_%s_%p’
(archivelog like ‘/oradata/archivelog/%’ delete input channel sbt1);
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
5.2.5 del_arch.sh定期删除归档日志备份
# Initialize default connect string variables:
. /oracle/.profile
target=’target /’
rcvcat=’rcvcat rman/rman@rman9i’
time=`date ‘+%m%d%H’`
# Initialize filenames:
obsolete_tape=/oracle/rmanscript/log/arch_tape_$time.log # list of obsolete tape backups
cmdfile=/oracle/rmanscript/log/delete_arch$time.cmd # the generated RMAN commmand script
delete_log=/oracle/rmanscript/log/deleted_arch_$time.log # execution log from generated script
# Get a list of obsolete tape files:
rman msgno $target $catalog msglog $obsolete_tape << EOF > /dev/null
list backup of archivelog until time ‘sysdate-15’;
exit;
EOF
# sed actions:
del_bpiece=”-e /AVAILABLE/ s/\(.* \)\(.*\)$/change backuppiece ‘\2’ delete;/”
#echo “allocate channel for delete type ‘sbt_tape’ ;” > $cmdfile
grep AVAILABLE $obsolete_tape | sed “$del_bpiece” >> $cmdfile
echo “release channel;” >> $cmdfile
#
# Execute the RMAN command file to delete the obsolete files:
#
rman msgno $target $rcvcat msglog $delete_log cmdfile $cmdfile
exit
5.2.6 del_tape.sh 定期删除数据库备份
# Initialize default connect string variables:
. /oracle/.profile
target=’target /’
rcvcat=’catalog rman/rman@rman9i’
time=`date ‘+%m%d%H’`
# Initialize filenames:
obsolete_tape=/oracle/rmanscript/log/ob_tape_$time.log # list of obsolete tape backups
cmdfile=/oracle/rmanscript/log/delete$time.cmd # the generated RMAN commmand script
delete_log=/oracle/rmanscript/log/deleted_$time.log # execution log from generated script
# Get a list of obsolete tape files:
rman msgno $target $catalog msglog $obsolete_tape << EOF > /dev/null
report obsolete redundancy=1 until time ‘sysdate-15’ device type ‘sbt_tape’;
#report obsolete device type ‘sbt_tape’;
exit;
EOF
# sed actions:
del_bpiece=”-e /RMAN-06285/ s/\(.* \)\(.*\)$/change backuppiece ‘\2’ delete;/”
echo “allocate channel for delete type ‘sbt_tape’ ;” > $cmdfile
grep RMAN-06285 $obsolete_tape | sed “$del_bpiece” >> $cmdfile
echo “release channel;” >> $cmdfile
#
# Execute the RMAN command file to delete the obsolete files:
#
rman msgno $target $rcvcat msglog $delete_log cmdfile $cmdfile
exit
六 FAQ
1. 如何启动和停止TSM 服务器
方法一:
启动:进入/usr/tivoli/tsm/server/bin 目录
输入命令 dsmserv
停止:在dsmserv 的提示符TSM:TSM>下
输入halt
方法二:
启动:进入/usr/tivoli/tsm/server/bin目录
输入命令 nohup dsmserv&
停止:ps –ef | grep dsm 查看dsmserv 的进程号
kill 进程号
tail –f nohup.out 查看日志
当机器重新启动时,TSM 服务器依靠
/etc/inittab 中的
自动启动
2 如何启动管理命令行接口
直接在系统提示符下输入
dsmadmc
提示输入user id : 这里为admin
提示输入password 这里为 admin
然后进入TSM 管理命令行
若要更改admin的password
输入:update admin admin newpassword
3如何启动WEB管理接口
打开IE ,输入http://172.16.1.21:8041/ibm/console
用户名:iscadmin
口令 :password
如果打开页面无效
进入/opt/IBM/ISC/PortalServer/bin 输入startISC.sh ISC_Portal
4 如何进行文件系统的备份
直接在系统提示符下输入命令如:
备份/usr 目录及下面的子目录dsmc sel /usr/ -subdir=yes
单独备份/etc/host 文件 dsmc sel /etc/host
5 如何查看备份
oracle连接rman
rman target / catalog rman/rman@rman9i
5.1概述可用的备份
RMAN>list backup summary;
B 表示 backup
F 表示 FULL
A 表示 archive log
0 1 表示 incremental backup
5.2按备份类型列出备份
RMAN>list backup by file;
按照 数据文件备份,归档日志备份,控制文件备份,服务器参数文件备份 列出
5.3列出详细备份
RMAN>list backup;
5.4列出表空间和数据文件备份
list backup of tablespace 和list backup of datafile 输出和list backup 相似 如:list backup of tablespace user_tbs;
list backup of datafile 3;
5.5列出归档日志备份
RMAN>list archivelog all; 简要信息
RMAN>list backup of archivelog all; 详细信息
5.6列出控制文件和服务器参数文件
RMAN>list backup of controfile;
RMAN>list backup of spfile;
6如何进行数据库故障恢复
如果安装配置了OEM 可以使用恢复向导进行恢复
步骤
1 startup mount
2 restore database
3 recover database
4 alter database open resetlogs
7 如何查看RMAN备份日志验证是否备份成功。
rman 的备份日志放在/oracle/rmanscript/log 目录下,
根据时间以及备份级别命名
incr0_110915.log 表示11月9号15时做的增量0 备份
查看日志
如果日志结尾为
Recovery Manager complete.
表示该级别的备份成功
如果日志包含如下:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
表示有错误 需要更正。
七 恢复
当数据库出现故障 需要进行恢复,运行脚本restore.sh
su – oracle
cd /rmanscript
./restore.sh
还原结束后,查看还原日志,看是否成功
日志位于/oracle/rmanscript/log 目录下
日志示例:
Recovery Manager: Release 9.2.0.6.0 – 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database (not started)
connected to recovery catalog database
RMAN> startup nomount;
2> run
3> {
4> allocate channel sbt1 type ‘sbt_tape’;
5> restore controlfile;
6> alter database mount;
7> restore database;
8> recover database;
9> alter database open resetlogs;
10> release channel sbt1;
11> }
12>
Oracle instance started
Total System Global Area 320308816 bytes
Fixed Size 742992 bytes
Variable Size 285212672 bytes
Database Buffers 33554432 bytes
Redo Buffers 798720 bytes
allocated channel: sbt1
channel sbt1: sid=13 devtype=SBT_TAPE
channel sbt1: Tivoli Data Protection for Oracle: version 5.2.0.0
Starting restore at 10-NOV-05
channel sbt1: starting datafile backupset restore
channel sbt1: restoring controlfile
output filename=/oradata/oratest/control01.ctl
channel sbt1: restored backup piece 1
piece handle=oratestfull_03h3dd2p_1_1 tag=ORATEST_FULL params=NULL
channel sbt1: restore complete
replicating controlfile
input filename=/oradata/oratest/control01.ctl
output filename=/oradata/oratest/control02.ctl
output filename=/oradata/oratest/control03.ctl
Finished restore at 10-NOV-05
database mounted
Starting restore at 10-NOV-05
channel sbt1: starting datafile backupset restore
channel sbt1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/oratest/system01.dbf
restoring datafile 00003 to /oradata/oratest/cwmlite01.dbf
restoring datafile 00004 to /oradata/oratest/drsys01.dbf
restoring datafile 00008 to /oradata/oratest/tools01.dbf
restoring datafile 00011 to /oradata/oratest/NNC_DATA01.dbf
restoring datafile 00013 to /oradata/oratest/NNC_DATA03.dbf
restoring datafile 00015 to /oradata/oratest/NNC_INDEX02.dbf
channel sbt1: restored backup piece 1
piece handle=oratestfull_03h3dd2p_1_1 tag=ORATEST_FULL params=NULL
channel sbt1: restore complete
channel sbt1: starting datafile backupset restore
channel sbt1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /oradata/oratest/undotbs01.dbf
restoring datafile 00005 to /oradata/oratest/example01.dbf
restoring datafile 00006 to /oradata/oratest/indx01.dbf
restoring datafile 00007 to /oradata/oratest/odm01.dbf
restoring datafile 00009 to /oradata/oratest/users01.dbf
restoring datafile 00010 to /oradata/oratest/xdb01.dbf
restoring datafile 00012 to /oradata/oratest/NNC_DATA02.dbf
restoring datafile 00014 to /oradata/oratest/NNC_INDEX01.dbf
restoring datafile 00016 to /oradata/oratest/NNC_INDEX03.dbf
channel sbt1: restored backup piece 1
piece handle=oratestfull_04h3dd3s_1_1 tag=ORATEST_FULL params=NULL
channel sbt1: restore complete
Finished restore at 10-NOV-05
Starting recover at 10-NOV-05
starting media recovery
archive log thread 1 sequence 4 is already on disk as file /oradata/oratest/redo03.log
archive log thread 1 sequence 5 is already on disk as file /oradata/oratest/redo01.log
archive log filename=/oradata/oratest/redo03.log thread=1 sequence=4
archive log filename=/oradata/oratest/redo01.log thread=1 sequence=5
media recovery complete
Finished recover at 10-NOV-05
database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
released channel: sbt1
Recovery Manager complete.
附录:还原测试
创建新库test ,导入数据从NC31
1. 还原之前先对数据库做一次备份
. /oracle/.profile
target=’target sys/sys@test’
rcvcat=’catalog rman/rman@rman9i’
# Get the current time for constructing a fairly unique filename in /tmp:
time=`date ‘+%m%d%H’`
# Construct filenames using $time for uniqueness:
cmdfile=/oracle/rmanscript/log/test_$time.rcv
msglog=/oracle/rmanscript/log/test_$time.log
cat <<EOF >$cmdfile
run{
allocate channel sbt1 type ‘SBT_TAPE’;
resync catalog;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘testarch_%s_%p’
(archivelog like ‘/oradata/testarchivelog/%’ delete input channel sbt1);
backup
format ‘testcf_%s_%p’
(current controlfile);
backup
full
filesperset 10
tag ‘test_full’
format ‘testfull_%u_%p_%c’
database;
sql ‘alter system archive log current’ ;
backup
filesperset 10
format ‘testarch_%s_%p’
(archivelog like ‘/oradata/testarchivelog/%’ delete input channel sbt1);
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
2.备份之前先验证数据
sqlplus sys/sys@test as sysdba
SQL> select count(*) from test.OM_JOB;
COUNT(*)
———-
1759
3.模拟数据库故障
shutdown immediate; 关闭数据库
重命名所有数据文件和控制文件
4.运行还原脚本
#before restore ,you must shutdown db
target=’target sys/sys@test’
rcvcat=’catalog rman/rman@rman9i’
time=`date ‘+%m%d%H’`
cmdfile=/oracle/rmanscript/log/restore_$time.rcv
msglog=/oracle/rmanscript/log/restore_$time.log
cat <<EOF >$cmdfile
startup nomount;
run
{
allocate channel sbt1 type ‘sbt_tape’;
restore controlfile;
alter database mount;
restore database;
recover database;
alter database open resetlogs;
release channel sbt1;
}
EOF
rman $target $rcvcat cmdfile $cmdfile msglog $msglog
exit
5. 还原结束验证数据
sqlplus sys/sys@test as sysdba
SQL> select count(*) from test.OM_JOB;
COUNT(*)
———-
1759
Leave a Reply