本文是我在客户部署TSM 备份软件的一个全面的实施文档,包括TSM For BA(备份文件) TSM For Oracle(备份oracle数据库),同时给出了一个全面的备份和恢复oracle数据库的实例。同时在恢复数据库后对数据的有效性进行了验证,给其他工程师在客户环境部署TSM提供了一个参考。
第1章 环境准备
1.1、介质描述
Storage Manager Linux Server 5.5.0.0
AIX平台的TSM Server
Storage Manager AIX Client 5.5.0.6
AIX平台的TSM 备份文件的客户端
Storage Manager Windows Client 5.5.0.6
Windows平台的TSM 备份文件的客户端
Storage Manager for Storage Area Network 5.5.0.3
通过SAN环境,即LAN-Free来备份数据需要安装的组件
Storage Manager for Database Protection for Oracle AIX 5.4.1.0
AIX平台,备份oracle数据库需要安装的组件
1.2、服务器及客户端信息
1.3、备份内容、策略及规划
1.3.1、备份存储池
Platform StoragePool Description
AIX FILE_TAPE_POOL 备份重要文件系统
AIX TAPE_POOL 备份oracle数据库
1.3.2、备份文件系统(待定)
1.3.3、备份数据库(待定)
1.3.4、过期处理(操作系统及文件)以下参数只针对与BA数据,对于TDPO数据不接受这些参数的限制
内容 参数 处理机制
操作系统及文件
过期处理原理 Verexists
(保留版本数)备份归档客户端所在的计算机上的某一个文件,在经过多次备份操作后,该文件将在TSM 服务器端形成多个备份。而Verexists 限定了这个客户端上未被删除的文件在TSM 服务器端的备份所允许保留的份数。如果用户备份的次数超过了Verexists 参数所指定的数量,则TSM 将自动删除比较老的备份。
例如,在缺省情况下,Verexists 的参数为2 ,则当用户进行了3 次备份后,最老的那一份数据将被设置为过期,仅保留最新的两份数据。Verexists 参数的值可以设置为0 -9999 ,也可以设置为NoLimit 。
Verdeleted(源文件被删除后,保留版本的数量)
用户已经把备份归档客户端的文件进行了备份,然后因为某种原因把这个文件从客户端删除。而Verdeleted 参数定义了,在用户从客户端删除这个文件后,在TSM 服务器端将保留的文件备份的分数。这个参数的缺省值为1 。
在用户执行完毕客户端文件的删除操作后,下一次客户端备份操作,将把超过Verdeleted 参数的备份设置为过期,例如用户设置Verdeleted 参数为3 ,在文件被删除前用户在服务器端保留了4 份备份。如果用户在客户端删除了该文件,则下一次客户端备份操作发生时,TSM 服务器将把最老的一份备份设置为过期,将只保留三份备份数据。
Verdeleted 可设置的数值范围包括0 -9999 ,或者设置为NOLimit ,表示保留所有的备份数据,即使该数据在客户端已经被删除。
Verdeleted 并不能单独决定备份数据的保留日期,一个文件备份是否过期还取决于其它几个参数,例如Retextra 和Retonly 等。
Retextra(保留天数)Verexists 指定了用户可以保留的客户端数据的备份数量,却没有指定备份后的数据将在服务器端保留多长时间。Retextra 指定了这个数据。确切的说,Retextra 指定了当备份数据从Active 变为Inactive 后可以保留的时间。TSM 规定,如果用户客户端的数据没有被删除,而在TSM 服务器端仅有一份该数据的备份的话,则该备份将永远保持Active 状态,而不会过期。
如果用户在服务器端产生了更新的备份,则以前的备份都将变为Inactive 。同样,如果用户在客户端删除了源文件,则所有备份文件也将变为Inactive 。从这时候起,Retextra 参数开始发挥作用,并开始倒数计时,超过Retextra 所规定的时间后,这些文件将被设置为过期。
Retextra 可以设置的数值从0 分布到9999 ,也可以设置为NOLimit 。
Retonly(保留唯一版本天数)一般说来,如果一份数据在备份归档客户端长期没有变化,则该数据在TSM 服务器上的备份数据将会逐渐过期,被删除,仅保留下最新的一份备份数据。如果TSM 客户端的这份数据既不发生修改,也不被删除,则这份数据将一直以Active 的状态保留下去。但是如果用户在客户端删除了这份数据,则该数据将立即变为Inavtive 。从这时起,Retonly 参数生效。它指定了这最后一份备份数据将在服务器上保留的时间。
第2章 配置TSM Server
2.1、安装TSM Server
2.1.1、下载TS3584 for AIX驱动
2.1.2、安装TS3584驱动
1. 执行smitty install 进行安装
2.1.3、安装TSM Server 5.5.0.0 for AIX
1. 执行smitty install 进行安装
2.2、更新TSM Server配置
2.2.1、更新TSM Server参数
1、 设置服务器名称及密码:
set servername tsmserver
set serverpassword password
2、 注册许可证:
reg lic file=*.lic number=100
执行q lic来查看
3、 设置日志模式:
set logmode rollforward
4、 设置密码过期时间:
set PASSExp 9999
5、 设置通信及空闲延时:
Setopt commtimeout 3600
Setopt idletimeout 60
6、 设置其他参数:
vi /opt/tivoli/tsm/server/bin/dsmserv.opt
BUFPOOLSIZE 524288
LOGPOOLSIZE 2048
LANGUAGE zh_CN
DEVCONFIG /tsm/files/devconfig.out
VOLUMEHISTORY /tsm/files/volhistory.out
2.2.2、定义新数据库卷和日志卷及其镜像、触发
1、 定义db卷及其镜像
define dbv /tsmfs/dbvol/db01.dsm formatsize=1000 wait=yes
define dbv /tsmfs/dbvol/db02.dsm formatsize=1000 wait=yes
define dbv /tsmfs/dbvol/db03.dsm formatsize=1000 wait=yes
extend db 3000
执行q dbv f=d来查询
2、 定义log卷及其镜像
define logv /tsmfs/logvol/log01.dsm formatsize=1000 wait=yes
define logv /tsmfs/logvol/log02.dsm formatsize=1000 wait=yes
define logv /tsmfs/logvol/log03.dsm formatsize=1000 wait=yes
extend log 3000
执行q logv f=d来查询
3、 定义扩展db和log的触发
define spacetrigger db fullpct=75 spaceexpansion=25 expansionprefix=/tsmfs/dbvol/ maximumsize=1000
define spacetrigger log fullpct=75 spaceexpansion=25 expansionprefix=/tsmfs/logvol/ maximumsize=1000
执行q spacetrigger db f=d和q spacetrigger log f=d来查询
4、 定义备份db的触发
define dbbackuptrigger devclass=LTOCLASS logfullpct=60
2.2.3、定义磁带库、磁带机及其路径
def library 3584lib libtype=scsi shared=yes
def path tsmserver 3584lib srctype=server autodetect=yes desttype=library device=/dev/smc0 >
def drive 3584lib 3580A element=autodetect >def drive 3584lib 3580B element=autodetect >def drive 3584lib 3580C element=autodetect >def drive 3584lib 3580D element=autodetect >def drive 3584lib 3580E element=autodetect >def drive 3584lib 3580F element=autodetect >
def path tsmserver 3580A srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape0 >
def path tsmserver 3580B srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape1 >
def path tsmserver 3580C srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape2 >
def path tsmserver 3580D srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape3 >
def path tsmserver 3580E srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape4 >
def path tsmserver 3580F srctype=server autodetect=yes desttype=drive library=3584lib device=/dev/IBMtape5 >
2.2.4、定义设备类
define devclass TBKCLASS library=3584lib devtype=LTO
define devclass LTOCLASS library=3584lib devtype=LTO
2.2.5、给磁带标号
label libvolume 3584lib search=yes labelsource=barcode checkin=scratch overwrite=yes
可以通过q libv来查询
2.2.6、定义TSM服务器自动管理
tsm server数据库备份:
define schedule backup_tsmdb_file type=administrative cmd="backup db devclass=TBKCLASS type=full " starttime=07:00 active=yes description="Database backup using files"
tsm server重要文件备份:
define schedule backup_devconfig type=administrative cmd="backup devconfig filenames=/tsm/dbbackup/devconfig.new" starttime=09:00 active=yes description="backup devconfig using files"
define schedule backup_volhistory type=administrative cmd="backup volhistory filenames=/tsm/dbbackup/volhistory.new" starttime=09:30 active=yes description="backup volhistory using files"
tsm server 卷历史信息删除:
define schedule delete_volhistory type=administrative cmd="delete volhistory TODate=today-2 type=dbbackup" starttime=07:30 active=yes description="Volhistory backup"
tsm server 卷空间回收操作:
define schedule expire_inventory type=administrative cmd="expire inventory" startt=08:00 description="Inventory expiration"
2.2.7、定义TSM服务器自动加载服务和rman catalog db备份调度(待定)
1、 rman catalog db的备份:
crontab -e
##############TSM CLIENT SCHEDULE###########################################################
0 19 * * * /opt/oracle/scripts/exprman.sh>/dev/console 2>&1 #Export rman catalog at 19:00 everyday
0 21 * * * /tsm/script/fullfs.sh>/dev/console 2>&1 #FullBackup Files at 21:00 everyday
脚本exprman.sh内容
exp rman/rman owner=rman file=catalog_full.dmp log=catalog_full.log buffer=102400
脚本fullfs.sh内容
nohup /tsm/script/exprman.sh &
export LOGFILE=/tsm/log/`date +%m%d.%H%M`file_full.log
dsmc selective /tsm/dbbackup/ -subdir=yes>$LOGFILE
dsmc selective /opt/oracle/catalog_full.dmp>>$LOGFILE
nohup rm -rf /opt/oracle/catalog_full.dmp &
2.2.8、定义存储池
define stgpool FILE_TAPE_POOL LTOCLASS maxscratch=nolimit
define stgpool TAPE LTOCLASS maxscratch=nolimit
2.2.9、定义备份oracle和file的策略域
define domain FILE_DOMAIN descr="BACKUP WIN FILES"
define domain ORACLE_DOMAIN descr="BACKUP ORACLE FILES"
2.2.10、定义备份oracle和file的策略集
define policyset FILE_DOMAIN standard
define policyset ORACLE_DOMAIN standard
2.2.11、定义备份oracle和file的管理类
define MGMTCLASS FILE_DOMAIN standard standard SPACEMGTECHNIQUE=NONE AUTOMIGNONUSE=0 MIGREQUIRESBKUP=YES
define MGMTCLASS ORACLE_DOMAIN standard standard SPACEMGTECHNIQUE=NONE AUTOMIGNONUSE=0 MIGREQUIRESBKUP=YES
定义备份oracle和file的副本组
define COPYGROUP FILE_DOMAIN standard standard DESTINATION=FILE_TAPE_POOL FREQUENCY=0 VEREXISTS=2 VERDELETED=1 RETEXTRA=90 RETONLY=180 MODE=MODIFIED SERIALIZATION=SHRSTATIC
define COPYGROUP ORACLE_DOMAIN standard standard DESTINATION=TAPE_POOL FREQUENCY=0 VEREXISTS=5 VERDELETED=1 RETEXTRA=90 RETONLY=180 MODE=MODIFIED SERIALIZATION=SHRSTATIC
2.2.12、分配备份oracle和file的默认管理类
assign defmgmtclass FILE_DOMAIN standard standard
assign defmgmtclass ORACLE_DOMAIN standard standard
2.2.13、激活备份oracle和file的策略集
activate policyset FILE_DOMAIN standard
activate policyset ORACLE_DOMAIN standard
activate policyset ORA-DBPOLICY standard
2.2.14、定义客户端备份调度(oracle的完全备份)
2.2.15、定义调度与节点的关联
2.2.16、定义客户端调度服务
2.2.17、注册节点
reg node P570NODE password domain=FILE_DOMAIN passexp=0 backdelete=yes maxnummp=10
reg node DELLNODE password domain=FILE_DOMAIN passexp=0 backdelete=yes maxnummp=10
reg node P51ANODE password domain=FILE_DOMAIN passexp=0 backdelete=yes maxnummp=10
reg node ORACLENODE password domain=ORACLE_DOMAIN passexp=0 backdelete=yes maxnummp=10
第5章 Oracle增量备份(包括datafile,controfile,archivelog)
脚本/tmp/tsm/rman/incre.sh
rq=`date +"%Y.%m.%d_%H.%M.%S"`
su - oracle -c /tmp/tsm/rman/rman.incre.sh >/tmp/tsm/log/rman.incre.$rq 2>&1
脚本/tmp/tsm/rman/rman.incre.sh
export ORACLE_SID=aml
rman target / rcvcat rman/rman@catalog / << EOF_RMAN
run{
allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t4 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t5 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t6 type 'sbt_tape' parms '
backup incremental level 1 tag '%d_full_%s_%p' filesperset 5 database diskratio=0 include current controlfile;
sql 'alter system archive log current';
backup format 'arch%t_%s_%p' diskratio=0 archivelog all delete input;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
}
EOF_RMAN
## delete OLD backups
export ORACLE_SID=aml
rman target / rcvcat rman/rman@catalog << EOF_RMAN
allocate channel for maintenance type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
crosscheck backup;
crosscheck archivelog all;
report obsolete;
delete noprompt obsolete recovery window of 90 days;
delete noprompt expired backup;
release channel;
EOF_RMAN
4.3.4、oracle备份验证
select output from v$rman_output order by stamp;
rman target / rcvcat rman/rman@catalog
list backup of tablespace users;
list backup of datafile 3;
list backup of database;----列出已备份的数据库的数据文件
list backup of controfile;----列出已备份的数据库的控制文件
list backup of archivelog all;--列出已备份的数据库的归档日志
list backup by file;
list recoverable backup of database;
list expired backup;
restore database preview;
4.3.5、oracle恢复测试
$>sqlplus /nolog
SQL> conn /as sysdba;
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1.7180E+10 bytes
Fixed Size 2114176 bytes
Variable Size 838864256 bytes
Database Buffers 1.6307E+10 bytes
Redo Buffers 31436800 bytes
Database mounted
rman target /
RMAN>
run {
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore controlfile from 'c-265712778-20090113-0a';
alter database mount;
}
allocated channel: t1
channel t1: sid=315 devtype=SBT_TAPE
channel t1: Da
Starting restore at 2009-01-13 17:13:15
channel t2: skipped, autobackup already found
channel t3: skipped, autobackup already found
channel t4: skipped, autobackup already found
channel t5: skipped, autobackup already found
channel t6: skipped, autobackup already found
channel t7: skipped, autobackup already found
channel t8: skipped, autobackup already found
channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:17
output filename=+DG_ASAML/asaml/controlfile/current.256.674845095
output filename=+DG_ASAML_ARCH/asaml/controlfile/current.256.674845095
Finished restore at 2009-01-13 17:13:33
database mounted
released channel: t1
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
418 419 ASAML 1328686371 CURRENT 1 2008-12-30 16:58:11
RMAN>
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t4 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t5 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
set until time "to_date('Jan 13 2009 17:56:42','Mon DD YYYY HH24:MI:SS')";
restore database;
recover database;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
alter database open resetlogs;
}
allocated channel: t1
channel t1: sid=315 devtype=SBT_TAPE
channel t1: Da
allocated channel: t2
channel t2: sid=314 devtype=SBT_TAPE
channel t2: Da
allocated channel: t3
channel t3: sid=313 devtype=SBT_TAPE
channel t3: Da
allocated channel: t4
channel t4: sid=312 devtype=SBT_TAPE
channel t4: Da
allocated channel: t5
channel t5: sid=311 devtype=SBT_TAPE
channel t5: Da
executing command: SET until clause
Starting restore at 2009-01-13 17:15:36
Starting implicit crosscheck backup at 2009-01-13 17:15:36
Crosschecked 39 objects
Finished implicit crosscheck backup at 2009-01-13 17:15:39
Starting implicit crosscheck copy at 2009-01-13 17:15:39
Finished implicit crosscheck copy at 2009-01-13 17:15:40
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +dg_asaml_arch/ASAML/AUTOBACKUP/2009_01_13/s_676052060.415.676052061
skipping datafile 13; already restored to file +DG_ASAML/asaml/datafile/mas_da
a_trade.370.675683005
skipping datafile 18; already restored to file +DG_ASAML/asaml/datafile/ts_a_xml.373.675683197
篇幅限制省略部分输出结果
................................................................................................................................................
skipping datafile 38; already restored to file +DG_ASAML/asaml/datafile/ts_a_trade_idx.400.675975405
channel t1: starting datafile backupset restore
channel t1: specifying datafile(s) to restore from backup set
restoring datafile 00043 to +DG_ASAML/asaml/datafile/testtsm.405.676030781
channel t1: reading from backup piece dbfull_676048210_51_1
channel t1: restored backup piece 1
piece handle=dbfull_676048210_51_1 tag=DBFULL
channel t1: restore complete, elapsed time: 00:03:36
Finished restore at 2009-01-13 17:19:27
Starting recover at 2009-01-13 17:19:29
starting media recovery
archive log thread 1 sequence 772 is already on disk as file +DG_ASAML/asaml/on
archive log thread 1 sequence 773 is already on disk as file +DG_ASAML/asaml/on
archive log thread 1 sequence 774 is already on disk as file +DG_ASAML/asaml/on
archive log filename=+DG_ASAML/asaml/on
archive log filename=+DG_ASAML/asaml/on
archive log filename=+DG_ASAML/asaml/on
media recovery complete, elapsed time: 00:00:01
Finished recover at 2009-01-13 17:19:38
released channel: t1
released channel: t2
released channel: t3
released channel: t4
released channel: t5
database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> quit;
Recovery Manager complete.
asdb1:/app/oracle$>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jan 13 17:21:22 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn /as sysdba;
Connected.
SQL> select * from testtsm1;
select * from testtsm1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from SYSTEM.TESTTSM1;
TEST1 TEST2
-------------------------------- --------------------------------
TEST3 TEST4
-------------------------------- --------------------------------
TEST5
--------------------------------
1 2
3 4
5
SQL>
评论