免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2708 | 回复: 4
打印 上一主题 下一主题

[Veritas NBU] nbu for oracle方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-11 22:34 |只看该作者 |倒序浏览
NetBackup Database Agent Installation

Choose the Database Agents you wish to install
one at a time or select Install All Database Agents.

         1)   NetBackup for DB2
         2)   NetBackup for Informix
         3)   NetBackup for Lotus Notes
         4)   NetBackup for Oracle
         5)   NetBackup for SAP
         6)   NetBackup for Sybase

         7)   Install All Database Agents

         q)   Done Selecting Agents
         x)   Exit from this Script

     Select the Oracle option if upgrading any of the
     following:   Oracle, Oracle on UNIX Advanced BLI Agent,
     Oracle ServerFree Agent or Database Archiver.
     The packages have been combined.

Choose an option: 4


Choose an option: q


You have chosen to install these Database Agents:

         NetBackup for Oracle

Is this list correct? [y,n] (y)

**********


Of the agents selected, the following are supported
on this platform and will be installed:

         Oracle

Loading the Database Agent packages into the
/usr/openv/netbackup/dbext directory and installing.


**********

         Installing NetBackup for Oracle



    Installing NetBackup for Oracle...

Extracting files from /usr/openv/netbackup/dbext/OEBU.linux2.4.tar.Z ...
usr/openv/netbackup/
usr/openv/netbackup/bin/
usr/openv/netbackup/bin/bpubsora
usr/openv/netbackup/bin/libobk.so
usr/openv/netbackup/bin/oracle_link
usr/openv/netbackup/bin/bporaexp
usr/openv/netbackup/bin/bporaimp
usr/openv/netbackup/bin/bpdbsbora
usr/openv/netbackup/dbext/
usr/openv/netbackup/dbext/OEBU.linux2.4.version
usr/openv/netbackup/ext/
usr/openv/netbackup/ext/db_ext/
usr/openv/netbackup/ext/db_ext/oracle/
usr/openv/netbackup/ext/db_ext/oracle/samples/
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/cold_database_backup.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/cold_duplex_database_backup_full.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/database_restore.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_database_backup.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_tablespace_backup.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/rman/pit_database_restore.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/data_archiver_export.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/data_archiver_export64.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_help.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_partitions.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_table_to_files.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_tables.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaexp/bporaexp_tables_rows.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/data_archiver_import.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/data_archiver_import64.sh
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive_schema_to_files.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_archive_to_users.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_bfile_table.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_help.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_ignore_rows_table.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_large_table.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_list.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_old_archive.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_partitions.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_from_files.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_to_files.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_table_to_user.param
usr/openv/netbackup/ext/db_ext/oracle/samples/bporaimp/bporaimp_tables.param
usr/openv/lib/
usr/openv/lib/libbpora.so.8.0
usr/openv/lib/libbpora.so.9.0
usr/openv/lib/libnbberman.so
usr/openv/lib/libdbsbrman.so
NetBackup for Oracle installation completed.
*********
Execution of ./install_dbext is complete.
Execution of ./install is complete.
File /tmp/install_options_trace.4426 contains a trace of this install.
VERITAS Installation Script
Copyright 1993 - 2004 VERITAS Software Corporation, All Rights Reserved.

         Installation Options

         1 NetBackup Add-On Product Software
         2 NetBackup Database Agent Software

         q To quit from this script
Choose an option [default: q]: q

A trace of the install can be found in /tmp/install_options_trace.4426
That file can be deleted after you are sure the install was successful.

安装脚本将libobk.so链接库装在/usr/openv/netbackup/bin目录下
执行(/usr/openv/netbackup/bin/oracle_link)



2.数据库link
#su – oracle
$/usr/openv/netbackup/bin/oracle_link
Fri Jun 24 00:41:55 CST 2005
All Oracle instances should be shutdown before running this script.
Please log into the Unix system as the Oracle owner for running this script
Do you want to continue? (y/n) [n]   y
LIBOBK_PATH: /usr/openv/netbackup/bin
O_HOME: /oracle/product/10.1.0
O_VERSION: 10.1.0.3.0
linking Oracle v10.1.0.3.0 for Linux RedHat
ln -s /usr/openv/netbackup/bin/libobk.so /oracle/product/10.1.0/lib/libobk.so
Done

3.数据库修改archive log模式

#su – oracle
$sqlplus ‘/ as sysdba’
sqlplus>alter system set log_archive_dest=’/oradata/tadsfmp/arch’;
sqlplus>shutdown immediate
sqlplus>startup mount
sqlplus>alter database archivelog;
sqlplus>alter database open;


确认archiver处于自动运行状态,如果是manual状态,执行archive log start
不过Oracle 10g里面已经把这个鸡肋功能给去掉了,所以就不需要这一步

2.1创建备份策略
1,在NetBackup Master Server上,创建一个新的备份策略, 取名oracle_backup_policy;

2,输入新策略的名称后,按确定,会提示配置一个完整备份策略的第一部分‘Attributes’;

其中:
策略类型Policy type选择Oracle;
在‘Policy storage unit’中选择需使用的存储单元;
在‘Policy volume pool’中选择已分配用来备份oracle数据的volume pool;
并打勾选中Limit jobs per policy,然后输入99,其它默认不变;

3,点击转向‘Clients’页面

点击‘New’来添加一个客户端,输入客户端的名称,也就是需要备份的那台oracle服务器的主机名,选择好主机类型,然后点击OK按钮;

4,点击‘Files’页面,然后点击‘New’,来添加需要调用的Oracle备份脚本,输入备份脚本的全路径和脚本的文件名,然后点击‘Add’,如下图所示,注意备份脚本此时尚未创建,所以备份策略建立完毕后,需要创建备份脚本;


5,检查此路径和文件名无误后,点击‘Schedules’页面,然后点击‘New’,来添加一个备份时间计划,

在‘Name’中输入新建备份时间计划的名称,如‘ora_full’;在‘Retention’中选择备份内容的保存周期,在‘Frequency’中设定备份作业的执行频率;

转向页面‘Start Window’中设定需要备份的时间段,完成后点击OK。

如下图显示,在计划列表中已有一个‘Default-Application-Backup’的备份策略,此策略是Oracle Agent的执行策略,不可以随意修改或删除;

到此,备份策略已制定完毕;

2.3创建备份脚本
1,         创建备份脚本存放路径;
此路径应和之前创建备份策略时写的备份脚本路径一致。

2,复制脚本模板;
Oracle Agent安装完成后,备份的脚本模板会放在/usr/openv/netbackup/ext/db_ext/oracle/samples/rman下

[oracle@cluster02 rman]$ mv *.sh   ../..

3, 修改备份脚本,红色为修改部分

#!/bin/sh
# $Header: hot_tablespace_backup.sh,v 1.2 2002/11/20 00:47:43 $
#
#bcpyrght
#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2003 VERITAS Software Corporation, All Rights Reserved $ *
#***************************************************************************
#ecpyrght
#
# ---------------------------------------------------------------------------
#                           hot_tablespace_backup.sh
# ---------------------------------------------------------------------------
#   This script uses Recovery Manager to take a hot (inconsistent) tablespace
#   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}.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" ]
then
         rm -f "$RMAN_LOG_FILE"
fi

# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------

echo > $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE

# ---------------------------------------------------------------------------
# Log the start of this script.
# ---------------------------------------------------------------------------

echo Script $0 >> $RMAN_LOG_FILE
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE

# ---------------------------------------------------------------------------
# Replace /db/oracle/product/ora81, below, with the Oracle home path.
# ---------------------------------------------------------------------------

ORACLE_HOME=/oracle/product/10.1.0
export ORACLE_HOME
# ---------------------------------------------------------------------------
# Replace ora81, below, with the Oracle SID of the target database.
# ---------------------------------------------------------------------------

ORACLE_SID=ora10
export ORACLE_SID

# ---------------------------------------------------------------------------
# Replace ora81, below, with the Oracle DBA user id (account).
# ---------------------------------------------------------------------------

ORACLE_USER=oracle

# ---------------------------------------------------------------------------
# Replace productionDB, below, with the target database TNS alias (service)
# name from the tnsnames.ora file.
# ---------------------------------------------------------------------------

TARGET_TNS=oracle
export TARGET_TNS

# ---------------------------------------------------------------------------
# Replace rcvcatDB, below, with the recovery catalog database TNS alias
# (service) name from the tnsnames.ora file.
# ---------------------------------------------------------------------------

RCVCAT_TNS=oracle
export RCVCAT_TNS

# ---------------------------------------------------------------------------
# Set the rcvcat connect string.
# Replace "rman/rman", below, with the rcvcat connect string.
# ---------------------------------------------------------------------------

RCVCAT_CONNECT_STR=rman/rman

# ---------------------------------------------------------------------------
# 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_FILE
echo    "RMAN: $RMAN" >> $RMAN_LOG_FILE
echo    "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_FILE
echo    "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

# ---------------------------------------------------------------------------
# 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" ]
then
         echo "Full backup requested" >> $RMAN_LOG_FILE
         BACKUP_TYPE="INCREMENTAL LEVEL=0"

elif [ "$NB_ORA_INCR" = "1" ]
then
         echo "Differential incremental backup requested" >> $RMAN_LOG_FILE
         BACKUP_TYPE="INCREMENTAL LEVEL=1"

elif [ "$NB_ORA_CINC" = "1" ]
then
         echo "Cumulative incremental backup requested" >> $RMAN_LOG_FILE
         BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"

elif [ "$BACKUP_TYPE" = "" ]
then
         echo "Default - Full backup requested" >> $RMAN_LOG_FILE
         BACKUP_TYPE="INCREMENTAL LEVEL=0"
fi

# ---------------------------------------------------------------------------
# Call Recovery Manager to initiate the backup. This example uses a
# Recovery Catalog. If you do not want to use a recovery catalog, add the
# command 'nocatalog' to the rman command line below and remove 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.
# ---------------------------------------------------------------------------
#   This script backs up the system tablespace to tape and archives the
#   current log.
#
#   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.
#
#   Typically, a level 0 backup would be done at least once a week.
#
#   Oracle recommends that the current log be archived immediately after
#   performing any open (i.e. hot) backup to ensure that the backup is
#   immediately usable, even if the online log is lost.
#
#   The scenario assumes:
#      o you are backing your tablespace up to one tape drive
#      o you wish to include offline datafiles
#      o you want the backup to continue if any files are inaccessible.
#      o you are using a Recovery Catalog
#      o you want to archive the current log
#      o you are using TNS alias names for target and catalog databases
#
#   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_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
# $RMAN target $TARGET_CONNECT_STR@$TARGET_TNS rcvcat $RCVCAT_CONNECT_STR@$RCVCAT_TNS msglog $RMAN_LOG_FILE append << EOF
$RMAN target / nocatalog << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
BACKUP
     $BACKUP_TYPE
     SKIP INACCESSIBLE
     TAG hot_tbs_bk_level0_whole
     # recommended format
     FORMAT 'df_%s_%p_%t'
     TABLESPACE USERS;
#    sql 'alter system archive log current';
RELEASE CHANNEL ch00;
}EOF
"
# Initiate the command string

if [ "$CUSER" = "root" ]
then
     su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE
     RSTAT=$?
else
     /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
     RSTAT=$?
fi

# ---------------------------------------------------------------------------
# Log the completion of this script.
# ---------------------------------------------------------------------------

if [ "$RSTAT" = "0" ]
then
     LOGMSG="ended successfully"
else
     LOGMSG="ended in error"
fi

echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
exit $RSTAT
2.4手工执行备份策略
1,         如果需要临时手工发起备份作业,打开‘NetBackup Administration Concole’,在策略中点击需要执行的Policy Name,此方法可以检测备份策略配置的正确性;

2,         作业提交后,到Activity Monitor里面去查看作业状态,
3,         如果作业成功,大事告捷,如果失败且status为6,表明rman脚本有问题。。。
4.Rman脚本的log为${0}.out,里面详细记录rman执行情况。

论坛徽章:
0
2 [报告]
发表于 2010-07-12 09:23 |只看该作者
control file 怎么处理的?
按文件模式备份吗?

论坛徽章:
3
CU十二周年纪念徽章
日期:2013-10-24 15:41:34IT运维版块每日发帖之星
日期:2015-09-04 06:20:00数据库技术版块每日发帖之星
日期:2015-11-24 06:20:00
3 [报告]
发表于 2010-07-12 09:37 |只看该作者
{:3_191:}{:3_191:}这样的文档网上很多了,NBU。

论坛徽章:
0
4 [报告]
发表于 2010-07-12 11:00 |只看该作者
第一次做oracle的备份吧?

这脚本也不对
你找hot_database_backup.sh这个
你这个脚本是hot_tablespace_backup.sh的吧

error 6原因很多的。脚本有错只是一部分。

论坛徽章:
0
5 [报告]
发表于 2010-07-14 12:06 |只看该作者
仅仅备份tablespace?

CODE 6不仅仅是脚本问题,脚本只是一个方面。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP