Monday, May 7, 2012

How to create multiple instances on a database


Creating multiple database instances

Create multiple instances of a database for a more versatile database environment.
Before you begin
A database environment with multiple instances provides the flexibility to tune an instance for a particular configuration, use different instances for development and production, restrict access to sensitive information, and optimize the database manager configuration for each instance.Creating multiple instances requires additional system resources.
About this task
To create multiple instances of a database, complete the following steps:
Choose your database type:
  • DB2
    • AIX®:An instance called db2inst1 is created during DB2® installation.
      1. Create a group for DB2:
        mkgroup db2iadm1
      2. Create users for DB2:
        mkuser groups=db2iadm1 db2inst2
        passwd db2inst2
        mkuser groups=db2iadm1 db2inst3
        passwd db2inst3
        mkuser groups=db2iadm1 db2inst4
        passwd db2inst4
        mkuser groups=db2iadm1 db2inst5
        passwd db2inst5
        mkuser groups=db2iadm1 db2inst6
        passwd db2inst6
      3. Create new DB2 instances:Login with root user and go to /opt/IBM/db2/V9.1/instance.
        ./db2icrt -u db2inst2 db2inst2
        ./db2icrt -u db2inst3 db2inst3
        ./db2icrt -u db2inst4 db2inst4
        ./db2icrt -u db2inst5 db2inst5
        ./db2icrt -u db2inst6 db2inst6
      4. Set the port number of the instance:Edit the/etc/services file and add the following line:
        db2c_<inst_name> <inst_port>/tcp
      5. Set the communication protocols for the instance:
        db2 update database manager configuration using svcename db2c_<inst_name>
        db2set DB2COMM=tcpip
        db2stop
        db2start
    • Linux®:An instance called db2inst1 is created during DB2 installation, along with three users: db2inst1,db2fenc1,dasusr1.
      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/db2inst1 db2inst1 -p passw0rd
        useradd -u 1101 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 -p passw0rd 
        useradd -u 1102 -g dasadm1 -m -d /home/dasadm1 dasusr1 -p passw0rd
        
        useradd -u 1103 -g db2iadm1 -m -d /home/db2inst2 db2inst2 -p passw0rd
        useradd -u 1104 -g db2iadm1 -m -d /home/db2inst3 db2inst3 -p passw0rd
        useradd -u 1105 -g db2iadm1 -m -d /home/db2inst4 db2inst4 -p passw0rd
        useradd -u 1106 -g db2iadm1 -m -d /home/db2inst5 db2inst5 -p passw0rd
        useradd -u 1107 -g db2iadm1 -m -d /home/db2inst6 db2inst6 -p passw0rd
      3. Create new DB2 instances:Login with root user and go to /opt/IBM/db2/V9.1/instance.
        ./db2icrt -u db2fenc1 db2inst1 
        ./db2icrt -u db2fenc1 db2inst2
        ./db2icrt -u db2fenc1 db2inst3
        ./db2icrt -u db2fenc1 db2inst4
        ./db2icrt -u db2fenc1 db2inst5
        ./db2icrt -u db2fenc1 db2inst6
      4. Set the port number of the instance:Edit the/etc/services file and add the following line:
        db2c_<inst_name> <inst_port>/tcp
      5. Set the communication protocols for the instance:
        db2 update database manager configuration using svcename 
         db2c_<inst_name>
        db2set DB2COMM=tcpip
        db2stop
        db2start
    • Windows®:
      1. Create an instance by running the following command:db2icrt <inst_name> -s ese -u <db2_admin_user>
      2. Set the port number of the instance:Edit the C:\WINDOWS\system32\drivers\etc\services file and add the following line:
        db2c_<inst_name> <inst_port>/tcp
      3. Set the communication protocols for the instance:
        db2 update database manager configuration using svcename 
         db2c_<inst_name>
        db2set DB2COMM=npipe,tcpip
        db2stop
        db2start
      4. Set the current instance parameter:
        set DB2INSTANCE=<instance name>
  • Oracle:Each database is a database instance.
    • AIX/Linux:
      1. Edit the connections.rsp file, located under the:<lotus_connections_root>/connections.sql/install/oracle/ directory:
        Note: LSCONN is the default database name and SID. Change this name, if necessary, to suit your own environment.
        [GENERAL]
        RESPONSEFILE_VERSION = "10.0.0"
        OPERATION_TYPE = "createDatabase"
        [CREATEDATABASE]
        GDBNAME = "LSCONN"
        SID = "LSCONN"
        TEMPLATENAME = "General Purpose"
        SYSPASSWORD = "conpasswd"
        SYSTEMPASSWORD = "conpasswd"
        EMCONFIGURATION = "LOCAL"
        SYSMANPASSWORD = "conpasswd"
        DBSNMPPASSWORD = "conpasswd"
        CHARACTERSET = "AL32UTF8"
        #NATIONALCHARACTERSET= "AL16UTF16"
        #MEMORYPERCENTAGE = "40"
        [DELETEINSTANCE]
        DB_UNIQUE_NAME = "LSCONN"
        INSTANCENAME = "LSCONN"
        SYSDBAUSERNAME = "SYS"
        SYSDBAPASSWORD = "conpasswd"
      2. Run the following command to create the database instance:
        • AIX:
          sed -e 's,^M,,g' createDb.ksh > createDb.tmp
          mv createDb.tmp createDb.ksh
          chmod +x createDb.ksh
          ./createDb.ksh <password>
          Note: ^M is a special character; type Ctrl + Y and Crtl + M to produce it.
        • Linux:
          dos2unix createDb.ksh
          chmod +x createDb.ksh
          ./createDb.ksh <password>
    • Windows:
      1. Edit the connections.rsp file, located under the:<lotus_connections_root>\connections.sql\install\oracle\ directory:
        Note: LSCONN is the default database name and SID. Change this name, if necessary, to suit your own environment.
        [GENERAL]
        RESPONSEFILE_VERSION = "10.0.0"
        OPERATION_TYPE = "createDatabase"
        [CREATEDATABASE]
        GDBNAME = "LSCONN"
        SID = "LSCONN"
        TEMPLATENAME = "General Purpose"
        SYSPASSWORD = "conpasswd"
        SYSTEMPASSWORD = "conpasswd"
        EMCONFIGURATION = "LOCAL"
        SYSMANPASSWORD = "conpasswd"
        DBSNMPPASSWORD = "conpasswd"
        CHARACTERSET = "AL32UTF8"
        #NATIONALCHARACTERSET= "AL16UTF16"
        #MEMORYPERCENTAGE = "40"
        [DELETEINSTANCE]
        DB_UNIQUE_NAME = "LSCONN"
        INSTANCENAME = "LSCONN"
        SYSDBAUSERNAME = "SYS"
        SYSDBAPASSWORD = "conpasswd"
      2. Microsoft Windows:Run the following command to create the database instance:
        createDb.bat <password>
  • SQL ServerWindows:
    Run the SQL Server installation wizard. On the Instance Name panel of the installation wizard, select Named instance, and then specify a new instance name in the field.
    For more information, go to the Microsoft SQL Server Developer Center Web site to view the SQL Server documentation:
    How to: Install SQL Server 2005 (Setup)
What to do next
When you create multiple database instances, you must install the databases on each instance. This means that if you are using the wizard to install the databases, you must prepare and run the database wizard once for each instance and if you are using the scripts to install the databases, you must run the scripts once for each instance.

No comments:

Post a Comment