camyd
作者camyd·2013-11-01 12:00
数据库管理员·中储粮

TSM备份DB2数据库和归档的解决方案

字数 21208阅读 4495评论 4赞 3

第一章节 TSM环境搭建(TSM版本5.5

在安装之前需要确定ompat-libstdc++的系统包已经安装.

[root@tsmserver mnt]# rpm -qa | grep compat-libstdc++

compat-libstdc++-296-2.96-138

compat-libstdc++-33-3.2.3-61

compat-libstdc++-33-3.2.3-61

 

Server

TIVsm-license-5.5.0-0.x86_64.rpm  (许可证包)

TIVsm-server-5.5.0-0.x86_64.rpm  server资源包)

TIVsm-tsmscsi-5.5.0-0.x86_64.rpm(设备驱动程序软件包)

Client

TIVsm-API.i386.rpm API包)

TIVsm-API64.i386.rpm 64API包)

注:allows you to add Tivoli Storage Manager application program interface calls to existing applications, and to write programs with general-use program interfaces that obtain Tivoli Storage Manager services

TIVsm-BA.i386.rpm    backuparchive包)

注:The Backup-Archive client allows users to maintain backup versions of their files, which they can restore if the original files are lost or damaged. Users can also archive files for long-term storage and retrieve the archived files when necessary

 

分别按照在server端和client端(默认路径: /opt/tivoli/tsm/

Server

rpm –ivh TIVsm-server-5.5.0-0.x86_64.rpm

rpm –ivh TIVsm-tsmscsi-5.5.0-0.x86_64.rpm

rpm –ivh TIVsm-license-5.5.0-0.x86_64.rpm

rpm –ivh TIVsm-API.i386.rpm

rpm –ivh TIVsm-API64.i386.rpm

rpm –ivh TIVsm-BA.i386.rpm

 

 

 

 

 

Client

rpm –ivh TIVsm-API.i386.rpm

rpm –ivh TIVsm-API64.i386.rpm

rpm –ivh TIVsm-BA.i386.rpm

 

 

第二章节 TSM启动

启动环境命令

cd /opt/tivoli/tsm/server/bin

nohup ./dsmserv &

注:一个TSM只能启动一个环境程序,如果之前有遗留的dsmserv进程的话,需要kill掉。

cat dsmserv.lock

kill processID

 

 

在启动TSMCLP之前,需要在/opt/tivoli/tsm/client/ba/bin下面创建dsm.optdsm.sys文件

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.opt.smp /opt/tivoli/tsm/client/ba/bin/dsm.opt

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.sys.smp /opt/tivoli/tsm/client/ba/bin/dsm.sys

chmod 755 /opt/tivoli/tsm/client/ba/bin/dsm.opt 

chmod 755 /opt/tivoli/tsm/client/ba/bin/dsm.sys

 

设置登陆CLP的用户名和密码

register admin uadmin padmin  uadmin是账户,padmin是密码)

 

启动TSMCLP

dsmadmc -id=admin -password=admin

 

服务器的一些设置CLP模式下

1,定义TSM 服务名:

SET servername WUXICLOUD_tsm

 

2,定义密码过期999

SET PASSEXP 999

 

3,设置服务器保留活动日志30

SET ACTLOGRETENTION 30

 

4,指定服务器等待客户机响应的最长时间300(以秒计)。

SETOPT COMMTIMEOUT 300

 

5,指定服务器等待闲置客户机的最长时间60((以分钟计)。

SETOPT IDLETIMEOUT 60

 

6,指定自动库存到期进程间的时间间隔(以小时计)。可以指定 0 33614 天)。最小值为 0,表明必须使用 EXPIRE INVENTORY 命令启动到期操作。

SETOPT EXPInterval 0

 

7,指定服务器密码。其他服务器在定义该服务器时必须具有同一密码。

SET serverpassword admin

 

安装TSM的许可证

register license file=*.lic  

/opt/tivoli/tsm/server/bin

-rw-r--r-- 1 root root 278 Nov  9  2007 dataret.lic   

(用 Data |Retention Protection Expiration and Deletion SuspensionDeletion Hold)所必需的)

-rw-r--r-- 1 root root 263 Nov  9  2007 tsmbasic.lic  basic版本)

-rw-r--r-- 1 root root 278 Nov  9  2007 tsmee.lic    

extend版本许可 IBM Tivoli Storage Manager Extended Edition。这包括灾难恢复管理器、大型库和 NDMP

 

 

 

 

第三章 Server端的资源配置定义

0,进入TSMCLP模式

cd /opt/tivoli/tsm/server/bin

dsmadmc -id=admin -password=admin

 

创建相关路径

mkdir /tsmdata    (TSM DB路径)

mkdir /tsmdata/tsmdbbak    TSM DB备份路径)

mkdir /tsmdata/filesave      TSM相关配置路径)

mkdir –p /tsmfiledata/db2backup

 

 

创建前删除TSM自带的相关资源

delete volume backup.dsm

delete volume archive.dsm

delete stgpool backuppool

delete stgpool archivepool

delete stgpool spacemgpool

delete mgmtclass standard standard standard

delete policyset standard standard

remove node client

delete domain standard

 

 

1,创建TSMDB与其副本DB

define dbvolume /tsmdata/db2_cloud.dsm formatsize=1024 wait=yes

define dbcopy /tsmdata/db2_cloud.dsm /tsmdata/db2_cloud_cp.dsm formatsize=1024 wait=yes

 

2,创建TSM的日志与其副本日志

define logvolume /tsmdata/log_cloud.dsm formatsize=512 wait=yes

define logcopy /tsmdata/log_cloud.dsm /tsmdata/log_cloud_cp.dsm formatsize=512 wait=yes

 

3,扩展DB的大小52M(必须以4M为增量)

extend db 52

 

4,扩展日志的大小4M

extend log 4

 

5,定义设备类

需要根据备份数据库的大小和备份、还原频率来选择某一种类型的设备类来存储 DB2 的备份数据库。TSM server 使用 define devclass 来完成此功能

define devclass db2diskclass devtype=file directory=/tsmfiledata/db2backup

 

6,定义存储池 (storage pool) 和存储卷 (volume)

存储池是一个逻辑概念,它表示了备份 / 归档数据的实际存储设备,每一个存储池都对应了一个特定的设备类。TSM server 使用 define stgpool 来完成此功能。(指定maxscratch就可以不用指定volume,利用系统临时卷

define stgpool db2filepool db2diskclass maxscratch=100

define stgpool db2archivepool db2diskclass maxscratch=100

define volume db2filepool d:tsmfiledatadb2backupvolm1 format=100

 (在不指定maxscratch的情况下,需要使用volume)

 

7,定义节点。为了让 DB2 通过 TSM client API 备份数据,必须在 TSM server 上为其注册一个节点,设置它的节点名及密码。

register node db2smp password domain=db2domain

(在这里,db2smp为新注册的节点,默认注册到 STANDARD 的策略域上,可以指定domain,需要在定义好domain后执行)

 

8,定义策略域

define domain db2domain description="policy domain for db2 backup"

 

9,定义策略集

define policyset db2domain db2policyset description="policy set for db2"

 

10,定义管理类

define mgmtclass db2domain db2policyset db2mgmtclass description="management class for db2"

 

11TSM server 使用 assign defmgmtclass 命令把设置某个策略集中的默认管理类

assign defmgmtclass db2domain db2policyset db2mgmtclass

 

 

 

通过定义拷贝组,服务器可以控制客户机如何备份和归档文件,以及管理已归档和备份的文化

12,定义备份拷贝组

define copygroup db2domain db2policyset db2mgmtclass dest=db2filepool

 

13,定义归档拷贝组

define copygroup db2domain db2policyset db2mgmtclass type=archive dest=db2archivepool

(这两个命令在 db2mgmtclass 中分别定义了 backup copy group archive copy group, 并指明 backup archive 的数据分别存储在 db2filepool db2archivepool 两个存储池中)

 

14,验证并激活策略集

validate policyset db2domain db2policyset

activate policyset db2domain db2policyset

 

15,修改备份的COPYGROUP的备份计划

update copygroup db2domain db2policyset DB2MGMTCLASS type=backup destination=db2filepool VERD=0 RETO=0

(由于要保证client端的DB备份和serverDB备份同步,在clientdelete的时候,在server端必须立即过期。VERD表示delete之后保存的个数,RETO表示delete之后保存的天数)

 

16,修改归档的COPYGROUP的备份计划

update copygroup db2domain db2policyset DB2MGMTCLASS standard type=archive destination=db2archivepool retver=NOLimit

(对于归档日志,采用不设时间,手动删除的方法)

 

17,修改生效

activate policyset db2domain db2policyset

(重新激活policyset,使更改生效)

 

18,分别查询当前activecopygroup

q co db2domain active db2mgmtclass type=backup f=d

q co db2domain active db2mgmtclass type=archive f=d

 

19,更新节点信息

update node db2smp domain=db2domain archdelete=yes backdelete=yes

注:archdeletebackdelete指的是客户机是否有删除备份和归档文件的权限

 

 

 

 

 

第三章 TSM客户端的设置(linux

1,关键要在/opt/tivoli/tsm/client/ba/bin/opt/tivoli/tsm/client/api/bin64下面新建dsm.sysdsm.opt文件。ba下面不创建的话,与server端连接会失败。api下面不创建的话,db2adutl等工具会使用失败。

保证下面文件都建立成功

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.opt.smp /opt/tivoli/tsm/client/ba/bin/dsm.opt

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.sys.smp /opt/tivoli/tsm/client/ba/bin/dsm.sys

chmod 755 /opt/tivoli/tsm/client/ba/bin/dsm.opt 

chmod 755 /opt/tivoli/tsm/client/ba/bin/dsm.sys

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.opt /opt/tivoli/tsm/client/api/bin

cp -ip /opt/tivoli/tsm/client/ba/bin/dsm.sys /opt/tivoli/tsm/client/api/bin

 

[db2inst1@db2-test2 bin64]$ cat dsm.sys

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

* IBM Tivoli Storage Manager                                           *

*                                                                      *

* Sample Client System Options file for UNIX (dsm.sys.smp)             *

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

 

*  This file contains the minimum options required to get started

*  using TSM.  Copy dsm.sys.smp to dsm.sys.  In the dsm.sys file,

*  enter the appropriate values for each option listed below and

*  remove the leading asterisk (*) for each one.

 

*  If your client node communicates with multiple TSM servers, be

*  sure to add a stanza, beginning with the SERVERNAME option, for

*  each additional server.

 

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

 

SErvername WUXICLOUD_TSM

                COMMmethod         TCPip

                TCPPort            1500

                TCPServeraddress   10.176.160.11

                PasswordAccess generate

                tcpnodelay                             yes (不允许延迟在网络发送连续小数据包)

                tcpbuffsize                             256

                tcpwindowsize                   64

                txnbytelimit                    2097152

                resourceutilization             2

                NODENAME      db2smp             (客户端节点名)

                errorlogretention               30 d

               enablelanfree                           yes

               lanfreecommmethod               tcpip

               lanfreetcpport                  1500

                   SCHEDMODE               PROMPT  (调度方式,PROMPT是服务器端提示)

                TCPCLIENTADDRESS        10.176.160.12  (客户端的IP地址)

                TCPCLIENTPORT           1501

                managedservices                 schedule webclient  (是否使用CAD调度)

   SCHEDLOGName /dbhome/db2inst1/tsm/dsmsched.log       (调度日志的路径)                                                                                                               

   ERRORLOGName /dbhome/db2inst1/tsm/dsmerror.log        TSM运行的日志)

 

 

2,环境变量设置(需要重启实例,reloadruntime)

export DSMI_DIR=/opt/tivoli/tsm/client/api/bin

export DSMI_LOG=/home/db2inst1/tsm

export DSMI_CONFIG=/opt/tivoli/tsm/client/ba/bin/dsm.opt

 

3DB2方面的设置

该数据库将会绑定到哪一个管理类中

db2 update db cfg for dbname using tsm_mgmtclass db2mgmtclass

dsm.sys里面设置好nodename,password generate之后,需要确认下面的参数为空值。

db2 update db cfg for dbname using tsm_nodename NULL

db2 update db cfg for dbname using tsm_password NULL

db2 update db cfg for dbname using tsm_owner NULL

 

4,设置节点密码(需要root用户)

cd /dbhome/db2inst1/sqllib/adsm

./dsmapipw

(输入的current password是在服务器端定义节点时的password

 

 

 

 

 

 

 

 

 

第四章 利用TSM备份DB2与归档日志

1,全备离线数据库

db2 backup db sample use tsm open 2 sessions with 6 buffers

2,在线数据库备份(包含日志)

db2 backup db sample online use tsm open 2 sessions with 6 buffers include logs

3,设置利用TSM归档日志

db2 update db cfg for sample using LOGARCHMETH1 TSM:db2mgmtclass

4,设置归档失败的次归档路径(必须引用磁盘)

db2 update db cfg for sample using FAILARCHPATH path-name

 

 

 

 

 

 

 

 

 

 

第五章         TSM备份与归档文件的查询(server)

0,进入TSMCLP模式

cd /opt/tivoli/tsm/server/bin

dsmadmc -id=admin -password=admin

1,  查询node下面的所有备份文件信息

select * from backups where node_name='DB2SMP'  

 

 

 

 

 

 

 

 

 

2,查询node下面的所有归档文件信息

select * from archives where node_name='DB2SMP

3'查询node的信息

q node db2smp

 

4,查询当前active状态的archive copygroup信息(copygroup决定存储池和在server保留时间)

q copygroup db2domain active db2mgmtclass type=archive format=detail

 

 

 

 

 

 

 

 

 

5,查询当前active状态的backup copygroup信息(copygroup决定存储池和在server保留时间)

q copygroup db2domain active db2mgmtclass format=detail

 

 

版本控制主要由copygroup的几个参数控制:(DB2的备份文件由于时间戳的原因,每个都是唯一的版本)

 

Version Data Exists    VERExists   :意思是tsm server保留多少份客户files

 

Version Data Deleted VERDeleted):   在客户端的文件被删除了,那么tsm server保留的版本数目(在备份过程中,tsm将会自动检查客户的文件是否曾经存在)

 

Retain Extra Versions RETExtra        当版本变成inactive后,该版本保留多少天。(时间到了后,tsm serverexpire process将会把该版本标记为已经过期,从此该inactive的版本将不可恢复了)

 

Retain Only Version    RETOnly        客户端文件被删除了,server端的最后一次对该文件的备份版本保留的天数。

 

 

6,backup objectarchive object的生存周期

backup object

在被从Server上面清除之前,backup object有三种状态:active, inactive, and expired

周期一

backup obejectclientsentserver端,它会变成active的状态。

周期二

当在客户端手动通过programlike db2adutl delete)或者有新版本的backup object生成的时候,它的状态会变成inactive

周期三

inactivebackup object超过保留时间的时候,会变成expired

周期四

expiredbackup object遇到执行过期清除进程的时候(一般该进程会调用expire inventory),会从server上面删除该backup,释放空间。

需要注意的是,activeinactive状态的backup object仍旧可以被TSM client端访问。

expired的时候,不允许访问。

inactive是由于clientprogram操作,变到expired是由于server端的保留设置,不需要client端干预。

 

archive object

在被从Server上面清除之前,archive object有三种状态:current and expired

周期一

clientsentserver端,状态是current state

周期二

client端手动清除或者超过保留设置,会变成expired state

周期三

expiredarchive object遇到执行过期清除进程的时候(一般该进程会调用expire inventory),会从server上面删除该backup,释放空间。

注意的是,一旦archive objectcurrent变成expired之后,就不能被client使用。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

第六章         db2adutl命令的运用

QUERY queries either tablespace, full backup, loadcopy images, or log archives. If you type query only, it returns all four.

EXTRACT, if you do not qualify it, displays the name of each backup image and prompts you to extract the image. If you qualify the command you reduce the scope of the search. For this option, time stamps do not apply to log archives.

DELETE, if you do not qualify it, works similarly to extract, except that backup images are marked inactive and archive objects (log files) are deleted.

VERIFY, performs consistency checking on the tablespace or backup copy that is on the Tivoli Storage Manager server. This parameter causes the entire backup image to be transferred over the network

 

 

1,  查询某个DB的所有备份情况(FULL DATABASE BACKUP,INCREMENTAL DATABASE BACKUP,DELTA DATABASE BACKUP,TABLESPACE BACKUP,INCREMENTAL TABLESPACE BACKUP, DELTA TABLESPACE BACKUP,LOAD COPY,LOG ARCHIVE

db2adutl query db sample

 

2,  查询DB的数据库级别备份情况

db2adutl query full db sample

 

3,  查询DB的归档日志情况

db2adutl query logs db sample

 

 

 

 

4,  客户端删除数据库备份文件(inactive化)

db2adutl delete full taken at 20110714151527 db sample WITHOUT PROMPTING 可以不提示

 

 

server端可以通过

select * from backups where STATE='INACTIVE_VERSION'

 

 

5,  server端导出备份到client

db2adutl extract full taken at 20010314084325 db sample WITHOUT PROMPTING

 

 

 

 

6,  验证全备备份文件的完整性

db2adutl verify full NONINCREMENTAL taken at 20110719141201 db sample WITHOUT PROMPTING

 

7,抽取归档日志文件

db2adutl EXTRACT LOGS BETWEEN S0000000 and S0000004 db sample WITHOUT PROMPTING

 

8,查看归档日志文件

db2adutl query logs db sample

 

 

 

 

 

 

第七章         TSM调度程序

DB2备份相关

1,  定义调度程序(每天的凌晨四点执行脚本)

def sched db2domain db2OLbackup_sched description=’OnLine DB2 Backup Daily’ act=command objects='su - db2inst1 -c /dbhome/db2inst1/TSM_online_backup.ksh' starttime=04:00 period=1

2,  与节点关联

def assoc db2domain db2OLbackup_sched db2smp

3,  client端启动调度服务(se指定服务名)

nohup dsmc sched -se=WUXICLOUD_TSM &    

4,  查看定义的调度程序

q sch db2domain db2OLbackup_sched f=d

5,查看调度程序执行状态(必须执行之后才能看见)

query event db2domain * nodes=db2smp   *代表这个domain下面的所有schedule

query event db2domain db2OLbackup_sched nodes=db2smp f=d

6,查询日志文件

tail -f dsmsched.log

7,  修改调度程序

update sched db2domain db2OLbackup_sched starttime=09:00

TSM Server自身维护定义TSM管理调度

TSM管理命令行提示符下执行如下一些命令为TSM Server自身维护定义所需的TSM管理调度任务:

1)    定义用于删除已经过期的TSM Database备份的调度任务:

define schedule expire_old_tsmdb_backup type=admin active=yes cmd=”delete volhistory type=dbbackup todate=today-7” starttime=10:45:00 duration=10 durunit=minutes period=1 perunit=days dayofweek=any expiration=never

2)    定义用于备份当前TSM Database的调度任务:

define schedule backup_tsmdb type=admin active=yes cmd=”backup db devclass=dbbakdev type=full” starttime=11:00:00 duration=10 durunit=minutes period=1 perunit=days dayofweek=any expiration=never

3)    定义用于备份当前TSM卷历史信息的调度任务:

define schedule backup_volhistory type=admin active=yes cmd=”backup volhistory file=/tsmdata/filesave/volhist.out” starttime=11:30:00 duration=10 durunit=minutes period=1 perunit=days dayofweek=any expiration=never

4)    定义用于备份当前TSM设备配置信息的调度任务:

define schedule backup_devconfig type=admin active=yes cmd=”backup devconfig file=/tsmdata/filesave/devcnfg.out” starttime=11:45:00 duration=10 durunit=minutes period=1 perunit=days dayofweek=any expiration=never

5)定义运行Inventory expiration的时间

define schedule EXPIRE_INVENTORY type=admin description="Inventory expiration" cmd="expire inventory" starttime=06:30 active=yes

6)    定义用于对TSMts3200_pool存储池中磁带进行空间回收的调度任务:

define schedule reclaim_ltopool1 type=admin active=yes cmd=”reclaim stgpool ts3200_pool threshold=80 duration=120” starttime=13:00:00 duration=10 durunit=minutes period=1 perunit=days dayofweek=any expiration=never

 

查询Server上执行的调度程序

query sched type=admin f=d

查看server事件执行情况

q event * type=admin

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

3

添加新评论4 条评论

atpeace331atpeace331数据库管理员银行
2014-08-04 22:30
总结得很棒!!!顶起!!!
flywiththewindflywiththewind其它easy world
2013-12-06 08:21
为什么图片无法显示呢?
zymh_zyzymh_zyIT顾问国内某公司
2013-11-13 22:09
有些图无法正常显示。。。
Run_LeoCatRun_LeoCat数据库管理员中科金财
2013-11-04 15:21
从哪里才能搞到TSM的环境来进行测试实验呢?
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广