NBU 异机恢复ORACLE基本步骤
NBU异机恢复Oracle操作步骤
NBU异机恢复Oracle操作步骤NBU 异机恢复Oracle操作步骤Hehuyi_In 于 2020-05-15 22:36:22 发布 1507 收藏 5分类专栏: Oracle 备份还原版权Oracle同时被 2 个专栏收录206 篇⽂章4 订阅订阅专栏备份还原31 篇⽂章0 订阅订阅专栏⼀、准备⼯作1. DBA恢复服务器安装与原库相同版本的数据库软件、NBU客户端双向开通到NBU备份服务器的1556、13724、13720、13782、13790端⼝的防⽕墙策略(应该只要1556和13724,但为避免还原时出现其他异常,建议都开)/etc/hosts⽂件添加NBU备份服务器主机名及原库主机名,ping 主机名测试能否解析成功确保恢复服务器磁盘空间⾜够2. NBU管理员/etc/hosts⽂件添加待恢复服务器主机名,ping 主机名测试能否解析成功,若不成功可使⽤bpclntcmd -clear_host_cache清除nbu端dns缓存配置恢复授权,确保备份机器和还原机器都在列表中,且允许还原Host Properties->Mater server->Client Attributes若是异机恢复,需在NBU给备份机器和恢复机器增加异机恢复的权限cd /usr/openv/netbackup/db/altnamestouch 主机名检查异机恢复参数NBUInstallPath/NetBackup/bin/admincmd/bpgetconfig | grep "DISALLOW_CLIENT"#输出DISALLOW_CLIENT_LIST_RESTORE = NODISALLOW_CLIENT_RESTORE = NO#若如上两个参数为YES,则表⽰禁⽌进⾏异机恢复,需要将两个参数改成NO,为保证参数⽣效,建议修改后重启主服务器上的NBU服务NBUInstallPath/NetBackup/bin/bp.kill_allNBUInstallPath/NetBackup/bin/bp.start_all⼆、数据恢复以下均在待恢复服务器操作1. 检查备份⽂件情况/usr/openv/netbackup/bin/bplist -C iZwz94g9fehswlnzd19jv2Z -t 4 -b -l -R /# -C后跟备份库主机名;-t后跟还原类型,4是oracle标志;-b指列出备份⽂件的⽇期和时间;-l指列出备份⽂件的详细信息;-R以递归的⽅式显⽰⼦⽬录。
NBUOracle时间点恢复测试步骤
NBUOracle时间点恢复测试步骤NBU ORACLE恢复测试步骤1、测试环境(1)服务器IBM AIX6.1(2)应用为用友财务系统、久其财务报表系统(3)环境情况:用友系统:CWNCLP1 IP:172.16.173.50CWNCLP2 IP:172.16.173.51数据库系统:Oracle rac软件:nbu 客户端和oracle代理久其系统:BBYWLP1 IP:172.16.173.10BBYWLP2 IP: 172.16.173.11数据库系统:Oracle rac软件:nbu 客户端和oracle代理备份服务器:Backupserver软件:nbu服务器端2、测试需求:用NBU软件备份和Oracle的archivelog方式来恢复数据到一个时间点的数据。
3、测试步骤:测试用友数据(1)在NUB备份服务器上用备份用友数据的策略来对用友数据做全备份。
(2)在备份任务完成后,用友工程师对数据进行更改(如向系统添加数据等)并记录下更改数据的时间。
(如2010-4-24 03:10:15)(3)更改数据完成后,停一段时间后再次对数据进行数据添加并记录下时间(如2010-4-24 03:15:40)(4)在数据更改完成后,停一段时间后。
开始数据恢复。
(5)数据恢复步骤:a)用SSH客户端工具分别登陆到CWNCLP1 CWNCLP2b)在CWNCLP1 CWNCLP2上用Oracle用户登陆,命令为su –oracle.c)登陆成功后,用conn / as sysdba;命令来连接数据库。
在CWNCLP1 CWNCLP2都要进行连接。
d)连接完成后,用shutdown immediate;命令分别在CWNCLP1 CWNCLP2上执行。
e)命令执行完成后,由于是Oracle rac ,所以需要查看一下备份时用的是那一台机器。
查看得到是在CWNCLP2做了数据库备份。
所以在CWNCLP2上执行startupmount;命令。
NBU入门_异机恢复oracle_nocatalog
NetBackup将Oracle数据库恢复到其它服务器(rman nocatalog)一、假设不使用rman catalog。
假设要将数据库恢复到new_host的不同文件系统/data上。
以oracle8i语法为例,Oracle9无svrmgrl,需用sqlplus “/ as sysdba”。
1. 在new_host上创建dba组和与old_host相同的Oracle用户。
将/data的可写权限给Oracle用户。
确定new_host上有足够的硬盘空间存放新的datafile及archive log file。
2. 修改.profile文件中相关的Oracle环境变量,ORACLE_SID保持与old_host中一致。
3. 安装与old_host相同版本的Oracle数据库软件,不创建数据库。
4. 将old_host中$ORACLE_HOME/dbs下的initSID.ora文件拷至new_host的$ORACLE_HOME/dbs下。
如果initSID.ora中有ifile=’xxx.ora’,则将xxx.ora也进行拷贝。
Oracle9也可能用spinitSID.ora。
5. 创建initSID.ora(及xxx.ora)中所用到的目录。
通常所需建立的目录为background_dump_dest、core_dump_dest、user_dump_dest、log_archive_dest。
常6. 在new_host上安装和配置NetBackup client和Oracle Agent。
注意在NetBackup Server的/usr/openv/netbackup/db/altnames目录下touch No.Restrictions (允许异机恢复)。
7. 从原机copy或从磁带异机恢复standard方式备份的最新的control file到new_host的/data目录下。
8. 修改initSID.ora(及xxx.ora),如果是OPS,将OPS相关的参数去掉:(1) control_files = (“/data/controlfile_name”)(2) log_archive_dest=”/data/arch”(3) sort_area_size=20000000# 如果sort_area_size不够大,恢复archive_log时可能出现ora-12209. svrmgrl> startup mount10. svrmgrl> select file# from v$datafile,记录file#11. svrmgrl> select * from v$logfile,记录log文件的目录。
NBU异机恢复windows oracle11g
2) 查看归档日志是否开启
archive log list
这里显示归档日志未开启。
3) 开启归档日志
关闭数据库:shutdown immediate;
启动数据库为 mount 状态:startup mount;
开启归档模式:alter database archivelog;
打开数据库查询:alter database open; archive log list;
2) 登录 RMAN rman target / nocatalog;
3) 关闭数据库 shutdown immediate;
4) 启动数据库为 nomount 状态 startup nom需要和源端 wxf-wos 的 dbid 一样:1763780182) set dbid=1763780182;
NBU 异机恢复 oracle
1. 相关信息表 一、网络信息
名称 NBU Master Server Oracle 源客户端 Oracle 目标客户端 主机名 wxf-wns wxf-wos wxf-wog IP 172.16.202.204 172.16.202.205 172.16.202.206 操作系统 Windows server 2008 R2 standard Windows server 2008 R2 standard Windows server 2008 R2 standard
二、 查看源端(wxf-wos)一些相关信息
查看 SID:select name from v$database;
查看 dbid:select dbid from v$database;
三、 查看目标端(wxf-wog)一些相关信息
1) 查看 oracle 的 SID
oracle异机恢复
Media上有完好的数据库oracle 9i,oracle_home=E:\oracle\ora92oracle_sid=ldl要求:Master完全备份media中的oracle数据库(控制文件,归档日志,数据库文件),然后在把oracle数据库恢复到restore主机上。
第一步,在裸机上安装oracle 9i下一步下一步只安装软件,不安装实例。
下一步下一步安装结束,退出。
第二步,允许异机恢复在master上面创建C:\Program Files\Veritas\NetBackup\db\altnames\No.restrictions 第三步,在restore上E:\oracle\ora92\database下创建pfile文件initldl.ora。
############################################ Sort, Hash Joins, Bitmap Indexes###########################################pga_aggregate_target=25165824sort_area_size=524288############################################ Database Identification###########################################db_domain=""db_name=ldl############################################ File Configuration###########################################control_files=("E:\oracle\oradata\ldl\CONTROL01.CTL","E:\oracle\oradata\ldl\CONTROL02.CTL", "E:\oracle\oradata\ldl\CONTROL03.CTL")############################################ Pools###########################################java_pool_size=33554432large_pool_size=8388608shared_pool_size=50331648############################################ Cursors and Library Cache###########################################open_cursors=300############################################ System Managed Undo and Rollback Segments###########################################undo_management=AUTOundo_retention=10800undo_tablespace=UNDOTBS1########################################### # Diagnostics and Statistics########################################### background_dump_dest=E:\oracle\admin\ldl\bdump core_dump_dest=E:\oracle\admin\ldl\cdumptimed_statistics=TRUEuser_dump_dest=E:\oracle\admin\ldl\udump########################################### # Processes and Sessions########################################### processes=150########################################### # Redo Log and Recovery########################################### fast_start_mttr_target=300########################################### # Cache and I/O########################################### db_block_size=8192db_cache_size=25165824db_file_multiblock_read_count=16第四步,创建文件夹,E:\oracle\oradata\ldl\E:\oracle\admin\ldl\bdumpE:\oracle\admin\ldl\cdumpE:\oracle\admin\ldl\udumpE:\oracle\admin\ldl\createE:\oracle\admin\ldl\pfile第五步,创建sidC:\>oradim -NEW -sid ldl第六步,创建密码文件C:\>orapwd file=e:\oracle\ora92\database\pwdldl.ora password=oracle第七步,设置环境变量C:\>set oracle_sid=ldl第八步,启动数据库到nomount状态C:\>sqlplus "/as sysdba"SQL*Plus: Release 9.2.0.1.0 - Production on 星期四10月23 10:33:46 2008 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.已连接到空闲例程。
NBU NetBackup 恢复Oracle
本机恢复以恢复172.16.7.103(主机名ylbi)上的oracle为例,进行说明。
1.查看数据文件的存放位置。
SQL> select * from dba_data_files;2.备份所有数据文件。
$ pwd/sapboe/oradata$ ls -ltotal 8drwxr-x--- 2 orabop dba 4096 Dec 18 11:10 BOP $ tar -cvf BOP.tar BOP/a BOP/a BOP/bo_temp01.dbf 1024016 blocks.a BOP/boe_data01.dbf 1024016 blocks.a BOP/boe_data02.dbf 1024016 blocks.a BOP/boe_data03.dbf 1024016 blocks.a BOP/control01.ctl 15072 blocks.a BOP/cre_eas.dbf 102416 blocks.a BOP/ds_ce_data01.dbf 1024016 blocks.a BOP/ds_ce_data02.dbf 1024016 blocks.a BOP/ds_lo_data01.dbf 1024016 blocks.a BOP/ds_lo_data02.dbf 1024016 blocks.a BOP/ds_temp01.dbf 1024016 blocks.a BOP/loc_eas.dbf 274832 blocks.a BOP/redo01.log 102401 blocks.a BOP/redo02.log 102401 blocks.a BOP/redo03.log 102401 blocks.a BOP/sysaux01.dbf 1986576 blocks.a BOP/system01.dbf 1495056 blocks.a BOP/temp01.dbf 59408 blocks.a BOP/undotbs01.dbf 204816 blocks.a BOP/users01.dbf 10256 blocks.3.将备份出的BOP.tar包放到其他路径。
NBU重定向恢复Oracle数据库总结
一、对源数据库进行一次完整、成功的备份;二、在NBU Master Server上建立C:\Program Files\Veritas\NetBackup\altnames\No.Restrictions文件;三、对于源服务器Media Server恢复到Client的情况下需要在Master Server上进行如下配置:四、目标客户端的bp.conf文件里CLIENT_NAME = orcldb04,client name要制定源服务器名称;五、在目标客户端上要可以用bplist命令列出源客户端所有的备份镜像.六、恢复步骤1、恢复控制文件(数据库nomount状态下,set DBID=1271924299)run{allocate channel ch01 type sbt_tape;send 'nb_ora_serv=s4pb02,nb_ora_client=orcldb04';restore controlfile from '/cntrl_474_1_747243121';release channel ch01;}2、恢复数据文件(数据库mount状态下)run{allocate channel ch00 type sbt_tape;send 'nb_ora_serv=s4pb02,nb_ora_client=vip_db1';restore database;release channel ch00;}ORrun{allocate channel ch00 type sbt_tape;allocate channel ch01 type sbt_tape;send 'nb_ora_serv=s4pb02,nb_ora_client=orcldb04';set newname for datafile 00003 to '/data/orcl/sysaux01.dbf';set newname for datafile 00007 to '/data/orcl/DRGN_DATA10.dbf'; set newname for datafile 00011 to '/data/orcl/DRGN_DATA06.dbf'; set newname for datafile 00015 to '/data/orcl/DRGN_DATA02.dbf'; set newname for datafile 00018 to '/data/orcl/DRGN_INDEX03.dbf'; set newname for datafile 00004 to '/data/orcl/users01.dbf';set newname for datafile 00008 to '/data/orcl/DRGN_DATA09.dbf'; set newname for datafile 00012 to '/data/orcl/DRGN_DATA05.dbf'; set newname for datafile 00016 to '/data/orcl/DRGN_INDEX05.dbf'; set newname for datafile 00017 to '/data/orcl/DRGN_INDEX04.dbf'; set newname for datafile 00001 to '/data/orcl/system01.dbf';set newname for datafile 00006 to '/data/orcl/DRGN_INDEX01.dbf'; set newname for datafile 00010 to '/data/orcl/DRGN_DATA07.dbf'; set newname for datafile 00014 to '/data/orcl/DRGN_DATA03.dbf'; set newname for datafile 00019 to '/data/orcl/DRGN_INDEX02.dbf'; set newname for datafile 00002 to '/data/orcl/undotbs01.dbf'; set newname for datafile 00005 to '/data/orcl/DRGN_DATA01.dbf'; set newname for datafile 00009 to '/var/orcl/DRGN_DATA08.dbf'; set newname for datafile 00013 to '/var/orcl/DRGN_DATA04.dbf'; restore database;switch datafile all;(如果数据文件路径修改,必须运行此命令)release channel ch00;release channel ch01;}set newname for datafile 00005 to '/data/orcl/DRGN_DATA01.dbf';set newname for datafile 00009 to '/var/orcl/DRGN_DATA08.dbf';set newname for datafile 00013 to '/var/orcl/DRGN_DATA04.dbf';restore database;switch datafile all;(如果数据文件路径修改,必须运行此命令)recover database;(如果恢复的时候指定的控制文件为最后一次增量备份的时候备份的,那么需要进行recover database的操作,否则会提示数据库恢复不完全)release channel ch00;release channel ch01;}3、恢复归档日志文件(mount状态下)SQL> recover using backup controlfile until cancel;4、打开数据库SQL> alter database open resetlogs;七、验证恢复是否成功1、关闭数据库2、打开数据库3、列出数据文件SQL> recover using backup controlfile until cancel;ORA-00279: change 59832031 generated at 03/31/2011 15:31:09 needed for thread 1ORA-00289: suggestion :/data/app/product/10.2.0/db_1/dbs/arch1_897_744143566.dbfORA-00280: change 59832031 for thread 1 is in sequence #897Specify log: {<RET>=suggested | filename | AUTO | CANCEL}cancelMedia recovery cancelled.SQL> alter database open resetlogs;Database altered.SQL> shutdown immediate;Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1610612736 bytesFixed Size 2084296 bytesVariable Size 1023410744 bytesDatabase Buffers 570425344 bytesRedo Buffers 14692352 bytesDatabase mounted.Database opened.SQL> select name from V$datafile;NAME-------------------------------------------------------------------------------- /data/orcl/system01.dbf/data/orcl/undotbs01.dbf/data/orcl/sysaux01.dbf/data/orcl/users01.dbf/data/orcl/DRGN_DATA01.dbf/data/orcl/DRGN_INDEX01.dbf/data/orcl/DRGN_DATA10.dbf/data/orcl/DRGN_DATA09.dbf/var/orcl/DRGN_DATA08.dbf/data/orcl/DRGN_DATA07.dbf/data/orcl/DRGN_DATA06.dbfNAME-------------------------------------------------------------------------------- /data/orcl/DRGN_DATA05.dbf/var/orcl/DRGN_DATA04.dbf/data/orcl/DRGN_DATA03.dbf/data/orcl/DRGN_DATA02.dbf/data/orcl/DRGN_INDEX05.dbf/data/orcl/DRGN_INDEX03.dbf /data/orcl/DRGN_INDEX02.dbf19 rows selected.SQL>。
通过nbu恢复oracle数据库(恢复实例)
1、关闭开启的实例数据库(未关监听)shutdown immediate2、传NBU客户端3、安装NBU客户端/usr/openv/netbackup/bin ./oracle_link 建立连接新客户端必须启动这个命令,不然无法进行还原,需要在oracle用户下跑命令4、查询备份信息5、设置备份可强制恢复6、检查Oracle安装软件7、检查NBU客户端进程8、检查备份集cd /usr/openv/netbackup/bin./bplist -C cmccdb1_beifen -t 4-R -b -l /|more9、创建参数文件/u01/app/oracle/database/10R1/dbs oracle环境变量touch init bacdb.orachmod 777 initbacdb.orabacdb.__db_cache_size=1711276032bacdb.__java_pool_size=46976204bacdb.__large_pool_size=13421772bacdb.__oracle_base='/opt/oracle/app/oracle'#ORACLE_BASE set from environmentbacdb.__pga_aggregate_target=677799526bacdb.__sga_target=4019976806 ----服务器内存80%bacdb.__shared_io_pool_size=0bacdb.__shared_pool_size=228170137bacdb.__streams_pool_size=6710886*.audit_file_dest='/opt/oracle/app/oracle/admin/bacdb/adump'*.audit_trail='db'*.compatible='11.2.0.4.0'*.control_files='/opt/oracle/oradata/bacdb/controlfile/control01.ctl','/opt /oracle/oradata/bacdb/controlfile/control02.ctl'*.db_block_size=8192*.db_domain=''*.db_name='bacdb'*.diagnostic_dest='/opt/oracle/app/oracle'*.dispatchers='(PROTOCOL=TCP) (SERVICE=bacdbXDB)'bacdb.instance_number=1*.log_archive_dest_1='location=/opt/oracle/oradata/bacdb/arch'*.open_cursors=2000*.pga_aggregate_target=677799526*.processes=1000*.remote_login_passwordfile='exclusive'#*.sessions=4405*.sga_target=4019976806bacdb.thread=1bacdb.undo_tablespace='UNDOTBS1'10、创建文件目录mkdir -p /opt/oracle/app/oracle/admin/bacdb/adumpmkdir -p /opt/oracle/oradata/bacdb/controlfilemkdir -p /opt/oracle/oradata/bacdb/archmkdir -p /opt/oracle/oradata/bacdb/datafilemkdir -p /opt/oracle/oradata/bacdb/tempfilemkdir -p /opt/oracle/oradata/bacdb/onlinelog11、根据参数文件启动至nomountexport ORACLE_SID=bacdbsqlplus /as sysdbastartup nomount pfile='/opt/oracle/app/oracle/product/11.2.0/db_1/dbs/initbacdb.ora';12、根据参数文件创建spfile文件create spfile from pfile;13、重启至nomount状态startup force nomount;14、创建sys密码文件orapwd file=$ORACLE_HOME/dbs/orapwbacdb password=ERab3OC_4s entries=5 force=y15、恢复控制文件export ORACLE_SID=bacdbrman target /run{allocate channel ch0 type'sbt_tape';send 'NB_ORA_CLIENT= bac-db-01_beifen';send 'nb_ora_serv=NFJD-WHGLZY-NBU-1';restore controlfile from'/cntrl_7110_1_932480583'; release channel ch0;}16、启动至mount状态alter database mount;17、查询需要恢复的表空间select NAME,TS# from v$tablespace;因为我们这里只做部分表空间恢复,只需要恢复SYSTEM,SYSAUX,UNDOTBS1,TEMP,UNDOTBS2,USERS,DATA_SMSGW表空间,所以要分别找出这些表空间都包括那些数据文件:18、查询需要恢复的表空间对应的数据文件select file#,name from v$datafile where TS# in('0','1','2','3','4','5','6')19、恢复数据文件restore数据文件(执行脚本)$ nohup /opt/oracle/oradata/restore/restore.sh > restore.sh.out 2>&1 &rman target / nocatalog <<EOFrun {allocate channel ch00 type'SBT_TAPE';allocate channel ch01 type'SBT_TAPE';allocate channel ch02 type'SBT_TAPE';allocate channel ch03 type'SBT_TAPE';send 'NB_ORA_CLIENT=bac-db-01_beifen';send 'NB_ORA_SERV=NFJD-WHGLZY-NBU-1';set newname for datafile1to'/opt/oracle/oradata/bacdb/datafile/system.262.863641207';set newname for datafile2to'/opt/oracle/oradata/bacdb/datafile/sysaux.261.863641231';set newname for datafile3to'/opt/oracle/oradata/bacdb/datafile/undotbs1.260.863641255';set newname for datafile4to'/opt/oracle/oradata/bacdb/datafile/undotbs2.270.863641297';set newname for datafile5to'/opt/oracle/oradata/bacdb/datafile/users.269.863641331';set newname for datafile6to'/opt/oracle/oradata/bacdb/datafile/data_smsgw.276.863781045';set newname for datafile31to'/opt/oracle/oradata/bacdb/datafile/data_smsgw.301.884961611';set newname for datafile55to'/opt/oracle/oradata/bacdb/datafile/system.329.922185251';set newname for datafile60to'/opt/oracle/oradata/bacdb/datafile/undotbs1.334.925769101';set newname for datafile61to'/opt/oracle/oradata/bacdb/datafile/undotbs2.335.925769185';set newname for datafile62to'/opt/oracle/oradata/bacdb/datafile/system.336.926934061';restore database skip tablespaceTBS_ACS,TBS_UCMQ,TBS_BTS,WH_TS,TBS_MMCC,TBS_IAPMMWLAN,TBS_MMPG,TBS_SIMS20; switch datafile all;release channel ch00;release channel ch01;release channel ch02;release channel ch03;}EOF20、修改线日志文件路径select group#,member from v$logfile order by group#;alter database rename file'+DATA/bacdb/onlinelog/group_1.256.863641201'to'/opt/oracle/oradata/bacdb/onlinelog/group_1.256.863641201';alter database rename file'+DATA/bacdb/onlinelog/group_2.266.863641203'to'/opt/oracle/oradata/bacdb/onlinelog/group_2.266.863641203';alter database rename file'+DATA/bacdb/onlinelog/group_3.258.863643321'to'/opt/oracle/oradata/bacdb/onlinelog/group_3.258.863643321';alter database rename file'+DATA/bacdb/onlinelog/group_4.257.863643323'to'/opt/oracle/oradata/bacdb/onlinelog/group_4.257.863643323';alter database rename file'+DATA/bacdb/onlinelog/group_5.274.863641203'to'/opt/oracle/oradata/bacdb/onlinelog/group_5.274.863641203';alter database rename file'+DATA/bacdb/onlinelog/group_6.273.863641205'to'/opt/oracle/oradata/bacdb/onlinelog/group_6.273.863641205';alter database rename file'+DATA/bacdb/onlinelog/group_7.272.863641205'to'/opt/oracle/oradata/bacdb/onlinelog/group_7.272.863641205';alter database rename file'+DATA/bacdb/onlinelog/group_8.271.863641207'to'/opt/oracle/oradata/bacdb/onlinelog/group_8.271.863641207';alter database rename file'+DATA/bacdb/onlinelog/group_9.268.863643325'to'/opt/oracle/oradata/bacdb/onlinelog/group_9.268.863643325';alter database rename file'+DATA/bacdb/onlinelog/group_10.267.863643325'to'/opt/oracle/oradata/bacdb/onlinelog/group_10.267.863643325';alter database rename file'+DATA/bacdb/onlinelog/group_11.265.863643327'to'/opt/oracle/oradata/bacdb/onlinelog/group_11.265.863643327';alter database rename file'+DATA/bacdb/onlinelog/group_12.264.863643327'to '/opt/oracle/oradata/bacdb/onlinelog/group_12.264.863643327';21、recover数据库run {allocate channel ch00 type'SBT_TAPE';allocate channel ch01 type'SBT_TAPE';allocate channel ch02 type'SBT_TAPE';allocate channel ch03 type'SBT_TAPE';send 'NB_ORA_CLIENT=bac-db-01_beifen';send 'NB_ORA_SERV=NFJD-WHGLZY-NBU-1';recover database skip forever tablespaceTBS_ACS,TBS_UCMQ,TBS_BTS,WH_TS,TBS_MMCC,TBS_IAPMMWLAN,TBS_MMPG,TBS_SIMS20; release channel ch00;release channel ch01;release channel ch02;release channel ch03;}22、打开数据库alter database open resetlogs;select open_mode from v$database;23、创建临时表空间SQL> create temporary tablespace temp1 tempfile '/opt/products/oradata/temp1.dbf' size 500m;Tablespace created.SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY';TABLESPACE_NAME------------------------------TEMPUSSD2_TEMPTEMP1SQL> alter database default temporary tablespace temp1;Database altered.SQL> drop tablespace TEMP including contents and datafiles;Tablespace dropped.SQL> drop tablespace USSD2_TEMP including contents and datafiles;Tablespace dropped.注:Oracle的恢复需要注意。
异机恢复ORACLE数据库(NBU)
异机恢复ORACLE数据库(NBU)ORACLE数据库异机恢复(NBU)一.恢复的前提条件.1.)日常备份都是成功的。
至少有一次全备份及全备份以来的增量备份和Archivelog.2.)原主机的OS及ORACLE版本与目标主机的OS及ORACLE版本保持一致.3.)需要原数据库的下列信息:1)IP Address, Hostname, Nbu media server/client2)Oracle DB version, SID,DBID,Datafile Path,Controlfile Path,Archivelog Path3)Catalog DB IP,SID/Service name ,user/password4.)在目标主机上安装与原数据库版本相同的oracle软件(Install type :Softwareonly)5.)在目标主机上安装Veritas 软件,安装类型与原主机一致(media server or client)二. 下面以aush49上的s1rel DB恢复到aush61为例对veritas 及oracle进行配置.1 )在目标主机上(aush61)配置veritas1) Edit $ORACLE_HOME/bp.conf file(aush61) s3pis> cd $ORACLE_HOME(aush61) s3pis> vi bp.confSERVER = aush06 /*master server host name*/CLIENT_NAME = aush49 /*source host name ,如果aush49是media server则写 SERVER = aush49*/CLINET_READ_TIMEOUT = 18002)Edit /usr/openv/netbackup/bp.conf ( aush61)aush61#vi bp.confSERVER = aush06 /*master servername*/CLIENT_NAME = aush49 /*source host name , 如果aush49是media server则写 SERVER = aush49*/CLIENT_NAME = aush61 /*target host name */VERBOSE = 5CLIENT_READ_TIMEOUT = 1800CLIENT_CONNECT_TIMEOUT = 18003) Touch a file on Master Server (aush06)aush06#cd /usr/openv/netbackup/db/altnamesaush06#touchaush61 /*target host name */2 ) 在master server (aush06)与目标主机(aush61)上配置/etc/hosts 文件aush61#vi /etc/hosts127.0.0.1 localhost10.5.15.61 aush6110.5.15.6 aush0610.5.15.49 aush4910.5.15.58 aush58aush06#vi /etc/hosts127.0.0.1 localhost10.5.15.61 aush6110.5.15.6 aush0610.5.15.49 aush4910.5.15.58 aush583) 在目标主机上(aush61)配置ORACLE.1 )创建于原数据库(aush49)相同的oracle user/group : s3pis/dba2 ) 配置s3pis环境变量(aush61) s3pis> more .profileORACLE_HOME=/u01/s3pis;export ORACLE_HOMEORACLE_SID=s3rel;export ORACLE_SIDPATH=$PATH:$ORACLE_HOME/bin;export PATHPS1="(`hostname`) `whoami`> "LD_LIBRARY_PATH=$ORACLE_HOME/lib;exportLD_LIBRARY_PATH3 ) 安装与原数据库相同版本的Oracle 软件,安装类型:SOFTWARE ONLY.4 ) 创建$ORACLE_HOME/network/admin/tnsnames.ora 文件连接catalog DB.(aush61) s3pis> more tnsnames.oracatalog =(description=(address_list=(address=(protocol=tcp)(host=10.5.13.178)(port=1521)))(connect_data=(service_name=catalog)))5 ) 创建pfile如果有原数据库(s1rel db)的pfile 或spfile ,可以直接使用;如果没有可以手动创建pfile !6 )创建与原数据库(s1rel db)相同的文件存放路径!1)根据对原数据库(s1rel )的日常维护信息,可以知道controlfile,datafile,archivelog file 的存取路径。
NBU oracle rac 异机恢复到单机(11G)
oracle 11g rac 恢复到单机环境介绍:10.204.101.45和46是11.2.0.4.0的rac环境,变成单机恢复到测试环境10.204.16.155(双方都是linux系统)101.45-racdb1101.46-racdb2补充:通过查看v$db_transportable_platform可以看到跨平台恢复是否支持:AIX 支持的平台恢复:linux 支持的平台恢复:一、16.155环境准备1、安装数据库软件2、安装nbu:二、恢复1、新建参数文件:到101.45上面把参数文件down下来修改下,修改后内容如下:cd $ORACLE_HOME/dbs/vi initracdb.oraracdb.__db_cache_size=369098752racdb.__java_pool_size=16777216racdb.__large_pool_size=33554432racdb.__oracle_base='/oracle/app/oracle'racdb.__pga_aggregate_target=553648128racdb.__sga_target=1056964608racdb.__shared_io_pool_size=0racdb.__shared_pool_size=620756992racdb.__streams_pool_size=0*.audit_file_dest='/oracle/app/admin/racdb/adump'*.audit_trail='FALSE'#*.cluster_database=true //单机去掉*.compatible='11.2.0.4.0'*.control_files='/oracle/app/oradata/racdb/ctl01.ctl'*.db_block_size=8192*.db_create_file_dest='/oracle/app'*.db_domain=''*.db_name='racdb'*.diagnostic_dest='/oracle/app'*.dispatchers='(PROTOCOL=TCP) (SERVICE=racdbXDB)'racdb.instance_number=1racdb.log_archive_dest_1='LOCATION=/oracle/arch'*.memory_target=1606418432*.open_cursors=300*.processes=500*.remote_login_passwordfile='exclusive'*.sessions=555racdb.thread=1racdb.undo_tablespace='UNDOTBS1'注意事项:1>把racdb2的删除掉,把racdb1替换成racdb2>把涉及到路径的替换成实际环境的,有些目录得手工创建。
NBU-ORACLE-异机异路径恢复
NBU_ORACLE_异机不同路径恢复详解恢复环境:NBU MASTER SERVER: as5NBU CLENET: e1, oracle源数据服务器,已做备份。
NBU CLIENT: e2, oracle目标服务器。
已装好跟e1同版本,同实例名,不同路径数据库,NBU AGENT已装好。
恢复内容:把e1备份的oracle恢复到e2上恢复过程:(下列过程只在as5和e2上操作)1. 把e2上安装的数据库开启归档,指定归档路径,归档路径在恢复时要使用,确保有足够的空间。
2. 在MASTER SERVER的C:\Program Files\Veritas\NetBackup\db\altnames目录下新建文件 No.Restrictions(允许异机恢复)。
3. 在e2上点击“开始”>打开backup,archive,restore程序4. 打开“File”>“Specify Netbackup Machines and Policy Type”第1页5. 点击“Edit Client List”按钮6. 添加e1进去。
第2页7. 在“Source client for restore”里改成e1(原来是e2)。
点击“OK”。
8. 然后点击菜单栏上的“Select for Restore”,然后选中要还原的e1的控制文件的备份,点击左边的恢复按钮(红圈处。
)9. 选择“Restore everything to a different location”,在“Destination”里定位到e2上控制文件所在的目录。
点击“Start Restore”开始恢复。
第3页10. 恢复成功后,关闭数据库C:\Documents and Settings\Administrator>sqlplus "/as sysdba"SQL> shutdown immediate; 关闭数据库11. 然后把恢复过来的e1的控制文件备份复制3份到该目录下,分别重命名为CONTROL01.CTL,CONTROL02.CTL,CONTROL03.CTL。
NBU oracle rac 异机恢复到单机(11G)
oracle 11g rac 恢复到单机环境介绍:10.204.101.45和46是11.2.0.4.0的rac环境,变成单机恢复到测试环境10.204.16.155(双方都是linux系统)101.45-racdb1101.46-racdb2补充:通过查看v$db_transportable_platform可以看到跨平台恢复是否支持:AIX 支持的平台恢复:linux 支持的平台恢复:一、16.155环境准备1、安装数据库软件2、安装nbu:二、恢复1、新建参数文件:到101.45上面把参数文件down下来修改下,修改后内容如下:cd $ORACLE_HOME/dbs/vi initracdb.oraracdb.__db_cache_size=369098752racdb.__java_pool_size=16777216racdb.__large_pool_size=33554432racdb.__oracle_base='/oracle/app/oracle'racdb.__pga_aggregate_target=553648128racdb.__sga_target=1056964608racdb.__shared_io_pool_size=0racdb.__shared_pool_size=620756992racdb.__streams_pool_size=0*.audit_file_dest='/oracle/app/admin/racdb/adump'*.audit_trail='FALSE'#*.cluster_database=true //单机去掉*.compatible='11.2.0.4.0'*.control_files='/oracle/app/oradata/racdb/ctl01.ctl'*.db_block_size=8192*.db_create_file_dest='/oracle/app'*.db_domain=''*.db_name='racdb'*.diagnostic_dest='/oracle/app'*.dispatchers='(PROTOCOL=TCP) (SERVICE=racdbXDB)'racdb.instance_number=1racdb.log_archive_dest_1='LOCATION=/oracle/arch'*.memory_target=1606418432*.open_cursors=300*.processes=500*.remote_login_passwordfile='exclusive'*.sessions=555racdb.thread=1racdb.undo_tablespace='UNDOTBS1'注意事项:1>把racdb2的删除掉,把racdb1替换成racdb2>把涉及到路径的替换成实际环境的,有些目录得手工创建。
NBU-Oracle备份恢复配置手册
NBU-Oracle备份恢复配置手册NBU ORACLE备份恢复配置手册Version 1.012安装前准备安装NBU SAN Media Server软件参照《NBU Media Server 安装手册》3安装配置NBU Oracle agent软件root@QC_P550_731:/mnt/install/NB_65_UOptions_20070723/vDBA>./install **********There are two ways to install database agent software.1. Remote Installation: Loads the software on a server withthe intent of pushing database software out to affected clients.2. Local Installation: Loads and installs the software only to thislocal machine.**********Do you want to do a local installation? [y,n] (n) y**********NetBackup Database Agent InstallationChoose the Database Agents you wish to installone at a time or select Install All Database Agents.1) NetBackup for DB22) NetBackup for Informix3) NetBackup for Lotus Notes4) NetBackup for Oracle5) NetBackup for SAP6) NetBackup for Sybase7) Install All Database Agentsq) Done Selecting Agentsx) Exit from this ScriptChoose an option: 4Choose an option: qYou have chosen to install these Database Agents:NetBackup for OracleIs this list correct? [y,n] (y)**********Of the agents selected, the following are supportedon this platform and will be installed:OracleNOTE: A license key for each of these selected agentswill be required on the master server in order for theagent to function properly.Loading the Database Agent packages into the/usr/openv/netbackup/dbext directory and installing.**********Installing NetBackup for OracleInstalling NetBackup for Oracle...Extracting files from /usr/openv/netbackup/dbext/OEBU.rs6000_51.tar.Z ... x usr/openv/netbackupx usr/openv/netbackup/binx usr/openv/netbackup/bin/bpubsora, 137444 bytes, 269 tape blocksx usr/openv/netbackup/bin/bpdbsbora, 128302 bytes, 251 tape blocksx usr/openv/netbackup/bin/libobk.a, 108793 bytes, 213 tape blocksx usr/openv/netbackup/bin/oracle_link, 32260 bytes, 64 tape blocksx usr/openv/netbackup/bin/bporaexp, 150370 bytes, 294 tape blocksx usr/openv/netbackup/bin/bporaimp, 162223 bytes, 317 tape blocksx usr/openv/netbackup/bin/libobk.a64, 117484 bytes, 230 tape blocksx usr/openv/netbackup/bin/bporaexp64, 164480 bytes, 322 tape blocksx usr/openv/netbackup/bin/bporaimp64, 177322 bytes, 347 tape blocksx usr/openv/netbackup/dbextx usr/openv/netbackup/dbext/OEBU.rs6000_51.version, 24 bytes, 1 tape blocksx usr/openv/netbackup/extx usr/openv/netbackup/ext/db_extx usr/openv/netbackup/ext/db_ext/oraclex usr/openv/netbackup/ext/db_ext/oracle/samplesx usr/openv/netbackup/ext/db_ext/oracle/samples/rmanx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/cold_database_backup.sh, 11875 bytes, 24 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/rman/cold_duplex_database_backup_full .sh, 12789 bytes, 25 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/database_restore.sh, 7155 bytes, 14 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_database_backup.sh, 11538 bytes, 23 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_tablespace_backup.sh, 11154 bytes, 22 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/pit_database_restore.sh, 10307 bytes, 21 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_database_backup_proxy.sh, 9983 bytes, 20 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_tablespace_backup_proxy.sh, 8575 bytes, 17 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bpend_notify.oracle_bli.sh, 27764 bytes, 55 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bpstart_notify.oracle_bli.sh, 31867 bytes, 63 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/post_checkpoint_notify.oracle_bli.sh, 21844 bytes, 43 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexpx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/data_archiver_export.sh, 5124 bytes, 11 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/data_archiver_export64.sh, 5130 bytes, 11 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_help.param, 733 bytes, 2 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_partitions.param, 1605 bytes, 4 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_table_to_files.param, 1652 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_tables.param, 1669 bytes, 4 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_tables_rows.param, 1868 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimpx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/data_archiver_import.sh, 5044 bytes, 10 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/data_archiver_import64.sh, 5050 bytes, 10 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive.param, 1242 bytes, 3 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive_schema_to_ files.param, 1317 bytes, 3 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive_to_users.pa ram, 1510 bytes, 3 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_bfile_table.param, 1604 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_help.param, 733 bytes, 2 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_ignore_rows_table.p aram, 1530 bytes, 3 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_large_table.param, 1542 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_list.param, 1594 bytes, 4 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_old_archive.param, 1556 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_partitions.param, 1513 bytes, 3 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_from_files.par am, 1370 bytes, 3 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_to_files.param , 1301 bytes, 3 tape blocksxusr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_to_user.param , 1656 bytes, 4 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_tables.param, 1289 bytes, 3 tape blocksx usr/openv/netbackup/ext/db_ext/oracle/binx usr/openv/netbackup/ext/db_ext/oracle/bin/setup_bli_scripts, 18091 bytes, 36 tape blocksx usr/openv/libx usr/openv/lib/libdbsbrman.so, 2029485 bytes, 3964 tape blocksx usr/openv/lib/libbpora.so.8.0, 257994 bytes, 504 tape blocksx usr/openv/lib/libbpora.so.9.0, 258010 bytes, 504 tape blocksx usr/openv/lib/libbpora64.so.9.0, 288345 bytes, 564 tape blocksx usr/openv/lib/libnbberman.so, 161051 bytes, 315 tape blocksLiveUpdate is not installed, skipping registration step...NetBackup for Oracle installation completed.**********Execution of ./install_dbext is complete.Execution of ./install is complete.File /usr/openv/tmp/install_addon_trace.2761086 contains a trace of this install.root@QC_P550_731:/mnt/install/NB_65_UOptions_20070723/vDBA>配置NBU Oracle Agentroot@QC_P550_731:/mnt/install/NB_65_UOptions_20070723/vDBA>su - oracle [YOU HAVE NEW MAIL]QC_P550_731:/home/oracle$cd /usr/openv/netbackup/binQC_P550_731:/usr/openv/netbackup/bin$./oracle_linkFri Apr 3 10:07:28 BEIST 2009All Oracle instances should be shutdown before running this script.Please log into the Unix system as the Oracle owner for running this scriptDo you want to continue? (y/n) [n] yLIBOBK path: /usr/openv/netbackup/binORACLE_HOME: /oracle/app/oracle/product/9.2.0Oracle version: 9.2.0.8.04创建Oracle备份脚本数据库全备份脚本/usr/openv/rman/hot_database_backup_zjcj2.sh,其中红色字体部分根据oracle修改#!/bin/sh# $Header: hot_database_backup.sh,v 1.2 2002/08/06 23:51:42 $##bcpyrght#***************************************************************************#* $VRTScprght: Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved $ * #***************************************************************************#ecpyrght## ---------------------------------------------------------------------------# hot_database_backup.sh# ---------------------------------------------------------------------------# This script uses Recovery Manager to take a hot (inconsistent) database# backup. A hot backup is inconsistent because portions of the database are# being modified and written to the disk while the backup is progressing.# You must run your database in ARCHIVELOG mode to make hot backups. It is# assumed that this script will be executed by user root. In order for RMAN# to work properly we switch user (su -) to the oracle dba account before# execution. If this script runs under a user account that has Oracle dba# privilege, it will be executed using this user's account.# ---------------------------------------------------------------------------# ---------------------------------------------------------------------------# Determine the user which is executing this script.# ---------------------------------------------------------------------------CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`# ---------------------------------------------------------------------------# Put output in <this file name>.out. Change as desired.# Note: output directory requires write permission.# ---------------------------------------------------------------------------RMAN_LOG_FILE=${0}.`date +%Y%m%d%H%M%S`.out# ---------------------------------------------------------------------------# You may want to delete the output file so that backup information does # not accumulate. If not, delete the following lines.# ---------------------------------------------------------------------------if [ -f "$RMAN_LOG_FILE" ]thenrm -f "$RMAN_LOG_FILE"fi# -----------------------------------------------------------------# Initialize the log file.# -----------------------------------------------------------------echo >> $RMAN_LOG_FILEchmod 666 $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Log the start of this script.# ---------------------------------------------------------------------------echo Script $0 >> $RMAN_LOG_FILEecho ==== started on `date` ==== >> $RMAN_LOG_FILEecho >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Replace /db/oracle/product/ora81, below, with the Oracle home path.# ---------------------------------------------------------------------------ORACLE_HOME=/oracle/app/oracle/product/9.2.0export ORACLE_HOME# ---------------------------------------------------------------------------# Replace ora81, below, with the Oracle SID of the target database.# ---------------------------------------------------------------------------ORACLE_SID=zjcj2export ORACLE_SID# ---------------------------------------------------------------------------# Replace ora81, below, with the Oracle DBA user id (account).# ---------------------------------------------------------------------------ORACLE_USER=oracle# ---------------------------------------------------------------------------# Set the target connect string.# Replace "sys/manager", below, with the target connect string.# ---------------------------------------------------------------------------TARGET_CONNECT_STR=/# ---------------------------------------------------------------------------# Set the Oracle Recovery Manager name.# ---------------------------------------------------------------------------RMAN=$ORACLE_HOME/bin/rman# ---------------------------------------------------------------------------# Print out the value of the variables set by this script.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILEecho "RMAN: $RMAN" >> $RMAN_LOG_FILEecho "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILEecho "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE echo "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Print out the value of the variables set by bphdb.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILEecho "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILE echo "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILE echo "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILE echo "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILE echo "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# NOTE: This script assumes that the database is properly opened. If desired,# this would be the place to verify that.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# If this script is executed from a NetBackup schedule, NetBackup# sets an NB_ORA environment variable based on the schedule type.# The NB_ORA variable is then used to dynamically set BACKUP_TYPE# For example, when:# schedule type is BACKUP_TYPE is# ---------------- --------------# Automatic Full INCREMENTAL LEVEL=0# Automatic Differential Incremental INCREMENTAL LEVEL=1# Automatic Cumulative Incremental INCREMENTAL LEVEL=1 CUMULATIVE ## For user initiated backups, BACKUP_TYPE defaults to incremental# level 0 (full). To change the default for a user initiated# backup to incremental or incremental cumulative, uncomment# one of the following two lines.# BACKUP_TYPE="INCREMENTAL LEVEL=1"# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"## Note that we use incremental level 0 to specify full backups.# That is because, although they are identical in content, only# the incremental level 0 backup can have incremental backups of# level > 0 applied to it.# ---------------------------------------------------------------------------if [ "$NB_ORA_FULL" = "1" ]thenecho "Full backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=0"elif [ "$NB_ORA_INCR" = "1" ]thenecho "Differential incremental backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=1"elif [ "$NB_ORA_CINC" = "1" ]thenecho "Cumulative incremental backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"elif [ "$BACKUP_TYPE" = "" ]thenecho "Default - Full backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=0"fi# ---------------------------------------------------------------------------# Call Recovery Manager to initiate the backup. This example does not use a# Recovery Catalog. If you choose to use one, replace the option 'nocatalog'# from the rman command line below with the# 'rcvcat <userid>/<passwd>@<tns alias>' statement.## Note: Any environment variables needed at run time by RMAN# must be set and exported within the switch user (su) command.# ---------------------------------------------------------------------------# Backs up the whole database. This backup is part of the incremental# strategy (this means it can have incremental backups of levels > 0# applied to it).## We do not need to explicitly request the control file to be included# in this backup, as it is automatically included each time file 1 of# the system tablespace is backed up (the inference: as it is a whole# database backup, file 1 of the system tablespace will be backed up,# hence the controlfile will also be included automatically).## Typically, a level 0 backup would be done at least once a week.## The scenario assumes:# o you are backing your database up to two tape drives# o you want each backup set to include a maximum of 5 files# o you wish to include offline datafiles, and read-only tablespaces,# in the backup# o you want the backup to continue if any files are inaccessible.# o you are not using a Recovery Catalog# o you are explicitly backing up the control file. Since you are# specifying nocatalog, the controlfile backup that occurs# automatically as the result of backing up the system file is# not sufficient; it will not contain records for the backup that# is currently in progress.# o you want to archive the current log, back up all the# archive logs using two channels, putting a maximum of 20 logs# in a backup set, and deleting them once the backup is complete.## Note that the format string is constructed to guarantee uniqueness and# to enhance NetBackup for Oracle backup and restore performance.### NOTE WHEN USING TNS ALIAS: When connecting to a database# using a TNS alias, you must use a send command or a parms operand to# specify environment variables. In other words, when accessing a database # through a listener, the environment variables set at the system level are not # visible when RMAN is running. For more information on the environment # variables, please refer to the NetBackup for Oracle Admin. Guide.## ---------------------------------------------------------------------------CMD_STR="ORACLE_HOME=$ORACLE_HOMEexport ORACLE_HOMEORACLE_SID=$ORACLE_SIDexport ORACLE_SID$RMAN target $TARGET_CONNECT_STR rcvcat rman/rman@qcrman msglog $RMAN_LOG_FILE append << EOFRUN {resync catalog;allocate channel t1 type 'SBT_TAPE';send 'NB_ORA_POLICY=$NB_ORA_POLICY';send 'NB_ORA_CLIENT=QC_P550_732';backuptag controlfformat 'cf_%s_%p'(current controlfile);release channel t1;#allocate channel t1 type 'SBT_TAPE' parms 'BLKSIZE=131072';allocate channel t2 type 'SBT_TAPE' parms 'BLKSIZE=131072';send 'NB_ORA_POLICY=$NB_ORA_POLICY';send 'NB_ORA_CLIENT=QC_P550_732';set maxcorrupt for datafile 1 to 0;backuptag bcktbs1filesperset 10format 'df_t%s_p%p'(tablespace system,users,tools,indx,undotbs1,undotbs2,id_user,id_user_ind);sql 'alter system archive log current';release channel t1;release channel t2;}EOF"# Initiate the command stringif [ "$CUSER" = "root" ]thensu - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE RSTAT=$?else/usr/bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILERSTAT=$?fi# ---------------------------------------------------------------------------# Log the completion of this script.# ---------------------------------------------------------------------------if [ "$RSTAT" = "0" ]thenLOGMSG="ended successfully"elseLOGMSG="ended in error"fiecho >> $RMAN_LOG_FILEecho Script $0 >> $RMAN_LOG_FILEecho ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILEecho >> $RMAN_LOG_FILEexit $RSTAT数据库归档备份脚本/usr/open/rman/hot_database_backup_zjcj2.sh,其中红色字体部分根据oracle修改#!/bin/sh# $Header: hot_database_backup.sh,v 1.2 2002/08/06 23:51:42 $##bcpyrght#***************************************************************************#* $VRTScprght: Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved $ * #***************************************************************************#ecpyrght## ---------------------------------------------------------------------------# hot_database_backup.sh# ---------------------------------------------------------------------------# This script uses Recovery Manager to take a hot (inconsistent) database# backup. A hot backup is inconsistent because portions of the database are# being modified and written to the disk while the backup is progressing.# You must run your database in ARCHIVELOG mode to make hot backups. It is # assumed that this script will be executed by user root. In order for RMAN# to work properly we switch user (su -) to the oracle dba account before# execution. If this script runs under a user account that has Oracle dba# privilege, it will be executed using this user's account.# ---------------------------------------------------------------------------# ---------------------------------------------------------------------------# Determine the user which is executing this script.# ---------------------------------------------------------------------------CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`# ---------------------------------------------------------------------------# Put output in <this file name>.out. Change as desired.# Note: output directory requires write permission.# ---------------------------------------------------------------------------RMAN_LOG_FILE=${0}.`date +%Y%m%d%H%M%S`.out# ---------------------------------------------------------------------------# You may want to delete the output file so that backup information does # not accumulate. If not, delete the following lines.# ---------------------------------------------------------------------------if [ -f "$RMAN_LOG_FILE" ]thenrm -f "$RMAN_LOG_FILE"fi# -----------------------------------------------------------------# Initialize the log file.# -----------------------------------------------------------------echo >> $RMAN_LOG_FILEchmod 666 $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Log the start of this script.# ---------------------------------------------------------------------------echo Script $0 >> $RMAN_LOG_FILEecho ==== started on `date` ==== >> $RMAN_LOG_FILEecho >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Replace /db/oracle/product/ora81, below, with the Oracle home path.# ---------------------------------------------------------------------------ORACLE_HOME=/oracle/app/oracle/product/9.2.0export ORACLE_HOME# ---------------------------------------------------------------------------# Replace ora81, below, with the Oracle SID of the target database. # ---------------------------------------------------------------------------ORACLE_SID=zjcj2export ORACLE_SID# ---------------------------------------------------------------------------# Replace ora81, below, with the Oracle DBA user id (account).# ---------------------------------------------------------------------------ORACLE_USER=oracle# ---------------------------------------------------------------------------# Set the target connect string.# Replace "sys/manager", below, with the target connect string.# ---------------------------------------------------------------------------TARGET_CONNECT_STR=/# ---------------------------------------------------------------------------# Set the Oracle Recovery Manager name.# ---------------------------------------------------------------------------RMAN=$ORACLE_HOME/bin/rman# ---------------------------------------------------------------------------# Print out the value of the variables set by this script.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILEecho "RMAN: $RMAN" >> $RMAN_LOG_FILEecho "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILEecho "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE echo "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# Print out the value of the variables set by bphdb.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILEecho "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILEecho "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILEecho "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILEecho "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILEecho "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# NOTE: This script assumes that the database is properly opened. If desired, # this would be the place to verify that.# ---------------------------------------------------------------------------echo >> $RMAN_LOG_FILE# ---------------------------------------------------------------------------# If this script is executed from a NetBackup schedule, NetBackup# sets an NB_ORA environment variable based on the schedule type.# The NB_ORA variable is then used to dynamically set BACKUP_TYPE# For example, when:# schedule type is BACKUP_TYPE is# ---------------- --------------# Automatic Full INCREMENTAL LEVEL=0# Automatic Differential Incremental INCREMENTAL LEVEL=1# Automatic Cumulative Incremental INCREMENTAL LEVEL=1 CUMULATIVE ## For user initiated backups, BACKUP_TYPE defaults to incremental# level 0 (full). To change the default for a user initiated# backup to incremental or incremental cumulative, uncomment# one of the following two lines.# BACKUP_TYPE="INCREMENTAL LEVEL=1"# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"## Note that we use incremental level 0 to specify full backups.# That is because, although they are identical in content, only# the incremental level 0 backup can have incremental backups of# level > 0 applied to it.# ---------------------------------------------------------------------------if [ "$NB_ORA_FULL" = "1" ]thenecho "Full backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=0"elif [ "$NB_ORA_INCR" = "1" ]thenecho "Differential incremental backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=1"elif [ "$NB_ORA_CINC" = "1" ]thenecho "Cumulative incremental backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"elif [ "$BACKUP_TYPE" = "" ]thenecho "Default - Full backup requested" >> $RMAN_LOG_FILEBACKUP_TYPE="INCREMENTAL LEVEL=0"fi# ---------------------------------------------------------------------------# Call Recovery Manager to initiate the backup. This example does not use a# Recovery Catalog. If you choose to use one, replace the option 'nocatalog'# from the rman command line below with the# 'rcvcat <userid>/<passwd>@<tns alias>' statement.## Note: Any environment variables needed at run time by RMAN# must be set and exported within the switch user (su) command.# ---------------------------------------------------------------------------# Backs up the whole database. This backup is part of the incremental# strategy (this means it can have incremental backups of levels > 0# applied to it).## We do not need to explicitly request the control file to be included# in this backup, as it is automatically included each time file 1 of# the system tablespace is backed up (the inference: as it is a whole# database backup, file 1 of the system tablespace will be backed up,# hence the controlfile will also be included automatically).## Typically, a level 0 backup would be done at least once a week.## The scenario assumes:。
Linux上NBU异机恢复Oracle测试
目录Linux平台下的恢复测试 (2)1. Oracle数据库恢复测试环境 (2)2. 恢复spfile文件 (4)3. 恢复控制文件 (5)4. 恢复数据文件 (6)5. 还原数据库 (7)6. 检验数据库一致性 (8)Linux平台下的恢复测试1.Oracle数据库恢复测试环境Windows 7 上安装NBU Master Server端,两个虚拟机上分别为源端和测试端,oracle 版本为oracle10g,数据库实例名为test。
整个恢复测试分为数据库的全备,数据库的spfile文件恢复,控制文件controlfile的恢复,恢复数据库和还原数据库。
恢复前准备,做好远数据库端的数据库全备,查询清楚源端数据库的备份集信息,如下图,1.在备份服务器上使用bplist命令,查看ORACLE数据库备份文件。
bplist –C oa.localdomain –t 4 –R \2.在源端rman上查看list backupset;查询spfile文件和控制文件的备份集信息,在测试端安装好oracle 的数据库软件和监听,不需要建立实例;在测试端建立好几个文件路径:/u01/app/oracle/product/10.2.0/admin/test下建立adump、bdump、cdump、udump、dpdump和pfile文件夹;在/u01/oracle下建立oradata和其子目录test文件夹。
Rman noumount状态登陆,然后登录如下,退出重新登陆rman 登录后状态为DUMMY。
2.恢复spfile文件现在一起准备就绪,输入恢复脚本,在脚本中加入从备份集查询到的信息,如下:run{allocate channel ch01 type 'sbt_tape';allocate channel ch02 type 'sbt_tape'parms="ENV=(NB_ORA_CLIENT=win2003,NB_ORA_SID=test,NB_ORA_SERV=axelpc)";restore spfile to 'E:\oracle\product\10.2.0\db_1\dbs\spfiletest.ora' from 'bk_u0ap2bbh9_s10_p1_t841330217';release channel ch1;release channel ch2;}解析:1.NB_ORA_CLIENT=oratest,NB_ORA_SERV=axelpc分别是源端主机名,数据库实例名,备份服务器的主机名2./u01/app/oracle/product/10.2.0/db_1dbs/spfiletest.ora是spfile的文件路径3.bk_4_1_842413981是spfile备份集的句柄,也可在NBU服务端查询,查询指令为:bplist -C test -t 4 –R\ 输出结果如下图,恢复成功之后可以看到如下显示,3.恢复控制文件Sqlplus进入启动nomount状态:>startup nomount;然后进入rman下运行如下脚本:run{allocate channel ch01 type 'sbt_tape'parms="ENV=(NB_ORA_CLIENT=oratest,NB_ORA_SERV=axelpc)"; restore controlfile from ' cntrl_7_1_842414152';release channel ch01;}解析都一样,其中cntrl_7_1_842414152是控制文件的备份集句柄。
ORACLE_11G_HA__NBU异机恢复过程
ORACLE 11G AIX HA ----NBU异机恢复过程恢复前提1.两台机器上NUB软件都已经安装好2.指定Master SERVER 上的/usr/openv/netbackup/bp.conf恢复源FORCE_RESTORE_MEDIA_SERVER = 生产库hostname 测试库hostname从生产库恢复到测试库。
操作目的节点POTLDB01 数据库恢复到POTLDB02即在节点POTLDB01上运行,并在节点POTLDB01上备份,恢复到POTLDB02上节点POTLDB01机器检查过程1.检查环境变量检查root@POTLDB01:/usr/openv/rmanscript#ps -ef |grep smonroot 385272 467274 0 10:40:22 pts/2 0:00 grep smonoracle 655484 1 0 Jul 25 - 0:06 ora_smon_portaldb机器名字root@POTLDB01:/usr/openv/rmanscript#hostnamePOTLDB01root@POTLDB01:/usr/openv/rmanscript#pwd ---rman脚本位置/usr/openv/rmanscriptroot@POTLDB01:/usr/openv/rmanscript#lshot_database_portaldb.sh hot_database_portaldb.sh.out hot_database_portaldb.sh_bak/etc/hosts文件172.16.3.115 POTLDB01_boot172.16.3.116 POTLDB02_boot172.16.3.116 POTLDB02172.16.3.115 POTLDB011.1.3.115 POTLDB01_stby1.1.3.116 POTLDB02_stby172.16.3.117 POTLDB_svc172.16.7.142 SHYQ-PS-MV-SV03-POTLDB01-nbu172.16.7.143 SHYQ-PS-MV-SV03-POTLDB02-nbu 网关IP10.11.233.124 nbumaster172.16.10.250 yqbf原备份脚本:$RMAN target $TARGET_CONNECT_STR nocatalog msglog $RMAN_LOG_FILE append << EOFRUN {ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';send 'NB_ORA_CLIENT=SHYQ-PS-MV-SV03-POTLDB01-nbu';BACKUP$BACKUP_TYPESKIP INACCESSIBLETAG hot_db_bk_level0FILESPERSET 5# recommended formatFORMAT 'bk_%s_%p_%t'DATABASE;sql 'alter system archive log current';RELEASE CHANNEL ch00;加入后的脚本如下:BACKUP# recommended formatFORMAT '/oradata/rman_bak/controlfile/ portal_bak _%s_%p_%t'CURRENT CONTROLFILE;在节点POTLDB01成功备份后发现控制文件如下:root@POTLDB02:/usr/openv/rmanscript#ls -l /oradata/rman_bak/controlfiletotal 131072-rw-r----- 1 oracle 1001 13402112 Jul 28 11:38 portal_bak_25_1_757683479-rw-r----- 1 oracle 1001 13434880 Jul 28 11:36 portal_control_c-603295704-20110728-03 -rw-r----- 1 oracle 1001 13434880 Jul 28 11:38 portal_control_c-603295704-20110728-04 -rw-r----- 1 oracle dba 13434880 Jul 28 13:46 portal_control_c-603295704-20110728-05 -rw-r----- 1 oracle 1001 13402112 Jul 28 11:36 portaldb_controlfile_bak_23_1_757683366 获取DBIDSQL> select dbid from v$database;DBID----------603295704查看备份记录root@POTLDB01:/usr/openv/netbackup/bin#./bplist -C SHYQ-PS-MV-SV03-POTLDB01-nbu -S nbumaster -t 4 -R //c-603295704-20110728-02/cntrl_21_1_757683165/c-603295704-20110728-01/al_bk_19_1_757682964/c-603295704-20110728-00/bk_17_1_757682762/bk_16_1_757682227/bk_603295704_11_1_757680386/cntrl_10_1_757680271/al_bk_603295704_8_1_757680166/bk_603295704_7_1_757680069/bk_603295704_6_1_757679974/cntrl_5_1_757679319/al_4_1_757679223/bk_3_1_757679124/bk_2_1_757678789模拟数据库文件被删掉root@POTLDB01:/oradata/datafiles/portaldb#pwd/oradata/datafiles/portaldbroot@POTLDB01:/oradata/datafiles/portaldb#lsarchives control02.ctl redo101.log redo201.log redo301.log redo401.log redo501.log sysaux01.dbf temp01.dbf users01.dbfcontrol01.ctl control03.ctl redo102.log redo202.log redo302.log redo402.log redo502.log system01.dbf undotbs01.dbfroot@POTLDB01:/oradata/datafiles/portaldb#cd ../root@POTLDB01:/oradata/datafiles#lsportaldbroot@POTLDB01:/oradata/datafiles#lsportaldbroot@POTLDB01:/oradata/datafiles#mv portaldb portal_colroot@POTLDB01:/oradata/datafiles#mkdir portaldbroot@POTLDB01:/oradata/datafiles#cd portaldbroot@POTLDB01:/oradata/datafiles/portaldb#lsroot@POTLDB01:/oradata/datafiles/portaldb#mkdir archivesroot@POTLDB01:/oradata/datafiles/portaldb#chown –R oracle:dba /oradata/datafiles异机恢复到POTLDB02过程root@POTLDB02:/#lspvhdisk0 00c5c5666830b3fa rootvg active hdisk1 00c5c5666c01952b rootvg active hdisk2 00c5c5366a63d937 datavghdisk3 00c5c5366a65b992 hbvgroot@POTLDB02:/#varyonvg datavgroot@POTLDB02:/#mount /dev/data_lv /oradataroot@POTLDB02:/#su - oracleoracle@POTLDB02:/home/oracle$sqlplus /nologconnSQL*Plus: Release 11.1.0.7.0 - Production on Thu Jul 28 13:32:28 2011Copyright (c) 1982, 2008, Oracle. All rights reserved.SQL> /as sysdba;Connected to an idle instance.SQL>SQL>SQL>SQL> exitDisconnectedoracle@POTLDB02:/home/oracle$rman target /Recovery Manager: Release 11.1.0.7.0 - Production on Thu Jul 28 13:32:49 2011 Copyright (c) 1982, 2007, Oracle. All rights reserved.connected to target database (not started)RMAN> startup nomount;Oracle instance startedTotal System Global Area 43025158144 bytesFixed Size 2156784 bytesVariable Size 20669531920 bytesDatabase Buffers 22280142848 bytesRedo Buffers 73326592 bytesRMAN> set dbid=603295704executing command: SET DBIDRMAN> restore controlfile from '/oradata/rman_bak/controlfile/portal_bak_25_1_757683479';Starting restore at 28-JUL-11using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=2188 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/oradata/datafiles/portaldb/control01.ctloutput file name=/oradata/datafiles/portaldb/control02.ctloutput file name=/oradata/datafiles/portaldb/control03.ctlFinished restore at 28-JUL-11RMAN> alter database mount;database mountedRMAN>RMAN>RMAN> run2> {3> allocate channel t1 type 'sbt_tape' parms 'ENV=(NB_ORA_SERVER=nbumaster,NB_ORA_CLIENT=SHYQ-PS-MV-SV03-POTLDB01-nbu)';4> allocate channel t2 type 'sbt_tape' parms 'ENV=(NB_ORA_SERVER=nbumaster,NB_ORA_CLIENT=SHYQ-PS-MV-SV03-POTLDB01-nbu)';5> restore database;6> switch datafile all;7> recover database;8> sql 'alter database open resetlogs';9> release channel t1;10> release channel t2;11> }allocated channel: t1channel t1: SID=2187 device type=SBT_TAPEchannel t1: Veritas NetBackup for Oracle - Release 6.5 (2009050106)allocated channel: t2channel t2: SID=2188 device type=SBT_TAPEchannel t2: Veritas NetBackup for Oracle - Release 6.5 (2009050106)Starting restore at 28-JUL-11channel t1: starting datafile backup set restorechannel t1: specifying datafile(s) to restore from backup setchannel t1: restoring datafile 00001 to /oradata/datafiles/portaldb/system01.dbfchannel t1: restoring datafile 00002 to /oradata/datafiles/portaldb/sysaux01.dbfchannel t1: restoring datafile 00003 to /oradata/datafiles/portaldb/undotbs01.dbfchannel t1: restoring datafile 00004 to /oradata/datafiles/portaldb/users01.dbfchannel t1: reading from backup piece bk_16_1_757682227channel t1: piece handle=bk_16_1_757682227 tag=HOT_DB_BK_LEVEL0channel t1: restored backup piece 1channel t1: restore complete, elapsed time: 00:03:55Finished restore at 28-JUL-11Starting recover at 28-JUL-11starting media recoverychannel t1: starting archived log restore to default destinationchannel t1: restoring archived logarchived log thread=1 sequence=11channel t1: restoring archived logarchived log thread=1 sequence=12channel t1: reading from backup piece al_bk_19_1_757682964channel t1: piece handle=al_bk_19_1_757682964 tag=TAG20110728T112924channel t1: restored backup piece 1channel t1: restore complete, elapsed time: 00:01:25archived log file name=/oradata/datafiles/portaldb/archives/1_11_756554328.dbf thread=1 sequence=11 archived log file name=/oradata/datafiles/portaldb/archives/1_12_756554328.dbf thread=1 sequence=12 unable to find archived logarchived log thread=1 sequence=13released channel: t1released channel: t2RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 07/28/2011 13:44:17RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 13 and starting SCN of 436680RMAN> alter database open;RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 07/28/2011 13:45:00ORA-01589: must use RESETLOGS or NORESETLOGS option for database open RMAN> sql 'alter database open resetlogs';sql statement: alter database open resetlogs成功检查oracle@POTLDB02:/home/oracle$sqlplus /nologSQL*Plus: Release 11.1.0.7.0 - Production on Thu Jul 28 14:04:12 2011Copyright (c) 1982, 2008, Oracle. All rights reserved.SQL> conn /as sysdba;Connected.SQL>SQL>SQL> select status,instance_name from v$instance;STATUS INSTANCE_NAME------------ ----------------OPEN portaldbSQL>。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
storage@NBU 异机恢复ORACLE基本步骤1、在主备份服务器上创建文件:#mkdir /usr/openv/netbackup/db/altnames#touch /usr/openv/netbackup/db/altnames/No.Restrictions注意文件名称中的大小写2、在需要恢复的主机上安装好ORACLE数据库以及NBU软件(包括Client 端软件以及Oracle agent软件),并且创建一个Oracle用户,注意该用户的名称和所属的组都要和原备份主机上的用户一致。
(本文档假设用户名为oracle)注意在此步骤中最好将原主机上创建过的一些文件目录或系统都创建好,需要mount好的文件系统也挂接好。
注意各文件系统以及创建目录的属性,将属主都更改为Oracle用户。
另外如果可能,最好将原主机上的oracle用户的.profile文件拷贝到当前oracle用户的主目录下。
3、通过NBU将原主机上备份的controlfile文件恢复到新主机上的指定位置(可以检查init<SID>.ora文件来确定文件位置)通过使用NBU的图形界面,可将controlifle恢复到新主机的指定位置上。
4、在新主机上启动数据库:#su - oracle$sqlplus "/as sysdba"sql>shutdown immediate;sql>startup mount;sql>exit;storage@5、使用nocatalog方式连接到目标数据库并执行恢复语句:#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>restore database;3>release channel ch00;4>}RMAN>exit对数据库进行recover恢复,并启动数据库。
注意在做此步骤前,要先检查原主机上是否有没有备份的archive log,如果有则拷贝到新的主机上。
#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>recover database;3>release channel ch00;4>}RMAN>alter database open resetlogs;RMAN>exit6、在数据库恢复完毕后,立刻对新的数据库进行一次全备份操作7、本文档的例子都是使用nocatalog方式。
如果用户是使用catalog方式,则需要注意两点:a、数据库连接方式不同。
使用catalog方式的时候,需要使用语句rman target / rcvcat [catalog库的监听器]来进行数据库的连接b、恢复controlfile的方式不同,通过如下脚本恢复:1、确保数据库已经停止,然后将数据库启动到nomount状态:#su - oracle$sqlplus "/as sysdba"sql>shutdown immediate;sql>startup nomount;sql>exit;storage@2、连接到catalog库,进行controlfile的恢复#su - oracle$rman target / rcvcat [catalog库的监听器]RMAN>run {1>allocate channel ch00 type 'sbt_tape';2>restore controlfile;3>release channel ch00;4>}RMAN>exit3、对数据库进行recover恢复,并启动数据库#su - oracle$rman target / rcvcat [catalog库的监听器]RMAN> alter database mount;RMAN>run {1>allocate channel ch00 type 'sbt_tape';2>recover database;3>release channel ch00;4>}RMAN>alter database open resetlogs;RMAN>exitstorage@附录:一些特殊情况下的恢复a、恢复后的数据库中库文件位置和原位置不同,或名称不同run {set newname for datafile 1 to '/data/data1.dbf';set newname for datafile 2 to '/data/data2.dbf';…restore database;switch datafile all;recover database;sql 'alter database open resetlogs';}通过使用set … for ..to语句将原库文件名称修改为新的库文件名称。
b、如果确认全部archive log都已用完,而recover仍提示需下一个archive log,或alter database openresetlogs时提示datafile1 need recover,可采用以下步骤#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2> recover database using backup controlfile until cancel;3>release channel ch00;4>}在脚本运行过程中根据提示,输入cancel <回车>脚本运行结束后使用命令alter database open resetlogs;启动数据库c、如果不是恢复到最新,而是恢复到某一时刻,rman脚本如下#su – oracle$rman target / nocatalogrun {allocate channel t1 type 'sbt_tape';set until time "to_date('06/30/02 13:00:00','MM/DD/YY HH24:MI:SS')"restore database;recover database;sql 'alter database open resetlogs';}d、恢复单个的数据文件:1、确保数据库已经停止,然后将数据库启动到mount状态:#su - oracle$sqlplus "/as sysdba"storage@sql>shutdown immediate;sql>startup mount;sql>exit;2、连接到catalog库,进行datafile的恢复#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>restore datafile ‘具体的datafile名称’;3>release channel ch00;4>}RMAN>exit3、对数据文件进行recover恢复,并启动数据库#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>recover datafile ‘具体的datafile名称’;3>release channel ch00;4>}RMAN>alter database open ;RMAN>exite、恢复单独的tablespace1、确保数据库已经停止,然后将数据库启动到mount状态:#su - oracle$sqlplus "/as sysdba"sql>shutdown immediate;sql>startup mount;sql>exit;2、连接到catalog库,进行tablespace的恢复#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>restore tablespace ‘具体的tablespace名称’;3>release channel ch00;4>}storage@RMAN>exit3、对数据表空间进行recover恢复,并启动数据库#su - oracle$rman target / nocatalogRMAN>run {1>allocate channel ch00 type 'sbt_tape';2>recover tablespace ‘具体的datafile名称’;3>release channel ch00;4>}RMAN>alter database open ;RMAN>exit。