1、建立连接[root@localhost~]#su-oracle[oracle@localhost~]$cd/usr/openv/netbackup/bin[oracle@localhostbin]$./oracle_link2012年08月25日星期六09:43:28CSTAllOracleinstancesshouldbeshutdownbeforerunningthisscript.PleaselogintotheUnixsystemastheOracleownerforrunningthisscriptDoyouwanttocontinue?(y/n)[n]yLIBOBKpath:/usr/openv/netbackup/binORACLE_HOME:/orcl/oracleOracleversion:10.2.0.1.0Platformtype:i686LinkingLIBOBK:ln-s/usr/openv/netbackup/bin/libobk.so/orcl/oracle/lib/libobk.soDonePleasecheckthetracefilelocatedin/tmp/make_trace.4459tomakesurethelinkingprocesswassuccessful.2、创建备份脚本[root@localhost~]#mkdir-p/usr/openv/netbackup/script[root@localhost~]#cd/usr/openv/netbackup/ext/db_ext/oracle/samples/rman[root@localhostrman]#lscold_database_backup.shdatabase_restore.shhot_tablespace_backup.shcold_duplex_database_backup_full.shhot_database_backup.shpit_database_restore.sh[root@localhostrman]#cphot_database_backup.sh/usr/openv/netbackup/script/[root@localhostrman]#cd/usr/openv/netbackup/script/[root@localhostscript]#lshot_database_backup.sh[root@localhostscript]#mvhot_database_backup.shrman.sh[root@localhostscript]#chmodo+xrman.sh[root@localhostscript]#virman.sh#!/bin/sh#$Header:hot_database_backup.sh,v1.22002/08/0623:51:42$##bcpyrght#***************************************************************************#*$VRTScprght:Copyright1993-2008SymantecCorporation,AllRightsReserved$*#***************************************************************************#ecpyrght##---------------------------------------------------------------------------#hot_database_backup.sh#---------------------------------------------------------------------------#ThisscriptusesRecoveryManagertotakeahot(inconsistent)database#backup.Ahotbackupisinconsistentbecauseportionsofthedatabaseare#beingmodifiedandwrittentothediskwhilethebackupisprogressing.#YoumustrunyourdatabaseinARCHIVELOGmodetomakehotbackups.Itis#assumedthatthisscriptwillbeexecutedbyuserroot.InorderforRMAN#toworkproperlyweswitchuser(su-)totheoracledbaaccountbefore#execution.IfthisscriptrunsunderauseraccountthathasOracledba#privilege,itwillbeexecutedusingthisuser'saccount.#---------------------------------------------------------------------------#---------------------------------------------------------------------------#Determinetheuserwhichisexecutingthisscript.#---------------------------------------------------------------------------CUSER=`id|cut-d(-f2|cut-d)-f1`#---------------------------------------------------------------------------#Putoutputinthisfilename.out.Changeasdesired.#Note:outputdirectoryrequireswritepermission.#---------------------------------------------------------------------------RMAN_LOG_FILE=${0}.out#---------------------------------------------------------------------------#Youmaywanttodeletetheoutputfilesothatbackupinformationdoes#notaccumulate.Ifnot,deletethefollowinglines.#---------------------------------------------------------------------------if[-f$RMAN_LOG_FILE]thenrm-f$RMAN_LOG_FILEfi#-----------------------------------------------------------------#Initializethelogfile.#-----------------------------------------------------------------echo$RMAN_LOG_FILEchmod666$RMAN_LOG_FILE#---------------------------------------------------------------------------#Logthestartofthisscript.#---------------------------------------------------------------------------echoScript$0$RMAN_LOG_FILEecho====startedon`date`====$RMAN_LOG_FILEecho$RMAN_LOG_FILE#---------------------------------------------------------------------------#Replace/db/oracle/product/ora81,below,withtheOraclehomepath.#---------------------------------------------------------------------------ORACLE_HOME=/u01/app/oracle/product/11.2.0/exportORACLE_HOMEOracleHOME目录,可通过env命令查出#---------------------------------------------------------------------------#Replaceora81,below,withtheOracleSIDofthetargetdatabase.#---------------------------------------------------------------------------ORACLE_SID=orclexportORACLE_SIDOracle实例名#---------------------------------------------------------------------------#Replaceora81,below,withtheOracleDBAuserid(account).#---------------------------------------------------------------------------ORACLE_USER=oracleOracle系统账户#---------------------------------------------------------------------------#Setthetargetconnectstring.#Replacesys/manager,below,withthetargetconnectstring.#---------------------------------------------------------------------------TARGET_CONNECT_STR=sys/Qweasd123Sys用户及其密码#---------------------------------------------------------------------------#SettheOracleRecoveryManagername.#---------------------------------------------------------------------------RMAN=$ORACLE_HOME/bin/rman#---------------------------------------------------------------------------#Printoutthevalueofthevariablessetbythisscript.#---------------------------------------------------------------------------#中间代码不用更改,此处略CMD_STR=ORACLE_HOME=$ORACLE_HOMEexportORACLE_HOMEORACLE_SID=$ORACLE_SIDexportORA