This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
database:db2 [2024/03/01 13:11] manu |
database:db2 [2025/07/09 13:54] (current) manu [Suppress Archogs] |
||
|---|---|---|---|
| Line 6: | Line 6: | ||
| [[database:db2_clone_steps|DB2 clone steps]] | [[database:db2_clone_steps|DB2 clone steps]] | ||
| + | |||
| + | [[database:db2_install_steps|DB2 install steps]] | ||
| ====== DB2 command line ====== | ====== DB2 command line ====== | ||
| + | |||
| + | https://www.ibm.com/docs/en/db2/11.5?topic=instances-designing | ||
| https://www.ibm.com/developerworks/servicemanagement/library/sm-tsm-db2/ | https://www.ibm.com/developerworks/servicemanagement/library/sm-tsm-db2/ | ||
| Line 149: | Line 153: | ||
| </cli> | </cli> | ||
| - | | + | ===== Update a user password ===== |
| + | |||
| + | For example, use the CONNECT statement to change the password of the user instance, | ||
| + | <cli prompt='$'> | ||
| + | $ db2 "CONNECT TO <database> USER <userid> USING <password> NEW <new_password> CONFIRM <new_password>" | ||
| + | </cli> | ||
| ===== DB2 list command ===== | ===== DB2 list command ===== | ||
| Line 334: | Line 343: | ||
| </cli> | </cli> | ||
| + | ==== Suppress Archlogs ==== | ||
| + | |||
| + | When doing online backup, you have to manually purge and suppress archlogs: | ||
| + | |||
| + | Example suppress archlogs older than 100 days, before 2024/12: | ||
| + | <cli prompt='$'> | ||
| + | $ db2 connect to TSMDB1 | ||
| + | |||
| + | $ db2 list history TSMDB1 | grep X |grep D | ||
| + | $ db2 prune history 202412 with force option and delete | ||
| + | |||
| + | $ find /db2archlog/db2inst1/TSMDB1 -type f -name "*.LOG" -ctime +100 -exec rm {} \; | ||
| + | </cli> | ||
| ===== Backup/restore DB2 database ===== | ===== Backup/restore DB2 database ===== | ||
| Line 798: | Line 820: | ||
| To reorganize a DB2 database, you can enable the parameter: AUTO_REORG | To reorganize a DB2 database, you can enable the parameter: AUTO_REORG | ||
| <cli prompt='$'> | <cli prompt='$'> | ||
| - | [db2sc@sptl779l ~]$ db2 get db cfg for TPCDB | grep reorg | + | [db2sc@lnx779l ~]$ db2 get db cfg for TPCDB | grep reorg |
| Automatic reorganization (AUTO_REORG) = OFF | Automatic reorganization (AUTO_REORG) = OFF | ||
| - | [db2sc@sptl779l ~]$ db2 update db cfg for TPCDB using auto_reorg on | + | [db2sc@lnx779l ~]$ db2 update db cfg for TPCDB using auto_reorg on |
| DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. | DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. | ||
| - | [db2sc@sptl779l ~]$ db2 get db cfg for TPCDB | grep reorg | + | [db2sc@lnx779l ~]$ db2 get db cfg for TPCDB | grep reorg |
| Automatic reorganization (AUTO_REORG) = ON | Automatic reorganization (AUTO_REORG) = ON | ||
| </cli> | </cli> | ||
| + | The 3 folowing parameters have to be set to ON | ||
| + | db2 update db cfg for <db_name> using auto_maint on | ||
| + | db2 update db cfg for <db_name> using auto_tbl_maint on | ||
| + | db2 update db cfg for <db_name> using auto_reorg on | ||
| + | |||
| + | List historic | ||
| + | <cli prompt='$'> | ||
| + | [db2sc@lnx779l ~]$ db2 -v "list history reorg all for TPCDB" | ||
| + | Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID | ||
| + | -- --- ------------------ ---- --- ------------ ------------ -------------- | ||
| + | G T 20210122103457 F S0000000.LOG S0000002.LOG | ||
| + | ---------------------------------------------------------------------------- | ||
| + | Table: "TPC "."T_STORAGE_VOLUME" | ||
| + | ---------------------------------------------------------------------------- | ||
| + | Comment: REORG | ||
| + | Start Time: 20210122103457 | ||
| + | End Time: 20210122103457 | ||
| + | Status: A | ||
| + | ---------------------------------------------------------------------------- | ||
| + | EID: 702 | ||
| + | |||
| + | Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID | ||
| + | -- --- ------------------ ---- --- ------------ ------------ -------------- | ||
| + | G T 20210122103457 F S0000000.LOG S0000002.LOG | ||
| + | ---------------------------------------------------------------------------- | ||
| + | Table: "TPC "."T_RES_REGISTERED_NAPI" | ||
| + | |||
| + | ---------------------------------------------------------------------------- | ||
| + | Comment: REORG | ||
| + | Start Time: 20210122103457 | ||
| + | End Time: 20210122103457 | ||
| + | Status: A | ||
| + | ---------------------------------------------------------------------------- | ||
| + | EID: 703 | ||
| + | </cli> | ||
| + | |||
| + | List DB size | ||
| + | <cli prompt='$'> | ||
| + | [db2sc@lnxl779l ~]$ db2 "CALL GET_DBSIZE_INFO (?, ?, ?, -1)" | ||
| + | |||
| + | Value of output parameters | ||
| + | -------------------------- | ||
| + | Parameter Name : SNAPSHOTTIMESTAMP | ||
| + | Parameter Value : 2024-03-01-13.18.40.360884 | ||
| + | |||
| + | Parameter Name : DATABASESIZE | ||
| + | Parameter Value : 381817823232 | ||
| + | |||
| + | Parameter Name : DATABASECAPACITY | ||
| + | Parameter Value : 489766322176 | ||
| + | |||
| + | Return Status = 0 | ||
| + | </cli> | ||
| + | |||
| + | https://datageek.blog/2014/06/02/how-to-tell-when-a-table-reorg-is-needed/ | ||
| + | |||
| + | ===== Uninstall DB2 ===== | ||
| + | |||
| + | <cli prompt='#'> | ||
| + | [root@lnx01] /tmp/db2/universal # ./db2_deinstall -a -b /opt/ibm/db2/V11.5 | ||
| + | DBI1016I Program db2_deinstall is performing uninstallation. Please | ||
| + | </cli> | ||