Tuesday, March 22, 2011

Changing installpaths using db2iupdt command

Hello All,

Here is my current install path : "/opt/ibm/db2/V9.1". Is it possible to change the install path to a new directory once DB2 is installed with a instance/database created.

The answer to this is NO, but we could install DB2 again to the path you wanted and run the db2iupdt command to update the instance to the existing path. Here is a simple test case:

1) Here is the current db2level which confirms my DB2 is installed at "/opt/ibm/db2/V9.1"
DB21085I  Instance "db2v91" uses "64" bits and DB2 code release "SQL09019" with
level identifier "020A0107".
Informational tokens are "DB2 v9.1.0.10", "s110109", "MI00382", and Fix Pack
"10".
Product is installed at "/opt/ibm/db2/V9.1".

2) Using db2_install script I installed DB2 to a different path now : "/opt/ibm/db2/V91FP10". Here is the db2ls output which confirms that I have 2 installs for V9.1 FP-10

db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.1                9.1.0.10       10                            Wed Mar  9 06:35:00 2011 CST             0
/opt/ibm/db2/V91FP10             9.1.0.10       10                            Mon Mar 21 19:32:47 2011 CDT           0

3) Now make sure the instance that is associated with the default install path(i.e /opt/ibm/db2/V9.1) is down completely before we run db2iupdt command: In my testcase it is 'db2v91'

4) Login as root and move to the 'instance' directory under newly created install path and run the 'db2iupdt' command with -D option. Using -D option moves an instance from a higher code level on one path to a lower code level installed on another path.

cd /opt/ibm/db2/V91FP10/instance

./db2iupdt -D db2v91
DBI1070I Program db2iupdt completed successfully.

5) Now logged in as the instance owner 'db2v91' and ran the db2level command and I can see it reflects to the new path:

DB21085I  Instance "db2v91" uses "64" bits and DB2 code release "SQL09019" with
level identifier "020A0107".
Informational tokens are "DB2 v9.1.0.10", "s110109", "MI00382", and Fix Pack
"10".
Product is installed at "/opt/ibm/db2/V91FP10".

Good luck!!

Thanks
Satya 

Monday, March 21, 2011

SECADM

Hello All,

We might get confused from the DB2 9.7 info center documentation regarding who actually gets the SECADM authority. Starting DB2 9.7 we have noticed many changes when it comes to the  security(Eg: The instance owner does not have SECADM authority by default which is unacceptable.)

Coming to SECADM question, since it is a Database authority and specific to a database, the user who creates the database will get the SECADM authority.

Here is a test case...logged in as the user 'v97fp2' and created a 'db1' database.

- db2 create db db1
DB20000I  The CREATE DATABASE command completed successfully.

- db2 connect to db1

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.2
 SQL authorization ID   = V97FP2
 Local database alias   = DB1

- db2 "select grantee, securityadmauth from syscat.dbauth"

GRANTEE          SECURITYADMAUTH
---------------- ---------------
V97FP2                  Y --> Automatically got the SECADM authority.
PUBLIC                  N

  2 record(s) selected.

NOTE: SECADM authority can be granted only by the security administrator (who holds SECADM authority) and can be granted to a user, a group, or a role.

Thanks
Samyn

db2imigr vs db2iupgrade

Hello All, 

If you are migrating the instance from DB2 V9.1 to V9.5:

1) Since we are migrating the instance from V9.1 to V9.5, make sure we meet the Prerequisites before starting the migration process.

Migration for DB2 servers:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.qb.migration.doc/doc/c0011933.html

2) Once we meet the  Prerequisites, we migrate the instance to 9.5 using "db2imigr" command.

3) Once done migrating the instance to 9.5, we migrate the database's under that instance using "migrate database" command.

====

If you are migrating the instance from DB2 V9.1 to V9.7:

1) Since we are migrating the instance from V9.1 to V9.7, make sure we meet the Prerequisites before starting the migration process:

Upgrade essentials for DB2 servers:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.qb.upgrade.doc/doc/c0023734.html

2) Once we meet the  Prerequisites, we migrate the instance to 9.7 using the "db2iupgrade" command since db2imigr is deprecated.

3) Once done upgrading the instance to 9.7, we upgrade the database's under that instance using "upgrade database" command.

We use db2imigr and db2iupgrade commands only when upgrading the instance from a lower version. db2imigr is deprecated starting DB2 9.7 and we use db2iupgrade instead.

Thanks
Samyn

Tuesday, March 8, 2011

Best method to do DB2 Offline Backup's

db2 connect to <database_name>
db2 quiesce database immediate force connections
db2 terminate
db2 deactivate db <database_name>
db2 backup db <database_name> to <directory_path>
db2 connect to <database_name>
db2 unquiesce database
db2 terminate

I suggest you to follow the above steps if you have a application server which has retry logic and attempting to make a connection to the database all the time.

Saturday, February 26, 2011

Creating the Instance using db2icrt

Only one instance can be created under a user name. db2icrt command is not available for a non-root installation of DB2 database products on Linux and UNIX operating systems.

1) Login in as root. If you are using the su command to become the root user ensure to issue the su command with the '-' option. This sets the environment as if you had logged in to the system using the "login" command.

2) Creating an instance for the user ID db2v97 on a client machine.

DB2DIR/instance/db2icrt db2v97 (where DB2DIR is the install location)

Install path in this example is "/opt/ibm/db2/V9.7". Now ran the following command "instance" directory under the install path.

./db2icrt db2v97
DBI1070I  Program db2icrt completed successfully.

3) Creating an instance for the user ID db2v97 and db2fenc on a server machine.

 ./db2icrt -u db2fenc db2v97
DBI1070I  Program db2icrt completed successfully.

The -u option specifies the fenced user ID. It is mandatory to create a fence ID while creating the instance on a server machine. You can also use the same user for the fence ID as well. Here is an example:

 ./db2icrt -u db2v97 db2v97
DBI1070I  Program db2icrt completed successfully.

Note that it is not supported to run db2icrt command when you source the DB2 instance environment.

Good Luck everyone!!

Thanks
Samyn

DB2 Installation with db2_install script

Hi,

Lets get started with the installation of DB2 using "db2_install" script on LINUX and UNIX platforms. You can also install DB2 using "db2setup" which launches the GUI wizard.

1) Firstly download the image and this can be done in 2 ways:
-- From the passport advantage site where you login in with your customer ID and password. Normally this image will be GA which comes with a license.

-- From the fixpack central site 
https://www-304.ibm.com/support/docview.wss?rs=71uid=swg27007053 
You have to apply the license once you install the product since this comes with 90 day trial period. Note that you can install the complete product from a fixpack image starting V9.1

2) Use the wget command for faster download to your server.
Here is an example:  
wget http://delivery04.dhe.ibm.com/sar/CMA/IMA/02bnh/0/v9.5fp7_linuxx64_server.tar.gz

3) Unzip and Untar the downloaded image as below:
-- gunzip v9.5fp7_linuxx64_server.tar.gz
-- tar -xvf v9.5fp7_linuxx64_server.tar

4) Move to the directory where the install scripts are located by running "cd server". Now run a "ls -l" command and you will notice the following scripts:

ls -l 
total 76
drwxr-xr-x  6 db2v95 db2v95 4096 Dec  4 01:10 db2
-r-xr-xr-x  1 db2v95 db2v95 5293 Dec  4 01:09 db2_deinstall
-r-xr-xr-x  1 db2v95 db2v95 5163 Dec  4 01:08 db2_install
-r-xr-xr-x  1 db2v95 db2v95 5145 Dec  4 01:08 db2prereqcheck
-r-xr-xr-x  1 db2v95 db2v95 5145 Dec  4 01:08 db2setup
drwxr-xr-x 15 db2v95 db2v95 4096 Dec  4 01:09 doc
-r-xr-xr-x  1 db2v95 db2v95 5181 Dec  4 01:10 installFixPack

5) Root installations require root user authority. For non-root installations, you must log on with the user ID that owns the non-root installation. In my example, I did the ESE product install as root.

./db2_install -p ese

It will prompt you for Install path whether you want to keep it to the default or change it as below:

Default directory for installation of products - /opt/ibm/db2/V9.5

***********************************************************
Do you want to choose a different directory to install [yes/no] ?

Enter yes to change the path. In my case I did to the default path.

6) Once done with the install you can run the db2ls to list installed DB2 products.

Install Path        Level   Fix Pack  Special Install Number Install Date              Installer UID
------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.5  9.5.0.7     7                          Fri Feb 25 19:05:05 2011 CST     0


Good Luck Everyone!!!!

Thanks

Friday, February 25, 2011

Kick Start

Hello DB2 lovers and users :)

This blog provides solutions/guidance/new updates for all DB2 users on various platforms(i.e LINUX/UNIX/WINDOWS). If you see flaws in any documentation, please feel free to post your comments/suggestions so that we can make this a better blog and make our DB2 users HAPPY!!.

Thanks
Samyn