Tuesday, November 16, 2004

Setting up Tomcat for DB2 and some tips

NOTE:

  • These were tested on win2k
  • "C:\jakarta-slide-2.0-tomcat-5.0.19\" is mentioned as $CATALINA_HOME

Pre-Requisites:

  • DB2.
  • Latest Java SDK
Steps:

  • Set an Enviromental Variable "JAVA_HOME" to the Java SDK's Home Directory.
  • Download & Install the latest binaries from Apache's Site (Get *.exe for windows to install as a service)
  • Copy "C:\Program Files\IBM\SQLLIB\java\db2java.zip" file to C:\jakarta-slide-2.0-tomcat-5.0.19\common\lib\" and rename the file to db2java.jar.

Running Tomcat as Service (Windows)

  • If you have installed *.exe file you already have Tomcat running as a service.
  • An work around for this is to run the startup.bat as a schedule task on system startup. This doesn't shows the Tomcat's command window (This method doesn't really install Tomcat as service)

Changing Tomcat's 8080 Port:

By Default Tomcat listens in the 8080 port (localhost:8080). It can be changed by changing values in the

$catalina_home\conf\server.xml

Change the value of Connector port to desired port.

THE PART THAT NEEDS TO BE CHANGED IN SERVER.XML

Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true"

Restart Tomcat to see the changes.


Enabling Tomcat for SSI (Server Side Includes)

Rename $CATALINA_HOME/server/lib/servlets-ssi.renametojar to $CATALINA_HOME/server/lib/servlets-ssi.jar.

Remove the XML comments from around the SSI servlet and servlet-mapping configuration in $CATALINA_BASE/conf/web.xml.

DB2 Catalog Commands

Tomcat may have to be restarted if you re-catalog an existing database that is being used in your code.

Errors

Looking at the Tomcat log files will help you solve the error messages that you see on browser.

Location of log files $Catalina_home\logs


Resources:

http://jakarta.apache.org/tomcat/

Monday, November 15, 2004

PreCompiling and Running Embeded SQL

Write your Embeded SQL C code with a file extension .sqc

Precompiling

db2 connect to database name
db2 prep filename.sqc
db2 connect reset

The Above Command on Sucess will give a filename.c file.

The C File needs to compilied with special flags as follows

gcc filename.c -Wall -I/home/db2inst1/sqllib/include/ -L/home/db2inst1/sqllib/lib -ldb2 -Wl,-rpath,/opt/IBM/db2/V8.1/lib -o

Run the outputfile to see the results.


NOTE:
  • The flags may vary if you have a username other than db2inst1.
  • And the flags need to be properly spaced.

Monday, October 04, 2004

Net Search Extender

Intro:

DB2 Net Search Extender Version 8.1 is one of a family of DB2 Extenders™. It replaces DB2 Text Information Extender Version 7.2, and Net Search Extender Version 7.2 and offers users and application programmers a fast, versatile, and intelligent method of searching full-text documents stored in DB2, other databases, and file systems using SQL queries.

Basically, DB2 Net Search Extender searches text documents held in the column of a database table. The documents can be in various formats, such as HTML or XML. Rather than sequentially searching through the text documents that would take a considerable amount of time, Net Search Extender creates a text index in order to make documents searchable. A text index consists of significant terms extracted from the text documents.

Installation:

  • Make sure you have the appropriate DB2 Fixpack that matches Extender’s Pre-requisite. (RTFM)
  • Install NSE and Fixpack if its needs any. (You can get a trial download that can be used for 90days from IBM’s site.)
  • After installation run the sample script available in the “SQLLIB/samples/nsesample.bat”

nsesample.bat

The script creates the given DBNAME if it doesn’t exist and tests if the NSE installation was successful.

  • Check the nsesample.log file to make sure everything is fine.

Enabling a database for text search:

db2text start (Starts the NSE instance services)

db2text ENABLE DATABASE FOR TEXT CONNECT TO
(Prepares the database for use with NSE)

As DB2 commands db2text ? gives the syntax of the command.

Creating an Index:

Note: The table being referenced is the one which has the Text/HTML Document.

NSE needs an index to be created on the column that needs to be searched (You need to have a primary key to create an index). Create an index on the table that has the Text/HTML file that needs to be searched.

db2text create index db2ext. for text on

() UPDATE FREQUENCY D (*) H (*) M (10) connect to

(This command creates an index and sets the update frequency to 10 minutes, this is required to avoid synchronization issues)

Right after creation, update the index to fill the created index with data

db2text update index db2ext. for text connect to


Queries that can be used now:

SELECT AUTHOR,TITLE FROM DB2EXT.TEXTTAB WHERE CONTAINS(COMMENT, ’"book"’) = 1

Searches for the word “book” in the text fields of the column comment.

SELECT AUTHOR,TITLE FROM DB2EXT.TEXTTAB WHERE CONTAINS(COMMENT, ’"book" & “db2”’)=1

As you do in Google you can use logical operators like “&” “|” “NOT”. And they can be mixed in a search string.

SELECT AUTHOR, TITLE, NUMBEROFMATCHES(COMMENT, ’"book"’) FROM DB2EXT.TEXTTAB

Gives the number of matches found for the given word.

WITH TEMPTABLE(docid,score) AS (SELECT docid, SCORE(COMMENT,’"book"’) FROM DB2EXT.TEXTTAB)
SELECT * FROM TEMPTABLE WHERE score > 0 ORDER BY score ASC

Score tells you how well the documents meets your search. This can be used to order the search results.

This is an Interesting one!

SELECT AUTHOR, TITLE FROM DB2EXT.TEXTTAB WHERE CONTAINS(COMMENT, 'fuzzy form of 80 "Joh"') =1

Above query results will contain JOHN. This can be used when a normal search didn’t return any result. Ever wondered how Google is making up its “Did you mean :)

More searches:

  • Search for multiple words in same sentence
  • multiple words in same paragraph
  • search structured documents like HTML
  • Thesaurus search with the dictionary built by you.
  • Search for numeric attributes
  • Wild card search

Read the Users guide to get more info about NSE.

References:

Users Guide

PerFormance Overview

More Resources

Saturday, September 18, 2004

Errors After A Redirected Restore!

ADM1814E The current log path
"/ PATH/NODE0000/" is invalid.

ADM1811E DB2 will now switch to the default log path
"/PATH/NODE0000/SQL00004/SQLOGDIR/".

Whether you are restoring to a different machine or on the same machine never forget to change the NEWLOGPATH Database Parameter. If you don’t DB2 will switch to default log path. This will not be an issue if you are using default log path.

DB2 was unable to confirm logs were archived.
Return code 118489304, FirstArchNum 31953, HeadExtentID 31958

An error was received from the user exit program.
0x2FF21508 : 0x0000001C ....

Userexit program maintains a log which is more informative than the above and it will be in the files named USEREXIT.ERR & ARCHIVE.LOG, you should be able to find that in the LOGPATH.

You have to act based on that.

In my case I have to create a directory for the new database so that it can archive the logs.

This message keeps coming up sometimes after a redirected restore and not sure what it means… Help me!

SQL procedure executables recovery has been initiated. DBNAME
0x2FF1E330 : 0x4341535342202020

SQL procedure executables recovery ended. RC:
0x2FF1E310 : 0x00000000

Wednesday, September 15, 2004

Migrating from AIX to Windows

There are the steps that i followed to migrate...

Haven't done the move on Prod DB. Will update with changes if any.

STEPS:

DB2 doesn’t support cross platform back-up and restore between AIX & Windows. Thus redirect restore cannot be used.

But DB2 UDB has tools to achieve this task.

  • db2move - Used for moving User tables (DATA)
  • db2look - Creates DDL to create the database objects in the new environment.
  • db2cfexp – Exports connectivity configuration to an export profile
  • db2cfimp – Import connectivity configuration information.

Steps for Moving from AIX to Windows

On AIX:

  1. Use db2move to export all table data to PC/IXF files
  2. Use db2look to generate DDL for all the database objects.
  3. Use db2cfexp to export the configuration information to a file.
  4. Transfer PC/IXF files & Configuration profile in Binary Mode.
  5. Transfer db2look.sql & db2move.lst in ASCII Mode.

On Windows:

  1. Make sure the version of DB2 is same with the appropriate Fixpack.
  2. Create an instance with the same name as it was in AIX. (optional)
  3. Create all the databases that you are moving.
  4. Set current schema name.
  5. Create required Buffer pools and Table Spaces for the DB.
  6. Run the script generated by db2look
  7. Import the configuration information using db2cfimp tool.
  8. Run db2move in load mode. (Takes a while for large DB’s)
  9. Update DB CFG to reflect the source DB.
  10. Do a Full DB/Table space Backup to take the table space out of backup pending state and check for the integrity of the Backup.
  11. Detect the tables that are in check pending state and bring it to normal state. (set integrity)
  12. Check other db objects to make sure they are in Normal State.
  13. All the configuration parameters need to be tuned according to the current hardware.

NOTE:

Don’t forget that default values for some parameters are different for windows & AIX


comments, suggestions, questions are welcome..


Welcome

Hi all

DB2 DBA's out there

Come Share your thought's findings...