How to create DB2 Instance on Linux

DB2 Instance:

DB2 Instance is a run time environment under which database runs. Instance is used to configure run time environment using Database Manager Configuration (DBM) parameters and registry variables. You can have multiple instance on same server depending upon your server resource configuration. Databases are unique within the instance. You cannot have 2 database with same name in one instance but you can have 2 database with same name in different instance on same server. E.g. You cannot have 2 database with same name i.e. TESTDB in one instance i.e. db2i1 but you can have 2 database with same name i.e. TESTDB in two instance on server i.e. db2i1 and db2i2. In this blog we will see step by step procedure to create DB2 Instance on Linux server. This same steps can be followed for not only Linux environment but it is applicable for any unix environment which is supported by DB2.

Prerequisite :

To create DB2 instance on linux server you would need 2 OS user (instance id and fenced id)  which is not mapped with any other DB2 instance.
DB2 instance username should not be more than 8 character long. If you want to use more than 8 character long username for DB2 instance then ensure your operating system supports long ids.
DB2 Instance username cannot be GUESTS, LOCAL, PUBLIC, USERS, ADMINS. It cannot begin with IBM, SQL, SYS

Creating OS Users:

useradd -d <user home directory> <username>
-d option is optional


Set password for both user (instance and fenced user) using passwd command



Instance Creation:

To create DB2 instance in non-root installation you would need root privilege.
Change working directory to <db2 installation folder>/instance
To get db2 installation path use db2ls command


Under instance directory list db2icrt file
ls -lrt db2icrt


Execute db2icrt to create instance

./db2icrt -u <fenced id> <db2instance id>


Connect to DB2 instance

su - <db2instance id>


After successful instance creation in your instance user home directory you would find sqllib directory.

Start DB2 Instance

db2start


As I have installed trail version of DB2 11.1 I got warning message.




If you liked this blog and interested in knowing more about DB2, please subscribe by clicking on Subscribe to ChoudharySumit.com by Email.

14 comments:

  1. This is very helpful for beginners as well as professionals.

    ReplyDelete
  2. Superb!! Great initiative.It will really helpful...👍

    ReplyDelete
  3. it was really helpful sumit, thank you for the blog and support which you provided me.

    ReplyDelete
  4. Very helpful blog Sumit. Thanks

    ReplyDelete
  5. Sumit,

    Great, thanks for the hardwork

    After installation of DB2 on linux, what will be the Endian format of the database.

    ReplyDelete
    Replies
    1. Linux x86-64 system it will be Little endian.

      Delete
  6. Hi, Thanks for publishing the Informative installation procedure,

    localhost:/opt/ibm/db2/V11.5/instance # ./db2icrt -u db2fencl db2inst1
    DBI1446I The db2icrt command is running.


    DB2 installation is being initialized.

    The instance home directory "/root" is invalid because it is not owned by the
    user "db2inst1". Change the ownership of the home directory to be owned by the
    instance user and its primary group.

    A major error occurred during the execution that caused this program to
    terminate prematurely. If the problem persists, contact your technical service
    representative.

    For more information see the DB2 installation log at "/tmp/db2icrt.log.17706".
    DBI1264E This program failed. Errors encountered during execution were
    written to the installation log file. Program name:
    db2icrt. Log file name: /tmp/db2icrt.log.17706.

    ReplyDelete
    Replies
    1. It seems your instance user home directory is incorrect... recreate your instance user with correct home directory and try again.

      Delete