Wednesday, April 9, 2008

Thursday, April 3, 2008

DB2: Backup Commands

*** Full Offline Backup of [database] to Disk [no HADR] ***
db2 CONNECT TO [database] user [user] using [password]
db2 "QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS"
db2 "CONNECT RESET"
db2 BACKUP DATABASE [database] TO "/cm/dbfs/lsbak/offline/full" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS WITHOUT PROMPTING
db2 CONNECT TO [database] user [user] using [password]
db2 "UNQUIESCE DATABASE"
db2 "CONNECT RESET"

*** Full Offline Backup of to TSM ***
su - db2inst1
db2text stop
db2 deactivate db [database]
db2 force applications all
db2stop
db2 BACKUP DATABASE [database] USE TSM WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS WITHOUT PROMPTING
db2start
db2 activate db [database]
db2text start

DB2: Maintenance the 3rs

$ db2 "reorgchk update statistics on table all" > /tmp/reorgchk_rmdb_0216.out
$ db2rbind [database] -l /tmp/db2rbind_rmdb_0216.out all
$ db2 "reorg table [schema].[table]"
$ db2 "reorg indexes all for table [schema].[table]"

AIX: Scripting Technics

*** To execute a command from root on behalf other users ***
su - db2inst1 -c "db2 BACKUP DB [database] ONLINE INCREMENTAL USE TSM INCLUDE LOGS " 2>&1 tee -a $_LOG
This line was taken from the db2incr.sh script on prod in /usr/tivoli/tsm/client/api/bin

DB2: Managing backups

$ db2adutl delete full older than 30 days db [database] (list logs to delete older than 30 days)
$ db2adutl delete logs between S0008971.LOG and S0009772.LOG db [database] without prompting

DB2: HADR Resync or Restablish

DB2 HADR Setup (Use when Databases Lose Connectivity or to Resynch Logs)
1. On the primary server issue:

db2 stop hadr on database icmnlsdb
2. On the primary server:
db2 BACKUP DATABASE [database] TO "/cm/dbfs/lsbak/offline/full" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS WITHOUT PROMPTING

Note: Document DB Backup Timestamp ICMNLSDB.0.db2inst1.NODE0000.CATN0000.20080320232702.001
3. FTP backup file to [standbyserver]:/cm/dbfs/lsbak/offline/full
4. On the standby server:

db2 restore database [database] from "/cm/dbfs/lsbak/offline/full" taken at 20080320232702 replace history file without rolling forward
Note: Timestamp = 20080320232702
There should be no need to change any other HADR parms as they should be maintained.

DB2: Basic Line Prompt Commands

*** Locks ***
$ db2text control list all locks for database [database]
$ db2text control clear all locks for database [database]

*** Connections ***
db2 connect to [database] user [user] using [password]

TSM: Basic Line Prompt Commands

root on [Server]:/usr/tivoli/tsm/client/ba/bin>dsmadmc
tsm: [Server]>q pro (list of active processes)
tsm: [Server]>q stg (list of available storage)

TSM: Basic Console Admin Commands

q act (Use to view the activity from the past 2 hours)
q act begint=00:06:00 (Use to review the activity from 6am till current time)
q stg (Use to see how musch storage is available in the TSm storage pools)
q occ stg=centera1 (Use to see how much Centera storage is being used)
q sess (Use to see if there are any active sessions currently backing up to TSM)
q pro (Use to list active TSM processes)