Creating multiple DB2 database instances

Create multiple DB2 database instances using the DB2® Command Line Processor. If you need to have only one database instance, you can skip this task.

About this task

When you create multiple database instances, you must install the databases on each instance. If you use the database wizard to install the databases, prepare and run the database wizard once for each instance. If you use the scripts to install the databases, run the scripts once for each instance.

Creating multiple DB2 database instances on AIX

Procedure

Attention:
  • For each instance that you want to create, log in as the instance owner before creating the instance.
  • Use the DB2 Command Line Processor to enter commands.
  • After creating the instance, add the instance to the user environment variable. The instance is then visible in the DB2 Control Center.
  • An instance called db2inst1 is created during DB2 installation.
To create DB2 database instances on AIX, follow these steps:

  1. Create a group for DB2:mkgroup db2iadm1
  2. Create a user for DB2:mkuser groups=db2iadm1 db2instN, where db2instN is the name of a user. DB2 prompts you to enter a password for the user. Repeat this step to create enough users to match the number of database instances.
  3. To create DB2 instances, log in with root user and go to /opt/IBM/db2/V9.5/instance.
    ./db2icrt -u db2instN db2instN
    where db2instN is the name of a user and also the name of an instance. Repeat this step to create enough instances to match the number of databases.
  4. To set the port number of the instance, edit the/etc/services file and add the following line: db2c_instance_name instance_port/tcpwhere instance_name is the name of the instance and instance_port is the port number of that instance. Repeat this step for each instance.
  5. Set the communication protocols for the instance:
    db2 update database manager configuration using svcename db2c_instance_name
    db2set DB2COMM=tcpip
    db2stop
    db2start
    Repeat this step for each instance.
  6. Edit your firewall configuration to allow the new instances to communicate through their listening ports.

Creating multiple DB2 database instances on Linux

Procedure

Attention:
  • For each instance that you want to create, log in as the instance owner before creating the instance.
  • Use the DB2 Command Line Processor to enter commands.
  • After creating the instance, add the instance to the user environment variable. The instance is then visible in the DB2 Control Center.
  • An instance called db2inst1 is created during DB2 installation, along with three users: db2inst1, db2fenc1, and dasusr1.
To create DB2 database instances on Linux, follow these steps:

  1. Create groups for DB2:
    groupadd -g 999 db2iadm1 
    groupadd -g 998 db2fadm1 
    groupadd -g 997 dasadm1 
  2. Create users for DB2:
    useradd -u 1100 -g db2iadm1 -m -d /home/db2instN db2instN -p db2instX
    where db2instN is the name of a user and db2instX is the password for that user. Create enough users to match the number of database instances.
  3. Create the db2fenc1 user for DB2 in the db2fadm1 group:

    useradd -u 1101 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 -p db2instX

  4. Create the db2fenc1 user for DB2 in the db2fadm1 group:

    useradd -u 1101 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 -p db2instX

  5. Create the dasusr1 user for DB2 in the dasadm1 group:

    useradd -u 1102 -g dasadm1 -m -d /home/dasadm1 dasusr1 -p db2instX

  6. To create new DB2 instances, log in with root user and go to /opt/ibm/db2/V9.5/instance.

    ./db2icrt -u db2fenc1 db2instN

    Create enough instances to match the number of databases.

  7. To set the port number of the instance, edit the /etc/services file and add the following line:

    db2c_<instance_name> <instance_port>/tcp

    where instance_name is the name of the instance and instance_port is the port number of that instance. Repeat this step for each instance.
  8. Log in as the database instance and set the communication protocols for the instance:
    su - db2instN
    db2 update database manager configuration using svcename 
     db2c_instance_name
    db2set DB2COMM=tcpip
    db2stop
    db2start
    Repeat this step for each instance.
  9. Edit your firewall configuration to allow the new instances to communicate through their listening ports.

Creating multiple DB2 database instances on Windows

Before you begin

Complete these steps for each instance that you plan to create:
  1. Create a new user and add it to the Administrators group.
    Note: If you are using DB2, also add the new user to the DB2ADMNS group.
  2. Remove the user account from the Users group.
  3. Grant rights to the new user:
    1. Click Start > Run and enter secpol.msc.
    2. Expand Local Policies and click User Rights Assignment.
    3. Open each of the following rights, click Add User or Groupand add the new user:
      • Act as part of the operating system
      • Adjust memory quotas|Increase quotas for a process
      • Create a token object
      • Debug programs
      • Lock pages in memory
      • Log on as a service
      • Replace a process level token
Tip: The new account uses the local system as the domain.

Procedure

Attention:
  • For each instance that you want to create, log in as the instance owner before creating the instance.
  • Use the DB2 Command Line Processor to enter commands.
  • After creating the instance, add the instance to the user environment variable. The instance is then visible in the DB2 Control Center.
To create DB2 database instances on Windows, follow these steps:

  1. Create an instance: db2icrt instance_name -s ese -u db2_admin_user where instance_name is the name of the instance and db2_admin_user is the user account for that instance.
  2. To set the port number of the instance, edit the C:\WINDOWS\system32\drivers\etc\services file and add the following line: db2c_instance_name instance_port/tcp
  3. Set the current instance parameter:set DB2INSTANCE=instance_name
  4. Set the communication protocols for the instance:
    db2 update database manager configuration using svcename   db2c_instance_name
    db2set DB2COMM=npipe,tcpip
    db2stop
    db2start
  5. Edit your firewall configuration to allow the new instances to communicate through their listening ports.