Configuring and testing DB2 UDB 7.1
Before you can run WebSphere Application Server, you must create a DB2
UDB instance and the database named was, which WebSphere Application Server uses.
Creating a database instance
Perform the following steps to create the resources required by a DB2 instance and to
create the instance:
- Ensure that you are logged into the machine with superuser (root) privileges.
- Invoke SMIT to create an administrative group for DB2 (named
db2adm
for
this example), by entering the following command: # smit mkgroup
- On the Add a Group screen, do the following:
- In the Group NAME field, type
db2adm
.
- Click OK. When this process is complete, exit from SMIT.
- Create a user to administer the DB2 instance (named
db2inst1
for this example), by entering the following command: # smit mkuser
- In the Add a User screen, complete the steps below. Note that the values that you
add for the HOME directory and Initial PROGRAM fields can differ from
those shown here.
- In the User NAME field, type
db2inst1
. Note that the user
name you specify here identifies the database instance owner. When you install
WebSphere Application Server you will specify this user name for the database user ID.
- In the Primary Group field, type
db2adm
.
- In the HOME directory field, type
/home/db2inst1
.
- In the Initial PROGRAM field, type
/usr/bin/ksh
.
- Click OK. When this process is complete, exit from SMIT.
- Assign an initial password for user db2inst1 by entering the following command:
# smit passwd
- In the Change a User's Password screen, do the following:
- In the User NAME field, type
db2inst1
and click OK.
- In the Change a User's Password pop-up window, type the new password for user
db2inst1. For this example, use the password
changeme
and
press Return. Note that DB2 requires a password of 8 or fewer characters.
- You are prompted to enter the new password again. Type
changeme
and
press Return. When this process is complete, exit from SMIT.
- Ensure that the user root is a member of the db2adm group by entering the command:
# smit user
- From the Users screen menu, choose Change / Show Characteristics of a User.
- In the Change / Show Characteristics of a User pop-up window, type
root
in the
User NAME field, and click OK.
- In the Change / Show Characteristics of a User screen, do the following:
- In the Group SET field, ensure that the group db2adm is included
by clicking the field and scrolling to the end of the entries. If db2adm is not listed,
append it to the list of entries.
- Click OK. When this process is complete, exit from SMIT.
- Create a database instance (named
db2inst1
in this example) by entering
the following command:
# /usr/lpp/db2_07_01/instance/db2icrt -u db2inst1 db2inst1
Note that you may get an error message stating that your machine is out of
space. Increase the free space in the /home directory.
- Create symbolic links from the home directory of the instance to the DB2 installation
directory by entering the following command:
# /usr/lpp/db2_07_01/cfg/db2ln
- Configure the instance owner (db2inst1 in this example) to run the db2profile
script on startup:
- For the Korn shell (ksh), add the following text to the .profile file of the
instance owner db2inst1. Note the space between the period (.) and the first slash (/).
. /home/db2inst1/sqllib/db2profile
- For the C shell (csh), add the following line to the .cshrc file of instance owner
db2inst1: source /home/db2inst1/sqllib/db2cshrc
- Configure root to run db2profile on startup. This is required to
install and run WebSphere Application Server.
Creating and configuring a database for WebSphere Application Server
Perform the following steps to create a database named was
and set
its DB2 application heap size:
- Log in as the DB2 instance owner named db2inst1, which was defined in the steps above.
Note that when you log in as db2inst1, the command prompt changes from
#
to $
to indicate a change in your login identity.
- If this is the first time that you have authenticated as the DB2 instance owner, you
are prompted to change the password. Type in a new password and press Return. Note that DB2
requires a password of 8 or fewer characters.
- When prompted, type the new password again and press Return.
- To ensure that the DB2 environment has been set correctly, verify the value of the
DB2INSTANCE environment variable by issuing the following command. The value returned
should be
db2inst1
: $ env | grep DB2INSTANCE
- Enter the following command to start DB2: $ db2start
- Enter the following command to create a database named
was
. This
process can take several minutes. $ db2 create database was
- Enter the following command to set the application heap size:
$ db2 update db config for WAS using applheapsz 256
- Stop and start the database for your changes to take effect. If an application heap size of 256
does not work for your system, increase it to 512.
It is recommended that you set up the database manager to use TCP/IP to
remotely connect to WebSphere. Note that if you are using a local DB2
database with WebSphere Application Server (for example, both DB2 and
WebSphere Application Server are installed on the same machine) all of the steps in
the following procedure will be performed on the same machine:
- On the server machine, log in as the DB2 instance owner.
(Note that, in these steps, the server and client may be the same machine.)
Then, do the following:
- Set DB2COMM to TCP/IP using a command such as the following:
db2set DB2COMM=tcpip
- Open an editor on the /etc/services file. If it does not specify DB2 connection
and interrupt service ports, then add lines such as the following to specify the ports:
server1 50000/tcp # DB2 connection service port
server1i 50001/tcp # DB2 interrupt connection service port
- Update the database manager configuration:
db2 update dbm cfg using svcename <DB2_connection_service_port>
For DB2_connection_service_port, specify the name used in the /etc/services
file (for example, server1
).
- On the client machine:
- Catalog the node using a command such as the following:
db2 catalog tcpip node node1 remote <hostname> \
server <DB2_connection_service_port>
- Catalog the database:
db2 catalog database was as wasAlias at node node1
- Stop and start DB2.
Verifying installation of DB2 UDB 7.1
To demonstrate that DB2 is functioning correctly, create a sample database and then
compile and execute a Java application that accesses this database. The steps below
establish that the correct environment is available for DB2 and the IBM JDK, and that
the JDBC driver is accessible from a Java application.
Perform the following steps to create the sample database and compile and run the Java
application:
- Log in as the DB2 instance owner (the value that you specified
for the User Name option in Step 5 in
"Creating a database instance").
Note that when you log in as the instance owner, the command prompt appears as
$
, rather than #
, to indicate your login identity.
- If this is the first time that you have authenticated as the DB2 instance owner,
you are prompted to change the password. Type in a new password and press Return. Note
that DB2 requires a password of 8 or fewer characters.
- When prompted, type the new password again and press Return.
- To ensure that the DB2 profile has been set correctly, search the environment
for the value of DB2INSTANCE by entering the following command. The value returned
must be the instance owner name (the value that you specified for
the User Name option in Step 5 in "Creating a
database instance"):
$ env | grep DB2INSTANCE
- Enter the following command to create the sample database. This process can
take several minutes to complete.
$ db2sampl
- Compile an example Java application, placing the resulting class file in the
local directory, by entering the following command:
$ javac -d . sqllib/samples/java/DB2Appl.java
- Start DB2 by entering the following command:
$ db2start
- Execute the sample by entering the following command:
$ java DB2Appl
Your output appears like the following:
Retrieve some data from the database...
Received results:
empno= 000010 firstname= CHRISTINE
empno= 000020 firstname= MICHAEL
empno= 000030 firstname= SALLY
. . .
Update the database...
Changed 1 row.
- To log out, enter control-D (
^D
) at the command prompt.
Verifying connection to the was database
To verify connection to the was database, perform the following steps:
- Log in as the DB2 instance owner (the value that you specified
for the User Name option in Step 5 in
"Creating a database instance").
Note that when you log in as the instance owner, the command prompt appears as
$
, rather than #
, to indicate your login identity.
- Enter the command:
$ db2 connect to was
Your output appears like the following (assuming an instance name of db2inst1):
Database Connection Information
Database server = DB2/6000 7.1.0
SQL authorization ID = DB2INST1
Local database alias = WAS
- To log out, enter control-D (
^D
) at the command prompt.