Sunteți pe pagina 1din 4

Database Administration: 

DB2/UDB (DB6)

DB6 data files


DB6 data is stored in tables spaces. The corresponding data files are called
containers. They are named <table space>.container<m> and placed in directory
/db2/<SID>/sapdata<n> or /db2/<SID>/sapdata<n>/NODExxxx depending from
product
and release .
All containers should have the same size because a rebalancer distributes the
data of a table space over all containers evenly !!!

DB6 log files


DB6 has two types of log files: Online log files and Offline log files.
The current log files are called Online log files. On SAP systems there are
normally 30 Online log files which are placed in directory /db2/<SID>/log_dir.
The inactive log files are called Offline log files and they are placed in
directory  /db2/<SID>/log_archive.

DB6 log modes:


DB6 has only two log modes. Either log mode is chosen or not.
If log mode is on the parameters  LOGRETAIN and USEREXIT will be set, so Online
log files are copied to Offline log files after all Online log files are full.
Then the Online log files are written from the beginning again.
If log mode is off the Online Redo logs are written wrap around, i.e. if all
Online log file are full they will be overwritten again without saving it. No
recovery of the database is possible.

DB6 data dictionary:


The DB6 data dictionary is stored in table space syscatspace.

DB6 User:
<sid>adm
db2<sid>
sapr3/sap<sid>
DB6 Groups:
db<sid>adm
db<sid>ctl
db<sid>mnt
sapsys

How to find errors ?


The DB6 alert log is called db2diag.log and it is placed in directory
/db2/<SID>/db2dump or /db2/<SID>/sqllib/db2dump or
/db2/db2<sid>/sqllib/db2dump
depending from product and release.

How to find the explanation for DB6 error codes ?


Enter db2 ? SQL<error code>.
 

View DB parameters
For instance-specific parameters enter  db2 get DBM cfg.
For <SID>-specific parameters enter   db2 get DB cfg  for <SID>.

Find out DB version:


Enter  db2level.
Enter db2 connect to <SID> user <usrname> using <pwd>.

Start the database:


Enter db2start.

Stop the database:


Enter db2stop.

Turn off the log mode


Enter db2 update db cfg  for <SID> using LOGRETAIN OFF.
Enter db2 update db cfg  for <SID> using USEREXIT OFF.
Stop and start the database to activate your changes.
Turn on the log mode
Enter db2 update db cfg  for <SID> using LOGRETAIN ON .
(Since version 6.1 parameter LOGRETAIN has status RECOVERY.)
Enter db2 update db cfg  for <SID> using USEREXIT ON .
Stop and start the database to activate your changes.
After turning the log mode on the database is in backup-pending state, i.e. no
application can connect to database. First a backup of the database must be
done (i.e. db2 backup database <SID> to /dev/null). Check db2diag.log for
problems. If you won't see any entries, logging should be started properly !!!

Create a table space


Enter
Create tablespace <table space name> managed by database using (
FILE '/db2/<SID>/sapdata<n>/<table space name>.container001'
          <size of container 1> ,
FILE '/db2/<SID>/sapdata<n>/<table space name>.container002'
          <size of container 2>,
... )
extentsize <extentsize, e.g. 16> prefetchsize <prefetchsize, e.g. 16>.
All containers should have the same size because a rebalancer distributes the
data of a table space over all containers evenly !!!

Expand a table space


Enter
alter tablespace <table space name> add (
FILE '/db2/<SID>/sapdata<n>/<table space name>.container<m+1>'
          <size of container m+1> ).
!!! All containers should have the same size !!! When a new data file is added
DB6 starts a rebalancer to distribute the data of the table space over all
containers evenly. To continue wait until the rebalancer is ready. You can see
this in file db2diag.log.

or

Enter
alter tablespace <table space name> extend (all <size>)
Since version 7.1 possible. Every existing container will be expanded with the
value <size>. Using this command, the rebalancer will not start.

How to check the available space of your database ?


Enter db2 list tablespaces show detail.

Change a DB parameter
For instance-specific parameters enter  db2 update DBM cfg using <parameter>
<new value>.
For <SID>-specific parameters enter   db2 update DB cfg  for <SID> using
<parameter> <new value>.

Executing an SQL query


Enter connect to <SID> user <usrname> using <pwd>.
Enter your SQL statement.

Executing a DB6 script


Enter db2 -tvf <Path and name of DB6 script>.

Updating the statistic of a table


Enter db2 reorgchk update statistics on table <owner>.<table name> for one
table.
Enter dmdb6srp -n <SID> -t ALL for all tables.

S-ar putea să vă placă și