(M)  s i s t e m a   o p e r a c i o n a l   m a g n u x   l i n u x ~/ · documentação · suporte · sobre

 

6. Creating DB2 instances

This section gives you a brief overview of DB2 instances and the DB2 Administration Server, and tells you how to create them.

Some IBM documentation uses the term "instance" to refer to both DB2 instances and a DB2 Administration Server. The basic similarity between a DB2 Administration Server and a DB2 instance, or "database manager", is that each is associated with a unique user ID. When you create either a DB2 instance or a DB2 Administration Server, DB2:

  • creates one or more new user IDs and corresponding home directories

  • creates a subdirectory in the instance home directory called sqllib

  • alters the .bashrc file to call the ~/sqllib/db2profile shell script to set up the environment for the instance

6.1. Overview of DB2 Administration Server

Like a queen bee in a hive, only one DB2 Administration Server can exist on any given DB2 server. By locally or remotely logging as the user ID that corresponds to the DB2 Administration Server, a database administrator uses the DB2 Administration Server to create, drop, or change the properties of DB2 instances.

6.2. Overview of DB2 instance

To quote the IBM DB2 Universal Database Version 7.1 Administration Guide definition of an instance:

An instance (sometimes called a database manager) is DB2 code that manages data. It controls what can be done to the data, and manages system resources assigned to it. Each instance is a complete environment. ... An instance has its own databases (which other instances cannot access), and all its database partitions share the same system directories. It also has separate security from other instances on the same machine (system).

What this boils down to is that for every DB2 instance, DB2 requires a unique user ID on your Linux workstation. Security for an instance is provided by the normal password authentication process for any Linux user ID. Each instance can contain one or more databases, each of which inherits settings from their instance.

Creating the Administration Server using db2setup

The DB2 Administration Server requires about 3 MB of disk space. The following steps guide you through the process of creating a DB2 Administration Server.

  1. Issue the db2setup command as described in Section 4.2.

  2. Select [ Create... ].

  3. Select the check box for Create the Administration Server. The Administration Server window is displayed.

  4. Enter a unique user name in the User Name field. You can use an existing user name that is not already in use by a DB2 instance, but it is probably simpler to create a new user for each instance.

  5. Select the Use default UID check box. As far as I can tell, this setting is always right.

  6. Enter a unique group name in the Group Name field. You can use an existing group name if you wish, but creating a new group ensures that you do not inadvertently give permissions to other users on your system.

  7. Select the Use default GID check box. Again, as far as I can tell, this setting is always right.

  8. Ensure that the value of the Home Directory field reflects the home directory of the user ID.

    Warning

    SuSE users: The prefix for the home directory may default to /usr/lib/db2/. This is almost certainly wrong; the value for a standard SuSE system should be /home/.

  9. Enter a unique password in the Password and Verify Password fields.

    Warning

    Enter a new password! If you do not enter a new password in these fields, DB2 assigns the default password ibmdb2, giving crackers a wide-open front door to your system.

Creating a DB2 instance using db2setup

A DB2 instance requires about 2 MB of disk space. A sample database for a DB2 instance requires about 16 MB of disk space. The following steps guide you through the process of creating a DB2 instance.

  1. Issue the db2setup command as described in Section 4.2.

  2. Select [ Create... ].

  3. Select the Create a DB2 Instance check box. The DB2 Instance window is displayed.

  4. Enter a unique user name in the User Name field. You can use an existing user name that is not already in use by a DB2 instance, but it is probably simpler to create a new user for each instance.

  5. Select the Use default UID check box. As far as I can tell, this setting is always right.

  6. Enter a unique group name in the Group Name field. You can use an existing group name if you wish, but creating a new group ensures that you do not inadvertently give permissions to other users on your system.

  7. Select the Use default GID check box. Again, as far as I can tell, this setting is always right.

  8. Ensure that the value of the Home Directory field reflects the home directory of the user ID.

    Warning

    SuSE users: The prefix for the home directory may default to /usr/lib/db2/. This is almost certainly wrong; the value for a standard SuSE system should be /home/.

  9. Enter a unique password in the Password and Verify Password fields.

    Warning

    Enter a new password! If you do not enter a new password in these fields, DB2 assigns the default password ibmdb2, giving crackers a wide-open front door to your system.

  10. Select [ Properties... ] to change the properties for the instance.

    1. Under the Authentication Type heading, select the Server Encrypt check box. This greatly improves the security of your system, by telling DB2 to accept encrypted passwords, rather than plain text passwords.

    2. Select the Auto start DB2 Instance at system boot check box if you want to start this DB2 instance every time you reboot your system.

    3. Select the Create a sample database for DB2 Instance check box if you plan to work with the sample applications available with the Application Development Client. To run correctly, most of the sample applications require the specific tables and data of the sample database. If you do not create the sample database now, you can create it later using the db2sampl command.

  11. Select [ OK ] to create the DB2 instance. The Fenced User text window is displayed. Repeat the previous steps for creating a new user and group. Server-side DB2 executables, such as stored procedures and user-defined functions, execute under the permissions of the fenced user ID. By controlling the permissions of the fenced user ID, you control the permissions of the server-side DB2 executables.

  12. Select [ OK ] to create the fenced user.