Comandos db2

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Buscar usuario dueño DB2

ps -fea|grep db2

db2qas 7012490 12124398 0 Jul 21 - 0:00 db2fmp (idle) 0


db2qas 7209164 12124398 0 Jul 21 - 0:03 db2fmp (idle) 0
root 7929976 12845222 0 Jul 15 - 0:33 db2ckpwd 0
db2qas 8257646 12845222 0 Jul 15 - 0:00 db2vend (PD Vendor Process -
258)
root 8519858 12845222 0 Jul 15 - 0:33 db2ckpwd 0

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

Listar las bases de datos

db2 list db directory | grep 'Database name'

Database name = QAS

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

Conectarse a la BD

db2 connect to DBNAME

db2qas> db2 connect to QAS

Database Connection Information

Database server = DB2/AIX64 9.7.9


SQL authorization ID = DB2QAS
Local database alias = QAS

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

Obtener configuración de la BD

db2 get db cfg for QAS

db2qas> db2 get db cfg for QAS

Database Configuration for Database QAS

Database configuration release level = 0x0d00


Database release level = 0x0d00

Database territory = en_US


Database code page = 819
Database code set = ISO8859-1
Database country/region code = 1
Database collating sequence = IDENTITY
Alternate collating sequence (ALT_COLLATE) = IDENTITY_16BIT
Number compatibility = OFF
Varchar2 compatibility = OFF
Date compatibility = OFF
Database page size = 16384

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

Buscar dentro de la configuración de la BD con el comodin grep

db2 get db cfg for QAS|grep log

db2qas> db2 get db cfg for QAS|grep log


User exit for logging status = YES
Catalog cache size (4KB) (CATALOGCACHE_SZ) = 20480
Number of primary log files (LOGPRIMARY) = 150
Number of secondary log files (LOGSECOND) = 40
Changed path to log files (NEWLOGPATH) =
Path to log files = /db2/QAS/log_dir/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (MIRRORLOGPATH) =
First active log file = S0044195.LOG
Block log on disk full (BLK_LOG_DSK_FUL) = YES
Block non logged operations (BLOCKNONLOGGED) = NO
Percent max primary log space by transaction (MAX_LOG) = 0
Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0
Percent log file reclaimed before soft chckpt (SOFTMAX) = 300
User exit for logging enabled (USEREXIT) = OFF
HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
First log archive method (LOGARCHMETH1) = TSM
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = OFF
Options for logarchmeth2 (LOGARCHOPT2) =
Failover log archive path (FAILARCHPATH) = /db2/QAS/FArch/
Number of log archive retries on error (NUMARCHRETRY) = 5

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

Buscar dentro del snapshot de la BD con el comodin grep

db2 get snapshot for database on qas|grep log

db2qas> db2 get snapshot for database on qas|grep log


Catalog database partition number = 0
Catalog network node name =
Buffer pool data logical reads = 56429368251
Buffer pool temporary data logical reads = 10848752
Buffer pool index logical reads = 10688365721
Buffer pool temporary index logical reads = 0
Buffer pool xda logical reads = 0
Buffer pool temporary xda logical reads = 0
Maximum secondary log space used (Bytes) = 0
Maximum total log space used (Bytes) = 4307028331
Secondary logs allocated currently = 0
Number write log IOs = 59394875
Number read log IOs = 9
Number partial page log IOs = 51004684
Number log buffer full = 6
File number of first active log = 44195
File number of last active log = 44344
File number of current active log = 44195
File number of log being archived = Not applicable
Catalog cache lookups = 55174062
Catalog cache inserts = 6583
Catalog cache overflows = 0
Catalog cache high water mark = 64557836
Catalog cache statistics size = 0
Memory Pool Type = Catalog Cache Heap

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

Listar los tablespaces

d2 list tablespaces

Tablespaces for Current Database

Tablespace ID = 0
Name = SYSCATSPACE
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal

Tablespace ID = 1
Name = ZSAPDATAI
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000

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

Listar la información de todos los contenedores

Ls=`db2 LIST DATABASE DIRECTORY|grep 'Database name'|awk '{print $4}'|sed '/^$/d'`


for I in $Ls
do
ARCH=$I.txt
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
db2 connect to $I
db2 get snapshot for tablespaces on $I |egrep 'Tablespace name|Container Name'
db2 disconnect $I
done

Database Connection Information

Database server = DB2/AIX64 9.7.9


SQL authorization ID = DB2QAS
Local database alias = QAS

Tablespace name = SYSCATSPACE


Container Name =
/db2/PRD/sapdata3/db2qas/NODE0000/QAS/T0000000/C0000000.CAT
Container Name =
/db2/PRD/sapdata1/db2qas/NODE0000/QAS/T0000000/C0000001.CAT
Container Name =
/db2/PRD/sapdata2/db2qas/NODE0000/QAS/T0000000/C0000002.CAT
Container Name =
/db2/PRD/sapdata7/db2qas/NODE0000/QAS/T0000000/C0000003.CAT
Container Name =
/db2/PRD/sapdata6/db2qas/NODE0000/QAS/T0000000/C0000004.CAT
Container Name =
/db2/PRD/sapdata11/db2qas/NODE0000/QAS/T0000000/C0000005.CAT
Container Name =
/db2/PRD/sapdata5/db2qas/NODE0000/QAS/T0000000/C0000006.CAT
Container Name =
/db2/PRD/sapdata8/db2qas/NODE0000/QAS/T0000000/C0000007.CAT
Container Name =
/db2/PRD/sapdata12/db2qas/NODE0000/QAS/T0000000/C0000008.CAT
Container Name =
/db2/PRD/sapdata4/db2qas/NODE0000/QAS/T0000000/C0000009.CAT
Container Name =
/db2/PRD/sapdata9/db2qas/NODE0000/QAS/T0000000/C0000010.CAT
Container Name =
/db2/PRD/sapdata10/db2qas/NODE0000/QAS/T0000000/C0000011.CAT
Tablespace name = ZSAPDATAI
Container Name =
/db2/PRD/sapdata3/db2qas/NODE0000/QAS/T0000001/C0000000.LRG
Container Name =
/db2/PRD/sapdata1/db2qas/NODE0000/QAS/T0000001/C0000001.LRG
Container Name =
/db2/PRD/sapdata2/db2qas/NODE0000/QAS/T0000001/C0000002.LRG
Container Name =
/db2/PRD/sapdata7/db2qas/NODE0000/QAS/T0000001/C0000003.LRG
Container Name =
/db2/PRD/sapdata6/db2qas/NODE0000/QAS/T0000001/C0000004.LRG
Container Name =
/db2/PRD/sapdata11/db2qas/NODE0000/QAS/T0000001/C0000005.LRG
Container Name =
/db2/PRD/sapdata5/db2qas/NODE0000/QAS/T0000001/C0000006.LRG
Container Name =
/db2/PRD/sapdata8/db2qas/NODE0000/QAS/T0000001/C0000007.LRG
Container Name =
/db2/PRD/sapdata12/db2qas/NODE0000/QAS/T0000001/C0000008.LRG
Container Name =
/db2/PRD/sapdata4/db2qas/NODE0000/QAS/T0000001/C0000009.LRG
Container Name =
/db2/PRD/sapdata9/db2qas/NODE0000/QAS/T0000001/C0000010.LRG
Container Name =
/db2/PRD/sapdata10/db2qas/NODE0000/QAS/T0000001/C0000011.LRG
Tablespace name = ZSAPDATAD
Container Name =
/db2/PRD/sapdata3/db2qas/NODE0000/QAS/T0000002/C0000000.LRG
Container Name =
/db2/PRD/sapdata1/db2qas/NODE0000/QAS/T0000002/C0000001.LRG
Container Name =
/db2/PRD/sapdata2/db2qas/NODE0000/QAS/T0000002/C0000002.LRG
Container Name =
/db2/PRD/sapdata7/db2qas/NODE0000/QAS/T0000002/C0000003.LRG
Container Name =
/db2/PRD/sapdata6/db2qas/NODE0000/QAS/T0000002/C0000004.LRG
Container Name =
/db2/PRD/sapdata5/db2qas/NODE0000/QAS/T0000002/C0000005.LRG
Container Name =
/db2/PRD/sapdata8/db2qas/NODE0000/QAS/T0000002/C0000006.LRG
Container Name =
/db2/PRD/sapdata12/db2qas/NODE0000/QAS/T0000002/C0000007.LRG
Container Name =
/db2/PRD/sapdata11/db2qas/NODE0000/QAS/T0000002/C0000008.LRG
Container Name =
/db2/PRD/sapdata10/db2qas/NODE0000/QAS/T0000002/C0000009.LRG
Container Name =
/db2/PRD/sapdata9/db2qas/NODE0000/QAS/T0000002/C0000010.LRG
Container Name =
/db2/PRD/sapdata4/db2qas/NODE0000/QAS/T0000002/C0000011.LRG

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

Parametro de auto almacenamiento de espacio de los tablespaces

db2 get snapshot for tablespaces on qas | grep automatic

db2qas> db2 get snapshot for tablespaces on qas | grep automatic


Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = No
Using automatic storage = No
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes
Using automatic storage = Yes

ver prilogs

db2 get snapshot for database on DDS | grep -i "Log"

You might also like