Validate your DB2 installation using db2val

A tool to solve installation worries

You can use the db2val copy validation tool for IBM® DB2® for Linux®, UNIX®, and Windows® to validate installed files at the database level, the instance level, or the system level. This function is useful not only for large-scale deployments of DB2, but also for embedding the DB2 installation process inside your own application installation. This article explains how to implement the tool and illustrates its use with several scenarios.

Prashant Naik (prasnaik@in.ibm.com), Senior Software Engineer, IBM

Photo of author Prashant NaikPrashant works as a Senior Software Engineer, DB2 Install QA team in IBM India Software Lab, Bangalore. He is an IBM Certified DB2 Database Administrator - DB2 LUW V9 for Linux, UNIX, and Windows.



Shivraj Kumar Sarsambi (shivraj.sarsambi@in.ibm.com), Senior Software Engineer, IBM

Author photo of Shivraj SarsambiShivraj Kumar Sarsambi is a IBM Certified DB2 Database Administrator - DB2 LUW V9 for Linux, UNIX, and Windows. Shivraj works for DB2 System and Verification Test team at the IBM India Software Lab, Bangalore. He graduated from U.V.C.E, Bangalore University with a major in Computer Science Engineering before joining IBM, and has completed DB2 advanced DBA certification.



Kayalvizhi Ganesan (kaganesa@in.ibm.com), Advisory Software Engineer, IBM

Photo of author Kayalvizhi GanesanKayalvizhi Ganesan works as a Software Developer for DB2 Install development team at the IBM India Software Lab, Bangalore.



21 July 2011

Also available in Chinese Vietnamese

What is the db2val tool?

The db2val tool is used to validate files laid down by the DB2 installer at the system level, instance level, or database level. This tool is mostly useful for large scale deployments of DB2. It can also be used for embedding the DB2 installation process inside your own application installation.

Suppose some install files are deleted or found to be missing sometime after installation. If this happens, you can use the db2val tool to check the latest state of installation files, instance setup, and database connections.

Scope of the tool

  • Install file validation
  • Instance validation
  • Database creation and connection
  • Extended security (Microsoft Windows only)

You can find the db2val tool on your DB2 installation path, for example:

<Installation path>/bin/db2val (where the installation path represents the db2 installed path for underlying operating system).

Default DB2 installation path on Linux and UNIX platforms: /opt/ibm/db2/V9.7 or /opt/IBM/db2/V9.7

Default DB2 installation path on Windows: C:\Program Files\SQLLIB\bin

You can verify the installation path as shown in Listing 1.

Listing 1. Command to verify the installation path
/opt/ibm/db2/V9.7/bin/db2val -o -l /tmp/va1.log

Syntax and description of the tool

The syntax of the tool is: # /opt/ibm/db2/V9.7/bin/db2val -h.

The DBI1329I Usage:

  • db2val [-h|-?]
    • [-o]
    • [-i inst_name1] | [-a]
    • [-b db_name]
    • [-d]
    • [-s]
    • [-l log_file]
Table 1. Usage options and explanations
Usage optionExplanation
-oSpecifies that only the installation files will be validated; validation of the instance, database, and extended security will not be performed. If this parameter is specified, the -i, -a, -b, and -s parameters are ignored.
-i inst_nameSpecifies the name of the instance to validate. To specify validation of multiple instances, specify this parameter multiple times. For example, -i inst1 -i inst2.
On Windows operating systems, if this parameter is not specified, the current instance will be used as the default value.
On Linux and UNIX operating systems, this parameter can only be used by root users in a root installation of a DB2 copy.
-aValidates all instances in the DB2 copy. On Linux and UNIX operating systems, this parameter can only be used by root users in a root installation of a DB2 copy. This option overrides the -i option.
-bValidates the local database creation and connection with the given database name. This parameter is ignored in the following scenarios:
the instance to be validated is a client instance * -a and -i are not specified when db2val is run by root users (on Linux and UNIX only).
-dValid only on Linux and UNIX operating systems. Use this parameter only when instructed by DB2 Support. Turns the debug mode on.
-sStarts the DB2 database manager for the specified instance that is part of a DPF environment.
-l log_fileWrites the log to the file name specified. Unless the -l parameter is specified, the default log path is:
On Linux and Unix, /tmp/db2valxx.log
On Windows, My Documents\DB2LOG\db2valxx.log
Where xx is a auto-generated value based on the current timestamp.
-h|-?Displays the usage information.

Scenarios and demo

The following different scenarios show how db2val can benefit you.

Scenario 1: DB2 installation path has a corrupted file

Consider the scenario where the libdb2dascmn.so library file is missing. Listing 2 shows how db2val helps to validate the DB2 installation.

Listing 2. Command to verify the installation path
Install Path: /opt/ibm/db2/V9.7

/opt/ibm/db2/V9.7/bin/db2val -o -l /tmp/va1.log

If the previous command is specified without -l option, the log will be generated and placed at default path /tmp/db2val on UNIX, or at C:\Users\Administrator\Documents\DB2LOG on Windows.

Listing 3. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.

DBI1344E  The validation tasks of the db2val command failed. For
      details, see the log file /tmp/va1.log.
Listing 4. Log file contents
Installation file validation for the DB2 copy installed at "/opt/ibm/db2/V9.7" starts.


Task 1: Validating Installation file sets.

Missing files:
/opt/ibm/db2/V9.7/lib64/libdb2dascmn.so
/opt/ibm/db2/V9.7/das/lib/libdb2dascmn.so
Status 1: Failure

Scenario 2: DB2 instance path has a missing file

Imagine that the instance related files under the sqllib folder are missing, for example: db2nodes.cfg. Use the following method shown in Listings 5, 6, and 7 to validate the DB2 installation path. Details are logged in the /tmp/val.log log file which is specified after -l.

Listing 5. Command to verify the corrupted/missing files at instance level
/opt/ibm/db2/V9.7/bin/db2val -i reginst1 -l /tmp/val.log
Listing 6. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.

DBI1344E  The validation tasks of the db2val command failed. For
      details, see the log file /tmp/val.log.
Listing 7. Log file contents
Task 8: Starting DB2 instance "reginst1".

SQL6031N  Error in the db2nodes.cfg file at line number "0". Reason Code "3".
Status 8: Failure

DBI1338E  The validation of the instance reginst1 failed. Reason Code =7.

Scenario 3: Permission issues of /etc/services

Scenario three shows that the /etc/services file is corrupted from your system, and how to validate it. In this example, the read permissions of the /etc/services file are removed so you can see how db2val figures it out, as shown in Listings 8, 9 and 10.

Listing 8. Command to verify the permissions of /etc/services
/opt/ibm/db2/V9.7/bin/db2val -o -l /tmp/va1.log
Listing 9. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.


DBI1345W  Read permission to the /etc/services file is not granted to
      every user. This lack of permission can cause the instance
      creation to fail.
Listing 10. Log file contents
Task 4: Validating the accessibility to the /etc/services file.

DBI1345W  Read permission to the /etc/services file is not granted to
      every user. This lack of permission can cause the instance
      creation to fail.

Scenario 4: Verifying database connection

The db2val tool can be used to check the connection to the local database. The following listings show an example how to validate the connections of the database testdb residing in the instance reginst1.

Listing 11. Command to verify the database connection
/opt/ibm/db2/V9.7/bin/db2val -i reginst1 -b testdb -l /tmp/val.log
Listing 12. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.

DBI1335I  Installation file validation for the DB2 copy installed at
      /opt/ibm/db2/V9.7 was successful.

DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/val.log.
Listing 13. Log file contents
Task 8: Validating database connections using CLP command.


   Database Connection Information

 Database server        = DB2/LINUX 9.7.0
 SQL authorization ID   = REGINST1
 Local database alias   = TESTDB

Note: The database will be dropped after these tests if it is created by the validation 
tool. The validation tool will skip the database validation if the instance is a client
type, or if the instance (server type) cannot be started.

Scenario 5: Validating the partitioned database setup

In a partitioned database environment, db2val will make sure the nodes are properly set up in the instance. Listings 14, 15, 16 indicate db2val output after validating partitioned database.

Listing 14. Command to verify the partitioned database environment
/opt/ibm/db2/V9.7/bin/db2val -i reginst1 -l /tmp/val.log
Listing 15. Output of the db2val
DBI1337I  The partitioned database environment validation for the instance
 reginst1 was successful.

DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/val.log.
Listing 16. Log file contents
Task 12: Validating code level on all database partitions.

0         9.7.0.0 0
1         9.7.0.0 0

Status 12: Success

DBI1337I  The partitioned database environment validation 
for the instance reginst1 was successful.

Partitioned database environment validation for the instance "reginst1" ends.

DBI1339I  The instance validation for the instance reginst1 was
      successful.

Instance validation for "reginst1" ends.

Scenario 6: Validating multiple instances using -i option

The db2val tool can be used to validate multiple instances in a single command. The following listings show how validation of the multiple instances reginst1 and reginst2 is done.

Listing 17. Command to validate multiple instances
 /opt/ibm/db2/V9.7/bin/db2val -i reginst1 -i reginst2
Listing 18. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.


DBI1335I  Installation file validation for the DB2 copy installed at
      /opt/ibm/db2/V9.7 was successful.


DBI1339I  The instance validation for the instance reginst1 was
      successful.


DBI1339I  The instance validation for the instance reginst2 was
      successful.



DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/db2val-07_21_07:40:06.log.
Listing 19. Log file contents
Instance validation for "reginst1" starts.


Task 5: Validating symbolic links in the instance directory.

Status 5: Success


Task 6: Validating instance file ownership and permission.

Status 6: Success


Task 7: Validating the accessibility to the /etc/services file.

Status 7: Success


Task 8: Starting DB2 instance "reginst1".

07/21/2011 07:45:09     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
Status 8: Success


DBI1339I  The instance validation for the instance reginst1 was
      successful.


Instance validation for "reginst1" ends.


Task 9: Stopping DB2 instance "reginst1".

07/21/2011 07:45:12     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
Status 9: Success

Instance validation for "reginst2" starts.


Task 10: Validating symbolic links in the instance directory.

Status 10: Success


Task 11: Validating instance file ownership and permission.

Status 11: Success


Task 12: Validating the accessibility to the /etc/services file.

Status 12: Success


Task 13: Starting DB2 instance "reginst2".

07/21/2011 07:45:24     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
Status 13: Success


DBI1339I  The instance validation for the instance reginst2 was
      successful.


Instance validation for "reginst2" ends.


Task 14: Stopping DB2 instance "reginst2".

07/21/2011 07:45:26     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
Status 14: Success

Scenario 7: Validating the non-root instance

The db2val tool can also be used to validate the non-root instance. When db2val is executed as a non-root user without any option specified, it validates the non-root instance.

Listing 20. Command to verify the non-root instance
db2val
Listing 21. Output of the db2val
DBI1379I  The db2val command is running. This can take several minutes.


DBI1335I  Installation file validation for the DB2 copy installed at
      /home/reginst1/sqllib was successful.


DBI1339I  The instance validation for the instance reginst1 was
      successful.


DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/db2val-07_21_08:03:04.log.
Listing 22. Log file contents
Instance validation for "reginst1" starts.


Task 5: Validating symbolic links in the instance directory.

Status 5: Success


Task 6: Validating instance file ownership and permission.

Status 6: Success


Task 7: Validating the accessibility to the /etc/services file.

Status 7: Success


DBI1339I  The instance validation for the instance reginst1 was
      successful.


Instance validation for "reginst1" ends.

Validating DB2 on Microsoft Windows using db2val

Extended security (Windows only)

DB2 users are authorized to do certain database operations. For instance, if you can create a database only when the extended security is enabled. If extended security is not set up then db2val gives a warning message.

Key points of the db2val tool

  • A regular user in the DB2 SYSADM group can run the validation for the related instance and install copy.
  • For a root user running the tool in a root-install copy on UNIX, the -i or -a must be used in order to do the instance and database validations. This is not required for non-root installation.
  • To verify multiple instances, repeat the -i option, or use -a option for all instances present in the DB2 copy. For example: /opt/ibm/db2/V9.7/bin/db2val -i test1 -i test2
  • The -b option will be ignored if the instance to be verified is a client instance.
  • On UNIX or Linux, root users can validate any root installations. The -i option should be used only for root installation.
  • On Windows, db2val will validate the current instance that the user is running unless -i or -a is specified. If the instance to be verified is a DPF instance, then administrator rights is also required.
  • Database creation and connection will be verified when the -b option is used. You can specify a database name for the test or let the tool generate one.

The default log path is $DB2TMPDIR/db2valxx.log (or /tmp/db2valxx.log if $DB2TMPDIR is undefined) on UNIX, and C:\Users\ADMINI~1\DOCUME~1\DB2LOG\db2valxx.log on Windows, where xx will be auto-generated. There are other possible default log file locations, such as the install directory. But since the tool can be run by root or instance users, this makes the $DB2TMPDIR or /tmp a better choice for default.

For more information about the db2val tool, please use the db2val help.

How you can start using the db2val tool

The install validation utility is available on UNIX, Linux, and Windows platforms. See the Syntax section for information on the syntax of the db2val install validation tool.

Conclusion

The db2val utility is a powerful tool for validating installation files, instances, database creation, connections to the database, and the state of partitioned database environments. This article has shown the various usage scenarios of the db2val tool. You'll find this a handy tool for ensuring that your installation is issue-free.

Resources

Learn

Get products and technologies

  • Build your next development project with IBM trial software, available for download directly from developerWorks.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Information management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=741695
ArticleTitle=Validate your DB2 installation using db2val
publish-date=07212011