• 35.09 KB
  • 14页

netbackup for oracle 异机恢复 实施手册

  • 14页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
'通过rman从NBU备份恢复ORACLE环境:redhat4asupdate7NUB6.5.2Oracle10.2.0.1ORACLESID====LJYNBUMasterServer:ljy_nbu7恢复的源机器名:oracle10a恢复的目标机器名:oracledest1.安装database1.1.设置oracle用户及安装目录/usr/sbin/groupaddoinstall/usr/sbin/groupadddba/usr/sbin/useradd-m-goinstall-Gdbaoraclemkdir-p/u01/app/oraclemkdir-p/u02/oradatachown-Roracle:oinstall/u01/app/oracle/u02/oradatachmod-R775/u01/app/oracle/u02/oradata1.2.更改主机配置文件i.Root用户vi/etc/sysctl.confkernel.shmall=2097152kernel.shmmax=2147483648kernel.shmmni=4096kernel.sem=25032000100128fs.file-max=65536net.ipv4.ip_local_port_range=102465000net.core.rmem_default=1048576 net.core.rmem_max=1048576net.core.wmem_default=262144net.core.wmem_max=262144vi/etc/security/limits.conforaclesoftnproc2047oraclehardnproc16384oraclesoftnofile1024oraclehardnofile65536vi/etc/pam.d/loginsessionrequired/lib/security/pam_limits.sosessionrequiredpam_limits.sovi/etc/profileif[$USER="oracle"];thenif[$SHELL="/bin/ksh"];thenulimit-p16384ulimit-n65536elseulimit-u16384-n65536fifii.oracle用户su-oraclevi./.bash_profileORACLE_BASE=/u01/app/oracleORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1ORACLE_SID=LJYexportORACLE_HOMEORACLE_BASEORACLE_SIDPATH=$PATH:$HOME/bin:$ORACLE_HOME/bin安装libaio在第4张光盘。否则安装oracle检测出错。 1.1.安装oracle应用程序su-oracle安装oracle应用程序1.安装NBUClientsu-root安装ICSbpx安装NBUClient安装DatabaseAgentfororaclesu-oracle运行oracle_link脚本:/usr/openv/netbackup/bin/oracle_link如果是NBUServer修改bp.conf文件加入:server=ljy_nbu72.instance初始化配置注意:如果有RmanCatalogDB,需要修改tnsnames.ora 文件已建立与RMANcatalog之间的连接2.1.创建Pfile:initLJY.ora文件注:可从其它地方拷贝一个文件更改即可更改文件中各个的路径信息。background_dump_dest=$HOME/ADMIN/BDUMPcompatible=10.2.0.1.0 control_files=$HOME/ORADATA/u01/ctrl_01_sid.ctlcore_dump_dest=$HOME/ADMIN/CDUMPdb_block_size=4096db_cache_size=4Mdb_domain=’’db_name=LJYinstance_name=LJYmax_dump_file_size=10240remote_login_passwordfile=exclusiveservice_names=db01shared_pool_size=8Mundo_management=AUTOuser_dump_dest=$HOME/ADMIN/UDUMP1.1.创建目录创建oracle恢复的必要目录,并设置权限1.1.1.dump目录mkdir-p./admin/LJY/adumpmkdir-p./admin/LJY/bdumpmkdir-p./admin/LJY/cdumpmkdir-p./admin/LJY/udump1.1.2.创建数据文件目录/data/LJY2.查看oracle备份情况2.1.Maserserver上查看备份文件记录su-root./bplist-Coracle10a-t4-l-R/-rw-rw----oracledba7340032Jun2700:06c-2093589112-20110627-02:-rw-rw----oracledba7340032Jun2700:06cntrl_402_1_754877157: -rw-rw----oracledba7340032Jun2700:05c-2093589112-20110627-01:-rw-rw----oracledba262144Jun2700:05al_400_1_754877102:-rw-rw----oracledba69468160Jun2700:05al_399_1_754877102:-rw-rw----oracledba7340032Jun2700:04c-2093589112-20110627-00:-rw-rw----oracledba262144Jun2700:03bk_397_1_754877037:-rw-rw----oracledba524288Jun2700:03bk_396_1_754877037:-rw-rw----oracledba21495808Jun2700:03bk_394_1_754877001:-rw-rw----oracledba262144Jun2700:03bk_395_1_754877001:-rw-rw----oracledba262144Jun2700:02bk_393_1_754876956:-rw-rw----oracledba23330816Jun2700:02bk_392_1_754876956:-rw-rw----oracledba262144Jun2700:01bk_391_1_754876881:-rw-rw----oracledba262144Jun2700:01bk_390_1_754876865:-rw-rw----oracledba262144Jun2623:57bk_389_1_754876670:-rw-rw----oracledba3670016Jun2623:57bk_388_1_754876670:-rw-rw----oracledba7340032Jun2600:07c-2093589112-20110626-02:-rw-rw----oracledba7340032Jun2600:06cntrl_386_1_754790809:1.1.修改NBU异机恢复授权文件1)方法一在Netbackupmasterserver上创建install_pathNetBackupdbaltnamesNo.Restrictions2)方法2严格限制恢复机器的名称:linstall_pathNetBackupdbaltnamesclient_nameclient_name:目标机器,恢复的目的地l将源机器名加入到此文件中例如:destination_client_name:恢复的目标机器名,例如:d1source_client_name:源机器名,即备份数据的主机名,例如:s1在install_pathNetBackupdbaltnames目录下创建文件名为d1的空文件,编辑此空文件加入源机器名,例如:s1 1.通过rman恢复数据库1.1.启动到nomount状态./rmantarget/startupnomountpfile="/u01/app/oracle/product/10.2.0/db_1/dbs/initLJY.ora";1.2.恢复controlfilerun{allocatechannelch1type"sbt_tape";SEND"NB_ORA_SERV=ljy_nbu7,NB_ORA_CLIENT=oracle10a";restorecontrolfilefrom"/cntrl_402_1_754877157";releasechannelch1;}1.3.Mountdatabasealterdatabasemount;1.4.恢复databaserun{ALLOCATECHANNELch00TYPE"SBT_TAPE";restoredatabase;recoverdatabase;RELEASECHANNELch00;}1.5.打开数据库alterdatabaseopenresetlogs; 1.完成2.创建、配置、启动监听器lsnrctlstart配置归档模式shutdownimmediate;startupmount;ALTERDATABASEARCHIVELOG;alterdatabaseopen;3.附录1:oracle管理3.1.oracle的常用启动与关闭1,启动isqlplus服务端口:5560isqlplusctlstart//启动isqlplusctlstop//停止2,启动数据库dbstartdbshut3,开启企业管理器端口:1158emctlstartdbconsoleemctlstopdbconsole4,启动监听lsnrctlstartlsnrctlstop5,开启代理emctlstartagentemctlstopagent6,启动实例sqlplus/nologconn/assysdba startup//启动实例shutdownimmediate//关闭实例7,tnsping192.168.111.210//测试Oracle数据库是否通8,http://192.168.111.210:5560/isqlplus/dba//isQL*PlusDBAURL9,http://192.168.111.210:1158/em//EnterpriseManager10gDatabaseControl1.1.Oracle时间参数设置showparameterNLS_DATE_FORMATaltersessionsetNLS_DATE_FORMAT="YYYY-MM-DDHH24:MI:SS";setuntiltime=’2010-01-1211:44:00’;sql"altersessionsetnls_date_format="DD-MON-YYYYHH24:MI:SS"";run{setuntiltime"19-MAR-200517:00:00";recovertablespacemarcus;}2.附录2:连接catalogDB恢复%rmancatalogrman/rman@rcatRMAN>setdbid=connecttarget/RMAN>run{RMAN>ALLOCATECHANNELCH00TYPE"SBT_TAPE";RMAN>SEND"NB_ORA_SERV=lion,NB_ORA_CLIENT=camel";RMAN>restorecontrolfile;RMAN>}SQL>alterdatabasemount;%orapwdfile=$ORACLE_HOME/dbs/orapwtestpassword=%rmancatalogrman/rman@RCVCAT RMAN>setdbid=RMAN>connecttarget/RMAN>run{RMAN>ALLOCATECHANNELCH00TYPE"SBT_TAPE";RMAN>ALLOCATECHANNELCH01TYPE"SBT_TAPE";RMAN>SEND"NB_ORA_SERV=lion,NB_ORA_CLIENT=camel";RMAN>restoredatabase;RMAN>restorearchivelogall;RMAN>}SQL>recoverdatabaseuntilcancelusingbackupcontrolfile;Nowapplythearchivedlogs.Type cancel whenyoudecidetostoprecovery.Run rman.rmanrcvcatrman/rman@rcatRecoveryManager:Release8.0.5.0.0-ProductionRMAN>@restore_database.rcvwhere restore_database.rcv istheRMANscriptthatcontainstherestorecommands.:run{#AllocatestapechannelandsetsRMANenvironmentvariableallocatechannelt1type"SBT_TAPE"parms="ENV=(NB_ORA_CLIENT=camel,NB_ORA_SERV=lion)";restore(database);restorecontrolfileto"D:orant805databasectl1TEST.ora";releasechannelt1;}1.查看oracle进程$ps-ef|grepora_oracle972110Jun2?0:19ora_qmnc_appsoracle278691011:46:55?0:00ora_mmnl_me oracle292161013:34:21?0:00ora_j000_appsoracle278591011:46:55?0:00ora_ckpt_meoracle278511011:46:55?0:00ora_mman_meoracle969510Jun2?1:28ora_lgwr_appsoracle2928929280013:35:20pts/tc0:00grepora_oracle970910Jun2?0:01ora_d000_appsoracle969110Jun2?1:05ora_dbw0_appsoracle973010Jun2?0:21ora_q000_appsoracle969910Jun2?1:27ora_smon_appsoracle278471011:46:53?0:01ora_pmon_meoracle968510Jun2?4:09ora_pmon_appsoracle278611011:46:55?0:00ora_smon_meoracle278491011:46:55?0:00ora_psp0_meoracle278651011:46:55?0:00ora_cjq0_meoracle970110Jun2?0:04ora_reco_appsoracle970710Jun2?7:08ora_mmnl_appsoracle971710Jun2?0:21ora_arc1_appsoracle971110Jun2?0:02ora_s000_appsoracle971510Jun2?0:06ora_arc0_appsoracle278711011:46:55?0:00ora_d000_meoracle968710Jun2?1:27ora_psp0_appsoracle278631011:46:55?0:00ora_reco_meoracle278551011:46:55?0:00ora_dbw1_meoracle968910Jun2?0:24ora_mman_appsoracle970510Jun2?3:03ora_mmon_appsoracle973210Jun2?0:13ora_q001_appsoracle969710Jun2?6:23ora_ckpt_appsoracle278731011:46:55?0:00ora_s000_meoracle278531011:46:55?0:00ora_dbw0_meoracle969310Jun2?0:57ora_dbw1_appsoracle970310Jun2?5:14ora_cjq0_appsoracle278571011:46:55?0:00ora_lgwr_meoracle278671011:46:55?0:00ora_mmon_meRMAN>run{setALLOCATECHANNELch00TYPE"SBT_TAPE";send"NB_ORA_SERV=gz-bk02,NB_ORA_CLIENT=gz-med01";setuntilscn255;recoverdatabase;} run{setnewnamefordatafile1to"/oradata/apps/me/system01.dbf";setnewnamefordatafile2to"/oradata/apps/me/undotbs01.dbf";setnewnamefordatafile3to"/oradata/apps/me/sysaux01.dbf";setnewnamefordatafile4to"/oradata/apps/me/users01.dbf";setnewnamefordatafile5to"/oradata/apps/me/conv_01.dbf";setnewnamefordatafile6to"/oradata/apps/me/convx_01.dbf";setnewnamefordatafile7to"/oradata/apps/me/eng_01.dbf";setnewnamefordatafile8to"/oradata/apps/me/engx_01.dbf";setnewnamefordatafile9to"/oradata/apps/me/fin_01.dbf";setnewnamefordatafile10to"/oradata/apps/me/finx_01.dbf";setnewnamefordatafile11to"/oradata/apps/me/global_01.dbf";setnewnamefordatafile12to"/oradata/apps/me/globalx_01.dbf";setnewnamefordatafile13to"/oradata/apps/me/hivol1_01.dbf";setnewnamefordatafile14to"/oradata/apps/me/hivol1x_01.dbf";setnewnamefordatafile15to"/oradata/apps/me/hivol2_01.dbf";setnewnamefordatafile16to"/oradata/apps/me/hivol2x_01.dbf";setnewnamefordatafile17to"/oradata/apps/me/hivol3_01.dbf";setnewnamefordatafile18to"/oradata/apps/me/hivol3x_01.dbf";setnewnamefordatafile19to"/oradata/apps/me/hivol4_01.dbf";setnewnamefordatafile20to"/oradata/apps/me/hivol4x_01.dbf";setnewnamefordatafile21to"/oradata/apps/me/hivol5_01.dbf";setnewnamefordatafile22to"/oradata/apps/me/hivol5x_01.dbf";setnewnamefordatafile23to"/oradata/apps/me/inv_01.dbf";setnewnamefordatafile24to"/oradata/apps/me/invx_01.dbf";setnewnamefordatafile25to"/oradata/apps/me/plan1_01.dbf";setnewnamefordatafile26to"/oradata/apps/me/plan1x_01.dbf";setnewnamefordatafile27to"/oradata/apps/me/plan2_01.dbf";setnewnamefordatafile28to"/oradata/apps/me/plan2x_01.dbf";setnewnamefordatafile29to"/oradata/apps/me/plan3_01.dbf";setnewnamefordatafile30to"/oradata/apps/me/plan3x_01.dbf";setnewnamefordatafile31to"/oradata/apps/me/prod_01.dbf";setnewnamefordatafile32to"/oradata/apps/me/prodx_01.dbf";setnewnamefordatafile33to"/oradata/apps/me/sales_01.dbf";setnewnamefordatafile34to"/oradata/apps/me/salesx_01.dbf";setnewnamefordatafile35to"/oradata/apps/me/techr_01.dbf";setnewnamefordatafile36to"/oradata/apps/me/techr_02.dbf";setnewnamefordatafile37to"/oradata/apps/me/techrx_01.dbf";setnewnamefordatafile38to"/oradata/apps/me/techrx_02.dbf";setnewnamefordatafile39to"/oradata/apps/me/techr2_01.dbf";setnewnamefordatafile40to"/oradata/apps/me/techr2_02.dbf"; setnewnamefordatafile41to"/oradata/apps/me/techrx2_01.dbf";setnewnamefordatafile42to"/oradata/apps/me/techrx2_02.dbf";setnewnamefordatafile43to"/oradata/apps/me/IMAGES01.dbf";setnewnamefordatafile44to"/oradata/apps/me/MPTAB.dbf";setnewnamefordatafile45to"/oradata/apps/me/MP_IDX.dbf";setnewnamefordatafile46to"/oradata/apps/me/reports_01.dbf";setnewnamefordatafile47to"/oradata/apps/me/INTF.dbf";setnewnamefordatafile48to"/oradata/apps/me/INTF_IDX.dbf";ALLOCATECHANNELch00TYPE"SBT_TAPE";send"NB_ORA_SERV=gz-bk02,NB_ORA_CLIENT=gz-med01";restoredatabase;switchdatafileall;}RMAN>run{2>ALLOCATECHANNELch00TYPE"SBT_TAPE";3>send"NB_ORA_SERV=gz-bk02,NB_ORA_CLIENT=gz-med01";4>restorearchivelogSEQUENCEbetween250and255;5>RMAN>run{2>ALLOCATECHANNELch00TYPE"SBT_TAPE";3>send"NB_ORA_SERV=gz-bk02,NB_ORA_CLIENT=gz-med01";4>sql"alterdatabaserenamefile""/oradata/me/redo03.log""to""/oradata/apps/me/redo03.log""";5>sql"alterdatabaserenamefile""/oradata/me/redo02.log""to""/oradata/apps/me/redo02.log""";6>sql"alterdatabaserenamefile""/oradata/me/redo01.log""to""/oradata/apps/me/redo01.log""";7>}selectnamefromv$datafile;selectmemberfromv$logfile;selectnamefromv$tempfileselectsequence#,namefromv$archived_logrun{setnewnamefordatafile1to"adsf/asdfsd/*.dbf" setnewnamefordatafile1to"adsf/asdfsd/*.dbf"setnewnamefordatafile1to"adsf/asdfsd/*.dbf"sql""alterdatabaserenamefiletoredo1.logsql""alterdatabaserenamefiletoredo3.logsql""alterdatabaserenamefiletoredo2.logallocatesbt_taperestoreswitchdatafileall;}restorearvhivelogsequencebetween222and555;1.Oracle使用1.1.将sqlplus操作输出到文件:spool setechooff          --是否显示执行的命令内容 setfeedbackoff      --是否显示*  rows  selected setheadingoff       --是否显示字段的名称setverifyoff        --是否显示替代变量被替代前后的语句。filsettrimspooloff     --去字段空格setpagesize500      --页面大小setlinesize1024      --linesize设定尽量根据需要来设定,大了生成的文件也大definefile="f:user.xls"prompt***Spoolingto&filspool&filselectu.username,u.userpwd,u.realname,u.sex,u.mobile,d.dep_namefromt_useruleftjoint_deptdonu.dept_id=d.dep_id;spooloff;看个例子:将select*fromemploees;的结果导出到c:filename.ext文件1、将下面保存为unloadata文件set  feedback  offset  pagesize  0set  term  offspool  c:filename.extselect*fromemploees;spool  off  2、执行@e:unloadata@命令的使用格式:@完整路径名/文件名(这里的文件名要指定完整的路径,默认的扩展名是.sql,如果脚本文件使用了默认的扩展名,则在@命令中可以省略扩展名。)1.1.重要表1.1.1.查询字典Select*fromdictionarywheretable_name=’’1.1.2.查看参数配置SHOWPARAMETERSHOWPARAMETERSSHOWPARAMETERCONTROL_FILESV$PARAMETER1.1.3.查看数据库版本Select*FROMV$VERSION'