使用TSM for Database备份Oracle数据库

使用TSM for Database备份Oracle数据库

TSM版本是6.2.1 平台是Windows 2003 32bit

TSM for Database 版本是 5.5.0

Oracle版本是10G R2,平台是 Redhat 5.3 32bit

整个环境都运行在 VMWare workstation 8.0.2

纯学习环境

 

配置Oracle 数据库启用RMAN备份

启用归档

[root@rhel5-ora ~]# su - oracle

[oracle@rhel5-ora ~]$ sqlplus / as sysdba

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1218968 bytes

Variable Size 88082024 bytes

Database Buffers 188743680 bytes

Redo Buffers 7168000 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 1

Next log sequence to archive 2

Current log sequence 2

SQL> select log_mode from v$database;

LOG_MODE

------------

ARCHIVELOG

 

Oracle10g之前,你还需要修改初始化参数使数据库处于自动归档模式。

在pfile/spfile中设置如下参数:

log_archive_start = true

重启数据库此参数生效,此时数据库处于自动归档模式。

 

创建rman数据库

使用dbca,创建rman catalog

clip_image002

clip_image003

如果catalog 与 目标数据库在同一台服务器,需要为catalog配置tnsname,不在同一台服务器也需要配置tnsname(我废话好多~~~)

 

为RMAN数据库创建表空间 创建用户 授权

[oracle@rhel5-ora ~]$ export ORACLE_SID=RMAN

[oracle@rhel5-ora ~]$ sqlplus / as sysdba

SQL> create tablespace rman_ts datafile '/u01/app/oracle/oradata/RMAN/rman01.dbf' size 150M extent management local uniform size 128K;

SQL> create user rman identified by rman default tablespace rman_ts quota unlimited on rman_ts;

SQL> grant recovery_catalog_owner to rman;

SQL> grant connect, resource to rman;

 

查看账号状态

SQL> select username,account_status from dba_users;

USERNAME ACCOUNT_STATUS

------------------------------ --------------------------------

MGMT_VIEW OPEN

SYS OPEN

SYSTEM OPEN

DBSNMP OPEN

SYSMAN OPEN

RMAN OPEN

OUTLN EXPIRED & LOCKED

MDSYS EXPIRED & LOCKED

ORDSYS EXPIRED & LOCKED

CTXSYS EXPIRED & LOCKED

ANONYMOUS EXPIRED & LOCKED

 

创建恢复目录

[oracle@rhel5-ora ~]$ export ORACLE_SID=RMAN

[oracle@rhel5-ora ~]$ rman catalog rman/rman

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Apr 10 10:58:00 2013

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to recovery catalog database

RMAN> create catalog tablespace rman_ts;

recovery catalog created

 

连接到目标数据库,注册目标数据库到恢复目录

[oracle@rhel5-ora ~]$ rman target sys/111111@ora10g

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Apr 10 11:14:02 2013

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORA10G (DBID=4064221434)

RMAN> connect catalog rman/rman@RMAN

connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

 

TSM配置

创建存储池

加磁带(可选)

创建domain,策略域等,

注册节点,到为ORA创建的策略域

安装BA

安装API

安装TDP

如果安装时出现找不到 class的情况,需要装IBM java

[root@rhel5x64tsmcliora Media]# rpm -ivh ibm-java2-i386-sdk-5.0-5.0.i386.rpm

Preparing... ########################################### [100%]

1:ibm-java2-i386-sdk ########################################### [100%]

然后设置环境变量

PATH=/opt/ibm/java2-i386-50/bin/:$PATH:$HOME/bin

首先要安装tsm for oracle的程序

把附件中的2个opt文件(dsm.opt、tdpo.opt),还有agent.lic文件拷贝到AgentOBA目录下

手动创建日志文件目录及日志文件,确保oracle用户对日志有写权限

[root@rhel5-ora logs]# pwd

/opt/tivoli/tsm/logs

[root@rhel5-ora logs]# ll

总计 12

-rwxrwxrwx 1 root root 2067 04-10 14:55 dsmerror.log

-rwxrwxrwx 1 root root 823 2011-08-24 dsmsched.log

-rw------- 1 oracle oinstall 143 04-10 14:55 tdpoerror.log

64bit系统可能需要为库文件做软连接,不确定

ln -sf /usr/lib/libobk64.a $ORACLE_HOME/lib/libobk64.a

修改dsm.opt ,servername是node name

[root@rhel5-ora bin]# pwd

/opt/tivoli/tsm/client/oracle/bin

[root@rhel5-ora bin]# cat dsm.opt

servername TSM-ORA

修改dsm.sys配置文件

[root@rhel5-ora bin]# pwd

/opt/tivoli/tsm/client/oracle/bin

[root@rhel5-ora bin]# cat dsm.sys

SErvername TSM-ORA

COMMMethod tcpip

TCPPort 1500

TCPServeraddress 10.1.1.140

nodename TSM-ORA

*passwordaccess generate

passworddir /etc/security/adsm/

tcpnodelay yes

tcpwindowsize 63

tcpbuffsize 256

txnbytelimit 2097152

*enablelanfree yes

*lanfreecommmethod tcpip

*lanfreetcpport 1500

schedmode prompted

tcpclientaddress 10.1.1.21

tcpclientport 1502

schedlogname /opt/tivoli/tsm/logs/dsmsched.log

errorlogname /opt/tivoli/tsm/logs/dsmerror.log

errorlogretention 30 d

schedlogretention 14 d

修改tdpo.opt

[root@rhel5-ora bin]# pwd

/opt/tivoli/tsm/client/oracle/bin

[root@rhel5-ora bin]# cat tdpo.opt

***************************************************************************

* IBM Tivoli Storage Manager for Databases

* Data Protection for Oracle

*

* Sample tdpo.opt for the Linux86 Data Protection for Oracle

*********************************************************************

DSMI_ORC_CONFIG /opt/tivoli/tsm/client/oracle/bin/dsm.opt

* DSMI_ORC_CONFIG /opt/tivoli/tsm/client/oracle/bin/dsm.sys

* DSMI_LOG /opt/tivoli/tsm/client/oracle/bin

DSMI_LOG /opt/tivoli/tsm/logs/

*TDPO_FS /adsmorc

TDPO_NODE TSM-ORA

TDPO_OWNER oracle

*TDPO_PSWDPATH /opt/tivoli/tsm/client/oracle/bin

*TDPO_DATE_FMT 1

*TDPO_NUM_FMT 1

*TDPO_TIME_FMT 1

*TDPO_MGMT_CLASS_2 mgmtclass2

*TDPO_MGMT_CLASS_3 mgmtclass3

*TDPO_MGMT_CLASS_4 mgmtclass4

验证配置

[root@rhel5-ora bin]# pwd

/opt/tivoli/tsm/client/oracle/bin

[root@rhel5-ora bin]# ./tdpoconf showenvironment

IBM Tivoli Storage Manager for Databases:

Data Protection for Oracle

Version 5, Release 5, Level 1.0

(C) Copyright IBM Corporation 1997, 2008. All rights reserved.

Data Protection for Oracle Information

Version: 5

Release: 5

Level: 1

Sublevel: 0

Platform: 32bit TDPO Linux86

Tivoli Storage Manager Server Information

Server Name: TSM-ORA

Server Address: 10.1.1.140

Server Type: Windows

Server Port: 1500

Communication Method: TCP/IP

Session Information

Owner Name: oracle

Node Name: TSM-ORA

Node Type: TDPO Linux86

DSMI_DIR: /opt/tivoli/tsm/client/api/bin

DSMI_ORC_CONFIG: /opt/tivoli/tsm/client/oracle/bin/dsm.opt

TDPO_OPTFILE: /opt/tivoli/tsm/client/oracle/bin/tdpo.opt

Password Directory: /opt/tivoli/tsm/client/oracle/bin

Compression: FALSE

License Information: License file exists and contains valid license data.

联系TSM server,当前密码为注册节点时的密码

[root@rhel5-ora bin]# pwd

/opt/tivoli/tsm/client/oracle/bin

[root@rhel5-ora bin]# ./tdpoconf password

IBM Tivoli Storage Manager for Databases:

Data Protection for Oracle

Version 5, Release 5, Level 1.0

(C) Copyright IBM Corporation 1997, 2008. All rights reserved.

***************************************************************

* IBM Tivoli Storage Manager for Databases Utility

* Password file initialization/update program

***************************************************************

Please enter current password:

Please enter new password:

Please reenter new password for verification:

ANU0260I Password successfully changed.

 

如果是root用户来执行 tpdoconf password命令的话,需要在tdpo.opt 中添加行 TDPO_NODE RHEL5X64TSMCLIORA-ORA

确保Oracle用户对tdpoerror.log, dsierror.log这两个文件有写权限.

 

测试

su - oracle

rman log=/home/oracle/logs/bacup_full_`date +%y%m%d_%H%M%S`.log cmdfile=/home/oracle/script/backup_full.rman

脚本

[oracle@rhel5-ora script]$ cat backup_full.rman

connect target /

connect catalog rman/rman@RMAN

run{

allocate channel ch1 type 'sbt_tape';

BACKUP INCREMENTAL LEVEL=0 tag 'TESTDB1' format 'testdb1%d_%s_%T' DATABASE include current controlfile;

BACKUP current controlfile format 'testdb1_controlfile1%d_%s_%T';

sql 'alter system archive log current';

backup format 'testdb1_arch1%d_%s_%T' archivelog all delete input;

release channel ch1;

}

 

su - oracle -c "rman log=./logs/rman_backup_full_`date +%y%m%d`.log cmdfile=/home/oracle/script/backup_full.rman"

你可能感兴趣的:(oracle,IBM,tivoli,TSM)