May 2020
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

WordPress Quotes

History is a relentless master. It has no present, only the past rushing into the future. To try to hold fast is to be swept aside.
John F. Kennedy
May 2020
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728293031

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (40)
Ansibile (19)
Apache (135)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (270)
centos8 (3)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (2)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Ubuntu (1)
Uncategorized (30)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

0 visitors online now
0 guests, 0 bots, 0 members

Hit Counter provided by dental implants orange county

DB2 Basics

How to get a snapshot for DB2

db2 get snapshot for dynamic sql write to file on dbname | tee output.file

or

db2 "select * from table( SNAPSHOT_DYN_SQL(dbname',-1) as t"

[edit]How to check DB2 licence

/export/home/ldapdb2/sqllib/adm/db2licm -l

[edit]How to get the DB2 version

db2level

[edit]How to make sure DB2 starts and works with WAS on AIX.

Modify startServer.sh – add

. ~db2inst1/sqllib/db2profile

or add the lines below to the file /etc/profile, and .dtprofile:

#The following three lines have been added by UDB DB2.
if [ -f /home/wasadmin/sqllib/db2profile ]; then
. /home/wasadmin/sqllib/db2profile
fi

[edit]How to move a DB2 database

chown ldapdb2 /ldapfs
su - ldapdb2
db2start
db2 force application all
db2 termincate
db2 backup db ldapdb2 to /Another_filesystem
db2 drop db ldapdb2
db2 create db ldapdb2 on /ldapfs
db2 force application all
db2 termincate
db2 restore db ldapdb2 from /Another_filesystem replace existing redirect
db2 "set tablespace containers for 3 using (path '/disks/1/3', path '/disks/2/3', path '/disks/3/3', path '/disks/4/3', path '/disks/5/3')"
db2 restore db ldapdb2 continue

Additionally, I recommend you to set the path to the DB2 log file directory on another file system to eliminate output I/O wait time as follows:

db2 update database configuration for ldapdb2 using newlogpath [path]

[edit]How to stop db2 instance when it is still active

Often I met this problem when I want to stop the db2 instance using

db2stop
SQL1025N The database manager was not stopped because databases are still active.

Here you can find a solution

This appendix describes the necessary steps to stop and start a DB2 instance. There are many ways to stop and start a DB2 instance, but the following steps will guide you to stop a DB2 instance to ensure that any defunct DB2 processes, interprocess communications, and defunct DARI processes have been removed successfully.

Current configuration:Instance: db2inst1 Database: sample Server: phantom

Stop the DB2 instance. Check existing applications that are currently connected to the database by logging on to phantom server as DB2 instance owner db2inst1:

$ db2 list applications

Auth Id   Appl. Name   Appl.. Handle   Appl. Id                       DB Name   # of Agents
-------   ----------   -------------   ----------------------------   -------   -----------
DB2INST1  db2bp        207             *LOCAL.db2inst1.010824003917   SAMPLE    1
DB2INST1  java         276             CCF21FFC.E5D8.010829004049     SAMPLE    1
DB2INST1  java         51              CCF21FFC.E5D9.010829004051     SAMPLE    1

If there is any application connected to the database, you can tell who is currently connected and from which location they are connected. In this case, there is one local connection from db2inst1 user ID, and there are two remote connections from IP address: xxx.xxx.31.252 converted from hex to decimal: CCF21FFC.

For remote connections, after you get the IP address, you can get the hostname by issuing the nslookup command:

$ /usr/sbin/nslookup xxx.242.31.252

Server:  charter.xxx.com
Address:  xxx.242.31.83

Name:    phantom.xxx.com
Address:  xxx.242.31.252

If there are any applications connected to the database, verify that they are not currently executing:

$ db2 list applications show detail | egrep -i "executing|pending"

If there are applications executing or pending, you can now force them off. Then verify to make sure there is no application connected to the database. If you see the following message, you’re ready to stop the DB2 instance:

$ db2 force application all

DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

$ db2 list applications

SQL1611W  No data was returned by Database System Monitor.  SQLSTATE=00000

Now you can stop the DB2 instance. When you get the message “SQL1064N DB2STOP processing was successful” you’re ready to do the next step. If you get the message below, you must start this step again:

$ db2stop

SQL1025N  The database manager was not stopped because databases are still active.

LAST RESORT. If for some reason you cannot stop the DB2 instance or DB2 commands are hung, you must run this utility to remove the DB2 engine and client’s IPC resources for that instance. This is your lifesaver:

$ ipclean

ipclean: Removing DB2 engine and client's IPC resources for db2inst1.

Stop the DB2 Administration Server instance. Skip this step if DB2 Admin instance is not running; otherwise, execute this command:

$ db2admin stop

Remove defunct DARI processes, DB2 background processes, or other defunct threads. List all DB2 processes for this instance:

$ ps -ef | grep db2

db2as 23797 23796  0   Aug 28 ?        0:00 db2sysc
db2as 23800 23798  0   Aug 28 ?        0:00 db2sysc
db2inst1 22229     1  0 13:08:01 pts/5    0:00 /db2/dbhome/db2inst1/sqllib/bin/db2bp 20580 5
db2as 23802 23797  0   Aug 28 ?        0:00 db2sysc
db2as 23801 23797  0   Aug 28 ?        0:00 db2sysc
db2as 23799 23797  0   Aug 28 ?        0:00 db2sysc

From the list above, we notice that there are processes belonging to the DB2 Admin services instance, so you must leave them alone. There is only one process that belongs to db2inst1, and that is a DB2 background process that did not get cleaned up after executing ipclean. Get the PID number and kill that process:

$ kill -9 22229

Most of the time, you will see many defunct processes, and to save time, you should execute the following command instead of executing the kill -9 ${PID} command many times:

$ ps -ef | grep db2inst1 | awk '{print "kill -9 "$2}' > /tmp/kpid
$ chmod +x /tmp/kpid
$ /tmp/kpid

Verify that no defunct processes are left. Repeat this step if necessary:

$ ps -ef | grep db2inst1

Remove defunct interprocess communication segments.

List all memory segments:

$ ipcs -am | grep db2inst1
IPC status from  as of Thu Aug 30 13:16:55 2001
T      ID            KEY            MODE           OWNER          GROUP
Shared Memory:
m      9910          0x74006380     --rw-rw-rw-    db2inst1       db2grp
m      59714         0x61006380     --rw-------    db2inst1       db2grp

From the list above, you notice that there are two memory segments that were not removed when executing ipclean. You must remove them manually:

$ ipcrm -m 9910
$ ipcrm -m 59714

List all semaphore segments:

$ ipcs -as | grep db2inst1
IPC status from  as of Thu Aug 30 13:16:55 2001
T      ID          KEY          MODE         OWNER        GROUP
Shared Memory:
s      1900549     0x74006380   --ra-ra-ra-  db2inst1     db2grp   1
s      1310727     00000000     --ra-ra----  db2inst1     db2grp   1
s      2031624     0x73006380   --ra-ra-ra-  db2inst1     db2grp   1

From the list above, notice that there are three semaphore segments that were not removed after executing ipclean. You must remove them manually:

$ ipcrm -s 1900549
$ ipcrm -s 1310727
$ ipcrm -s 2031624

List all message queue segments:

$ ipcs -aq | grep db2inst1

IPC status from  as of Thu Aug 30 13:16:55 2001
T           ID         KEY         MODE         OWNER     GROUP
Shared Memory:
q           1572868    0x01dadd16  -Rrw-------  db2inst1  db2grp 65535
q           901125     0x01eba5ed  --rw-------  db2inst1  db2grp 65535
q           1609739    00000000    --rw-------  db2inst1  db2grp 65535
q           659468     00000000    -Rrw-------  db2inst1  db2grp 65535

From the list above, notice that there are four message queue segments that were not removed after executing ipclean. You must remove them manually:

$ ipcrm -q 1572868
$ ipcrm -q 901125
$ ipcrm -q 1609739
$ ipcrm -q 659468

Verify that there are no defunct interprocess communications left. Repeat this step if necessary:

$ ipcs -a | grep db2inst1

Before you start the DB2 instance, it is best practice to back up the previous db2diag.log, any event logs, notification log, and the associated trap files, and start with a fresh copy. Move the current db2diag.log to the backup directory:

$ mkdir -p /db2/backup/db2inst1/diaglogSep12
$ cd /db2/dbhome/db2inst1/sqllib/db2dump
$ mv db2diag.log /db2/backup/db2inst1/diaglogSep12/
$ mv db2eventlog* /db2/backup/db2inst1/diaglogSep12/
$ mv db2inst1.nfy /db2/backup/db2inst1/diaglogSep12/
$ touch db2diag.log db2inst1.nfy db2eventlog.nnn where nnn is the database partition number
$ chmod 664 db2diag.log db2inst1.nfy db2eventlog.*

If there are any trap files, group them together:

$ cd /db2/dbhome/db2inst1/sqllib/db2dump
$ tar -cvf /db2/backup/db2inst1/diaglog/trapAug292001.tar t* c* l* [0-9]*

Or execute this keepDiagLog.sh script:

#!/bin/ksh
#
# Clean up db2diag.log, trap files, dump files, etc
#
# Usage:  keepDiagLog.sh
#
# Execute as DB2 instance owner
#
LOGTIME=`date '+%y%m%d%H%M%S'`
DIAGDIR=${HOME}/sqllib/db2dump
typeset instname=${1-db2inst1}
typeset ROOTDIR=${2-/dbbackup}
typeset dbname=${3-sample}
typeset OLDDIR=${4-${ROOTDIR}/${instname}/${dbname}/db2diag${LOGTIME}}
mkdir -p ${OLDDIR}
cd ${DIAGDIR}
cp -r * ${OLDDIR}/
for j in `ls`
do
  if  [ -d "${j}" ]; then
    rm -r ${j}
  else
    rm ${j}
  fi
done
touch db2diag.log ${instname}.nfy
chmod 666 db2diag.log ${instname}.nfy
exit 0
# You need to add the steps for the event log files based on the
# number of database partitions defined on your server.

Now you’re ready to start the DB2 instance. Start the DB2 instance:

$ db2start

SQL1063N  DB2START processing was successful.

And you’re ready to start the DB2 Admin instance. Start the DB2 Admin instance:

$ db2admin start

Verify the database connection.

Connect to the sample database:

$ db2 connect to sample

   Database Connection Information
 Database server        = DB2/SUN 8.1.0
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

Disconnect from the sample database:

 $ db2 terminate

Reactivate the database to improve performance.

Activate the sample database:

$ db2 activate database sample
DB20000I  The ACTIVATE DATABASE command completed successfully.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam