Skip to main content

Automatic deployment toolkit for an SOA project environment, Part 3: IBM DB2 for Linux, UNIX, and Windows and IBM Content Manager automatic installation scripts

HeQing (Hawking) Guan (guanheq@cn.ibm.com), Senior Software Engineer, IBM
HeQing Guan's photo
HeQing Guan (Hawking) is a senior software engineer on the IBM Global Business Solution Center team. He has a doctorate from the Chinese Academy of Sciences and has worked in the SOA field for almost 5 years.
Qiang Bai (baiqiang@cn.ibm.com), Software Engineer, IBM
Qiang Bai's photo
Qiang Bai has worked as a software engineer with the Global Business Solution Center in CSDL. In addition to focusing on software configuration management (SCM) products, he is responsible for developing the solution assets built on IBM's Service-Oriented Architecture (SOA) methodology.
YuLin Chen (chenyul@cn.ibm.com), Software Engineer, IBM
YuLin Chen's photo
YuLin Chen is a software engineer in the IBM Global Business Solution Center. He is responsible for developing the solution assets built on IBM's Service-Oriented Architecture (SOA) methodology.
YaoFei (Richard) Zhu (zhuyaof@cn.ibm.com), Staff Software Engineer, IBM
YaoFei Zhu's photo
YaoFei Zhu (Richard) joined the IBM China Development Lab in 2005 and has worked in Linux on POWER and on Global Business Solution Center (GBSC) teams as a system developer, application developer, and infrastructure architect. He has more than 6 years of experience in AIX, Linux, System p, System x, storage, and SOA.

Summary:  This article series introduces an automatic deployment toolkit (Automatic-DT), which helps infrastructure architects install and configure deployment nodes with a list of IBM software installed and configured automatically. It also helps testers and developers refresh builds in their daily tests and integration life cycle. In this article, Part 3 in the series, build automatic installation and configuration scripts on IBM® DB2® for Linux®, UNIX, and Windows® and IBM Content Manager.

View more content in this series

Date:  17 Oct 2008
Level:  Intermediate PDF:  A4 and Letter (49KB)Get Adobe® Reader®
Activity:  3522 views

Introduction

This article shows you how to automatically set up DB2 for Linux, UNIX, and Windows (hereafter referred to as DB2) and IBM Content Manager. The automatic installation scripts are written in Python, which enables these two products to be installed without human intervention.

The setup of each product is divided into three main steps:

  • Pre-installation steps are performed to check whether the requirements of the product are met.
  • Installation starts.
  • Post-installation steps are executed after installation is complete to verify a successful installation and to allow for some extra tasks to be done based on project requirements; for example, it might check the installation logs to confirm that no error occurred in the installation or execute some DB2 SQL scripts to set up a DB2 database for development.

Response file

To set up a product like DB2 automatically, you need a silent installation. In a silent installation, you use response files to specify the configuration parameters that you'd normally type in the installer's GUI. A response file is a text file with one line for each input field that you'd find in the regular interactive installation.

In general, there are two ways to prepare a response file:

  • Saving: When performing manual installation, you can have the installer generate one, recording the options that you've selected during the installation, and then make some small modifications as needed. This is quite useful if you're installing the exact same components on a large number of machines.
  • Editing: Modify a response file from a common template. A template response file displays all the possible options that you can specify, but it's more difficult because you must be an expert on the response file template.

In the automatic installation scripts, several response files are already provided. You can use them directly, make some modifications, or users can overwrite the response file. An example of a DB2 response file is shown in Listing 1.


Listing 1. Example of a DB2 response file
PROD=ENTERPRISE_SERVER_EDITION
LIC_AGREEMENT=ACCEPT
# installation destination dir
FILE=C:\IBM\SQLLIB\

INSTALL_TYPE=CUSTOM

COMP=SPATIAL_EXTENDER_SAMPLES
COMP=INFORMATION_CATALOG_SAMPLES
COMP=JDBC_SUPPORT
COMP=IBM_JDK
COMP=IBM_JRE
COMP=LDAP_EXPLOITATION
... ... ... ...
COMP=TCPIP_DB2_LISTENER_SUPPORT

LANG=EN
DAS_CONTACT_LIST=LOCAL

INSTANCE=DB2
DB2.NAME=DB2
DEFAULT_INSTANCE=DB2
DB2.AUTOSTART=YES
#db2 user name and password
DB2.USERNAME=db2admin
DB2.PASSWORD=244259359291351148346332
... ... ... ...
DB2_ADMINGROUP_NAME=DB2ADMNS


DB2 setup

As discussed in the Introduction, complete the following three main steps—pre-installation, installation, and post-installation—to finish DB2 setup.

DB2 pre-installation

  1. Check to see whether there's a DB2 product installed in the destination directory, as shown in Listing 2.

    Listing 2. DB2 pre-installation
    #1. Check to see whether there's a DB2 product installed in the destination dir.
    def checkDB2Installed(): 
     filename = "db2level_output.txt";
     db2level = os.path.join(db2BinDir, "db2level.exe")
     executeFile = db2level + " > " + filename
     os.system(executeFile)
     if(os.path.exists(filename)):
      f = file(filename)
      for line in f:
       if(line.startswith("Product is installed at \"" + db2BinDir + "\".")):
        return True
     return False
    

DB2 installation

  1. Check to see if the DB2 response file is already prepared.
  2. Execute the DB2 silent installation, as shown in Listing 3.

    Listing 3. DB2 installation
    #execute DB2 installation
    def executeDB2Installation() :
     #1. Check to see if the response file is prepared.
     if os.path.exists(responseFile):
      executeFile = executeFile + " -f -l " + db2_log + " -u " + responseFile
      #2. execute silent installation
      os.system(executeFile)
      return True
     else :
      log(responseFile + " is invalid!")
      return False
    

DB2 post-installation

  1. Make sure the installation is successful. Here you use the operation checkDB2Installed, shown in Listing 2.
  2. Try to find and catalog existing databases on the local hard disk, as shown in Listing 4. This task is useful to recover the existing data in the scenarios that a DB2 server has removed and then reinstalled.

    Listing 4. Find and catalog existing databases on the local hard disk
    #2. Find and catalog already existed databases on the local hard disk
    def addExistedDatabase(): 
     self.executeDB2Command("list database directory on " + db2InstalledBaseDir)
     if(os.path.exists(db2_cmd_log)) :
      f = file(db2_cmd_log)
      for line in f:
       #find the database name in the line, denoted by name1
       databaseList.append(name)
       self.executeDB2Command("catalog database " + name1)
     return True
    # execute "db2cmd db2 command"
    def executeDB2Command() : 
     if( os.path.exists(db2cmdFile())) :
      #run db2cmd db2 -z logcommand
      cmd = "start /D" + db2BinDir + " /I /WAIT " + db2cmdFile
       + " /w " + "db2 " + "-z" + db2_cmd_log + " " + command
      os.system(cmd)
      return self.checkCommandExeResult(db2_cmd_log)
     return False
    # See if the result of "db2cmd db2 command" is successful
    def checkCommandExeResult(self, logfile = ""):
     if(os.path.exists(logfile)):
      f = file(logfile)
      for line in f:
       if line.find("DB20000I") != -1 :                
        return True
      return False            
     return False
    

  3. There are also some extra tasks based on the project requirements (see Listing 5), such as creating tables, preparing needed data, or creating a DB2 instance.

    Listing 5. Extra tasks based on the project requirements
    def doMoreTasks():
     db2.createDatabase('SampleDB')
     db2.executeSQLScripts('Sample.sql')
    
    #create database databaseName
    def createDatabase():
     command = "create database " + databaseName
     return self.executeDB2Command(command)
    
    #execute sql scripts
    def executeSQLScripts(self, filename) :
      #run db2cmd /w db2 -tf filename -z logfile
      cmd = "start /D" + db2BinDir 
        + " /I /WAIT " + db2cmdFile + " /w " + "db2 -tf " 
        + filename + " -z " + logfile
      os.system(cmd)
      if(os.path.exists(logfile)):
       logfilef = file(logfile)
       for line in logfilef:
        #Find an error in the sql execution
        if( not line.startswith("DB20000I")):
         return False
       return True
     return False
    

Table 1 shows detailed information about how to use Python and DB2 commands in your DB2 automatic installation scripts.


Table 1. Detailed information about Python and DB2 commands
StepsTaskPython functionsDB2 commands
Pre-installationCheck to see if there's a DB2 product installed in the destination directory.os.system(...)db2level
InstallationConfirm that the response file has already been prepared.os.path.exists(...)-
Execute the DB2 silent installation. os.system(...)db2setup -f -l db2.log –u responseFile.txt
Post-installationMake sure the installation was successful.os.system(...)db2level
Find and catalog the existing databases on the local hard disk.os.system(...)(1) db2cmd db2
(2) LIST DATABASE DIRECTORY [ON drive]
(3) CATALOG DATABASE database-name [AS alias] [ON drive]
Perform extra tasks based on the project requirements, such as creating tables, preparing needed data, or creating a DB2 instance.os.system(...)db2 -tf filename -z logfile
db2 CREATE DATABASE database-name

WebSphere Application Server V5.1.1 setup

The WebSphere Application Server V5.1.1 setup isn't the focus of this article, but we're introducing it here because IBM Content Manager needs WebSphere Application Server V5.1.1. So the following section covers just enough of the WebSphere Application Server installation and configuration to show you how it supports the IBM Content Manager installation. (For more information about WebSphere Application Server V5.1.1 installation and configuration, visit the WebSphere Application Server information center.)

WebSphere Application Server pre-installation

  1. Check to see whether there's a WebSphere Application Server V5.1.1 product already installed in the destination directory, as shown in Listing 6.

    Listing 6. Check to see if there's a WebSphere Application Server V5.1.1 product already installed in the destination directory
    #Check to see whether there's a WebSphere Application Server V5.1.1 
          product already installed in the destination dir
    def checkWASInstalled():
     versionInfo = WASBinDir + "\\versionInfo.bat"
     if(not os.path.exists(versionInfo)):
      return False
     versionLog = "versionInfo.log"
     os.system(versionInfo + " > " + versionLog)
     installed = False;
     if os.path.exists(versionLog):
      f = file(versionLog, 'r')
      #Read all content in versionLog, and try to find version in the versionLog
      for line in f:           
       if line.find(version) != -1:
        installed = True
      f.close()
     return installed
    

WebSphere Application Server installation

  1. Check to see if the WebSphere Application Server response file is prepared.
  2. Execute the WebSphere Application Server V5.1.0 silent installation.

    Listing 7. Execute WebSphere Application Server V5.1.0 silent installation
    def installWAS(self, executeFile, responseFile) :   
     #1. Check to see  if the WebSphere Application Server response file is prepared.
     if os.path.exists(responseFile):
      executeFile = executeFile + " -options " + responseFile
      #2. Execute WebSphere Application Server 5.1.0 silent installation.
      os.system(executeFile)
      return True
     else :
      log( responseFile + " is invalid!" )
      return False
    

  3. Check to see whether WebSphere Application Server V5.1.0 is installed successfully. Here you use the operation checkWASInstalled, shown in Listing 6.
  4. Execute the WebSphere Application Server V5.1.1 fix pack silent update.

    Listing 8. Execute WebSphere Application Server V5.1.1 fix pack
    #4. Install WebSphere Application Server 5.1.1 fix pack silent update.
    def installWASFixPack() :
     log( "start to install the fixpack of WAS ...." )
     logfile = "fixpack.log";
     command = FixpackExecutableFile 
      + " -fixpack -install -installDir " + "\"" 
      + WASInstalledDir + "\""\
      + " -fixpackDir " + "\"" + FixpackDir
      + "\"" + " -fixpackID " + FixpackID
      + " -ihsInstallDir " + IHSInstalledDir
      + " -skipMQ " + "> " + logfile
     os.system(command)
     log( "The installation is ended!" )        
     return True
    

WebSphere Application Server post-installation

  1. Make sure that WebSphere Application Server V5.1.1 has been installed successfully. Here you use the operation checkWASInstalled, shown in Listing 6.

Table 2 shows detailed information about how you use Python and WebSphere Application Server commands in your WebSphere Application Server automatic installation scripts.


Table 2. Detailed information about Python and WebSphere Application Server commands
StepsTaskPython functionsWebSphere Application Server commands
Pre-installationCheck to see whether a WebSphere Application Server V5.1.1 product is installed in the destination directory.os.system(...)versionInfo.bat
InstallationConfirm that the response file has already been prepared.os.path.exists(...)-
Execute the WebSphere Application Server V5.1.0 silent installation. os.system(...)win\Install.exe -options responseFile.txt
Execute the WebSphere Application Server V5.1.1 fix pack silent update. os.system(...)fixpackDir\updateSilent.bat -fixpack -install -installDir WAS511InstalledDir -fixpackDir fixpackDir\ fixpacks -fixpackID "was51_fp1_win" -ihsInstallDir IHSInstalledDir -skipMQ > logfile
Post installationCheck to see if the installation was successful.os.system(...)versionInfo.bat

IBM Content Manager setup

This section walks you through the steps involved in IBM Content Manager setup. IBM Content Manager depends on a DB2 server and WebSphere Application Server V5.1.1. So in the pre-installation of DB2 Content Manager, you also complete steps for DB2 setup and WebSphere Application Server setup.

IBM Content Manager pre-installation

  1. Check to see whether IBM Content Manager is installed in the destination directory.
  2. Check to see whether DB2 and WebSphere Application Server V5.1.1 have been installed. If they have not been installed, please go perform the installation steps discussed in the DB2 setup and WebSphere Application Server V5.1.1 setup sections.

    Listing 9. IBM Content Manager pre-installation
    #1. Check to see if IBM Content Manager is installed in the destination dir.
    def checkDB2CMInstallation():
     foundedString = "IBM Content Manager Enterprise Edition"
     if(code == "IIC"):
      foundedString = "IBM DB2 Information Integrator for Content"
     elif(code == "EC"):
      foundedString = "IBM Content Manager eClient"
     db2cmlevel = CMBinDir + "\\cmlevel.bat" > filename
     if(os.path.exists(db2cmlevel)) :
      os.system(db2cmlevel)
      if(os.path.exists(filename)):
       f = file(filename)
       for line in f:
        if(line.startswith(foundedString)):
         log("The " + code + " has been installed")
         return True
     log("The " + code + " has not been installed")
     return False
    
    #2. Check to see if DB2 and WebSphere Application Server V5.1.1 are installed
    def checkPreRequisit(self):
     if(not checkWASInstalled()):
      log("WAS 511 has not been installed")
      return False
     if(not checkDB2Installed()):
      log("DB2 has not been installed")
      return False
     return True
    

IBM Content Manager installation

  1. Start the WebSphere Application Server V5.1.1 server called server1.

    Listing 10. Start the WebSphere Application Server V5.1.1 server called serverName
    def startServer(serverName):
     if(not self.serverStatus(serverName)):
      log( "try to start " + serverName)
      logfile = "startServer.log"
      startfile = WASBinDir + "\\startServer.bat"
      os.system(startfile)
      return True
    

  2. Check to see if the IBM Content Manager response file is prepared.
  3. Execute the IBM Content Manager silent installation.
  4. Make sure that IBM Content Manager is installed successfully.

    Listing 11. IBM Content Manager installation
    def installCM() :
     executeDir = CMSrcInstallDir
     executeFile = CMSrcInstallDir + "\\setup-cm-8.3.00.exe"
     responseFile = CM_response_file
     logfile = 'cminstall-rc.txt'
     successString = "0"
     self.installDB2CMProduct(executeDir, executeFile, responseFile)
     # Check that the IBM Content Manager is installed successfully.
     if(os.path.exists(logfile)) :
      f = file(logfile)
      for line in f:
       if(line.startswith(successString)):
        return True
     return False
    
    def installDB2CMProduct(executeDir, executeFile, responseFile) :
     if os.path.exists(responseFile)
          and os.path.exists(executeFile):
      executeFile = executeFile + " -is:javahome " 
         + executePath + "java\\jre"
         + " -options " + responseFile\
         + " -silent" 
      #execute db2cm product silent instalation
      os.system(executeFile)
      return True
     else :
      log( responseFile + " or " 
           + executeFile + " is invalid!" )
      return False
    

  5. Start the WebSphere Application Server V5.1.1 server named icmrm, which is added by the IBM Content Manager installation.
  6. Check to see if the IBM DB2 Information Integrator for Content response file is prepared.
  7. Execute the DB2 Information Integrator for Content silent installation.
  8. Make sure that DB2 Information Integrator for Content is installed successfully.

    Listing 12. DB2 Information Integrator for Content installation
    def installIIC() :
     executeDir = IICSrcInstallDir
     executeFile = IICSrcInstallDir + "\\setup-ii4c-8.3.00.exe"
     responseFile = IIC_response_file
     logfile = 'ii4cinstall-rc.txt'
     successString = "0"
     if(not startServer("icmrm")): #5. Start WebSphere Application Server 
              V5.1.1 server named icmrm.
      log("Fail to start icmrm, please take a look at the WebSphere server")
      return False
     self.installDB2CMProduct(executeDir, executeFile, responseFile)
     # Check that the DB2 Information Integrator for 
         Content is installed successfully.
     if(os.path.exists(logfile)) :
      f = file(logfile)
      for line in f:
       if(line.startswith(successString)):
        return True
     return False
    

  9. Check to see if the IBM Content Manager eClient response file has been prepared.
  10. Execute the IBM Content Manager eClient silent installation.
  11. Make sure that the IBM Content Manager eClient is installed successfully.

    Listing 13. IBM Content Manager eClient installation
    def installEC() :
     executeDir = ECSrcInstallDir
     executeFile = ECSrcInstallDir + "\\setup-ec-8.3.00.exe"
     responseFile = EC_response_file
     logfile = 'ecinstall-rc.txt'
     successString = "0"
     if(not startServer("icmrm")): #5. start was 511 server named icmrm.
      log("Fail to start icmrm, please take a look at the WebSphere server")
      return False
     self.installDB2CMProduct(executeDir, executeFile, responseFile)
     # Make sure the IBM Content Manager eClient is installed successfully.
     if(os.path.exists(logfile)) :
      f = file(logfile)
      for line in f:
       if(line.startswith(successString)):
        return True
     return False
    

IBM Content Manager post-installation

Because you've already checked the installation result in the IBM Content Manager installation section, there are no more tasks in this step.

Table 3 shows detailed information about how you use Python, WebSphere Application Server, and IBM Content Manager commands in your IBM Content Manager automatic installation scripts.


Table 3. Detailed information about Python, WebSphere Application Server, and IBM Content Manager commands
StepTaskPython functionIBM Content Manager command
Pre-installationCheck to see if there's an IBM Content Manager product installed in the destination directory.os.path.exists(...)cmlevel.bat
Check to see if WebSphere Application Server is started.os.system(...)startServer [serverName]
[serverName] can be server1 or icmrm.
This is a WebSphere Application Server command.
Check to see if DB2 is installed.This depends on other Python modules that were developed earlier in the article. See the operation checkDB2Installed in Listing 2.
InstallationExecute IBM Content Manager silent installation.os.system(...)[executeFile] -is:javahome executePath java\\jre -options responseFile.txt –silent
[executeFile] can be setup-cm-8.3.00.exe, setup-ii4c-8.3.00.exe, or setup-ec-8.3.00.exe due to the code (CM, IIC, or EC).
Post-installationCheck the installation logs to confirm that the IBM Content Manager installation is finished with no errors.file(...)-

Conclusion

This article introduced how to automatically install DB2 and IBM Content Manager, and how to make use of Python. After finishing your design and implementation, you applied those scripts to prepare development and test environments for other team members. You've seen that it saves time and that it's easy to use. Plus, you were able to do all of this installation using only one command!


Resources

Learn

Get products and technologies

  • Download IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.

Discuss

About the authors

HeQing Guan's photo

HeQing Guan (Hawking) is a senior software engineer on the IBM Global Business Solution Center team. He has a doctorate from the Chinese Academy of Sciences and has worked in the SOA field for almost 5 years.

Qiang Bai's photo

Qiang Bai has worked as a software engineer with the Global Business Solution Center in CSDL. In addition to focusing on software configuration management (SCM) products, he is responsible for developing the solution assets built on IBM's Service-Oriented Architecture (SOA) methodology.

YuLin Chen's photo

YuLin Chen is a software engineer in the IBM Global Business Solution Center. He is responsible for developing the solution assets built on IBM's Service-Oriented Architecture (SOA) methodology.

YaoFei Zhu's photo

YaoFei Zhu (Richard) joined the IBM China Development Lab in 2005 and has worked in Linux on POWER and on Global Business Solution Center (GBSC) teams as a system developer, application developer, and infrastructure architect. He has more than 6 years of experience in AIX, Linux, System p, System x, storage, and SOA.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services, Information Management
ArticleID=346422
ArticleTitle=Automatic deployment toolkit for an SOA project environment, Part 3: IBM DB2 for Linux, UNIX, and Windows and IBM Content Manager automatic installation scripts
publish-date=10172008
author1-email=guanheq@cn.ibm.com
author1-email-cc=flanders@us.ibm.com
author2-email=baiqiang@cn.ibm.com
author2-email-cc=flanders@us.ibm.com
author3-email=chenyul@cn.ibm.com
author3-email-cc=flanders@us.ibm.com
author4-email=zhuyaof@cn.ibm.com
author4-email-cc=flanders@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers