Monday, February 28, 2011

Install & Configure Oracle Database Gateway for MQ

This is a digression from the usual entry but it took me a while to install and configure the gateway and I think it may be useful to anyone trying it in the future. The documentation in the main is excellent but there are a few instructions that my installation required that were not documented.

Oracle Database Gateway for MQ (64-bit Linux installation)

I installed the Gateway on a separate server from the database. The WebSphere MQ was installed on it's own server also.  

Basic Requirements

·         X-Windows server (e.g. Cygwin, Xming)
·         Ssh client software (e.g. putty)
·         linux.x64_11gR2_gateways.zip file.
·         mqc6_6.0.2.10_linuxx86-64.tar
·         Oracle 11GR2 database installed

Installation documents

Gateway:
IBM MQ Client

Installation Steps

·         Install MQ Client
·         Install Procedural Gateway
·         Configure Gateway

Install MQ Client


N.B. Deploy the samples or we can’t test the Queue

Procedure

  • Log in as root.
  • Create the directories to hold the MQ code and working data.
o   The WebSphere MQ is installed in /opt/mqm.
The working data uses /var/mqm
·         Create a user ID and group ID  mqm.
o   Set the users home directory to /var/mqm
  • Change into the unzipped MQ product directory  
    • Run the mqlicense.sh script.
./mqlicense.sh -accept
You must accept the license agreement before you can proceed with the installation.
  • Use the rpm -ivh command to install each component that you require.
o   rpm -ivh MQSeriesRuntime-6.0.2-10.x86_64.rpm MQSeriesClient-6.0.2-10.x86_64.rpm MQSeriesSamples-6.0.2-10.x86_64.rpm




Verify

Go to /opt/mqm/samp/bin
·         CHANNEL1 = the server-connection channel defined on the MQ server
·         TCP = the communications protocol.
·         server-hostname = the TCP/IP host name of the server.
·         port =port MQ is listening on (Default 1414)
set MQSERVER=‘CHANNEL1/TCP/server-hostname(port)’ –Use quotes in Linux

Browse the queue
amqsgbrc <<Queue Name>> <<Queue Manager>>

Output (Successful)
Sample AMQSGBR0 (browse) start
<<Queue Manager>>
Messages for <<Queue Name>> (ctrl+C to stop or just let it browse the msgs)
1 <RFH >
2 <RFH >

Install Procedural Gateway

Log-in as the user intended to own the gateway software
Unzip the linux.x64_11gR2_gateways.zip file.

Pre-installation

Determine where the WebSphere MQ queue manager runs.
Local system                      Oracle SID = dg4mqs
Remote system                                Oracle SID = dg4mqc
We require the
1.       MQ Queue Manager
2.       MQ Channel
3.       MQ server-host IP
4.       MQ Port

Installation


Navigate to the unzipped folder and  ./runInstaller to run the GUI installer
For installation instructions use section 5 of the Oracle Installation guide

Configure Oracle Procedural Gateway

The gateway is installed and preconfigured using default values for the gateway SID, directory names, file names, and gateway parameter settings.
 The default SID values are:
·         dg4mqs               
o    The default SID that is used when the gateway resides on the same system as the WebSphere MQ software.
·         dg4mqc
o    The default SID that is used when the gateway resides on a different system than the WebSphere MQ software. 
 A basic gateway initialization file is also installed, and values in this file are set based on the information entered during the installation phase.

Listener.ora


We want to make 2 changes to the Listener File.
1.       We want to an add an EXTPROC entry to listen for the external library
a.       This will allow the database to connect to the correct library
2.       We want to add the LD_LIBRARY_PATH to the dg4mqc entry
a.       This will allow us to use the correct 64-bit library and eliminate the error
(ADDRESS=(PROTOCOL=tcp)(HOST=172.30.10.48)(PORT=10400)) * establish * dg4mqc * 12518
TNS-12518: TNS:listener could not hand off client connection
 TNS-12547: TNS:lost contact
  TNS-12560: TNS:protocol adapter error
   TNS-00517: Lost contact
    Linux Error: 32: Broken pipe



Example Listener
 Oracle_Home = /home/oracle/product/11.2.0/tg_1
SID_LIST_LISTENER =
   (SID_LIST =
     (SID_DESC=
            (SID_NAME= PLSExtProc)
            (ORACLE_HOME=/home/oracle/product/11.2.0/tg_1)
            (PROGRAM= extproc)
            (ENVS="EXTPROC_DLLS=ANY:/home/oracle/product/11.2.0/tg_1/bin/libdg4mqc.so")
            )
       (SID_DESC=
         (SID_NAME=dg4mqc)
         (ORACLE_HOME=/home/oracle/product/11.2.0/tg_1)
         (PROGRAM=dg4mqc)
         (ENVS="LD_LIBRARY_PATH=/opt/mqm/lib64")
      )
   )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
  )

DIRECT_HANDOFF_TTC_LISTENER=OFF

ADR_BASE_LISTENER = /home/oracle/product/11.2.0/tg_1
TRACE_LEVEL_LISTENER=ADMIN
TRACE_DIRECTORY_LISTENER=/home/oracle/product/11.2.0/tg_1/network/trace
TRACE_FILE_LISTENER=listener
LOG_DIRECTORY_LISTENER=/home/oracle/product/11.2.0/tg_1/network/log
LOG_FILE_LISTENER=listener
To test the dg4mqc programme is pointing to the correct library at the command line run
$ dg4mqc



Set the LD_LIBRARY_PATH and rerun


Tnsnames.ora
The database server needs an entry in the tnsnames.ora to connect to the gateway (via database link)
DG4MQC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = dg4mqc)
      (SERVER=DEDICATED)
    )
  )


Database Link

A connection to the gateway is established through a database link when it is first used in an Oracle session.
CREATE PUBLIC DATABASE LINK dblink USING 'DG4MQC'; 
The AUTHORIZATION_MODEL parameter is set to RELAXED and as such no username or password are required.

Alias Library

Create the Oracle Database Gateway for WebSphere MQ alias library, libdg4mq, using the Oracle Database Gateway for WebSphere MQ deployment scripts. During installation, the appropriate shared library name is defined ORACLE_HOME/dg4mq/admin/deploy/pgmobj.sql on UNIX
For a remote model, the libdg4mqc.so shared library is used.
For example:
CREATE OR REPLACE LIBRARY libdg4mq AS 'ORACLE_HOME/lib/libdg4mqc.so' TRANSACTIONAL;




Preparing the Production Oracle Database


Before you can compile MIPs on a production Oracle database, the following PL/SQL packages must be present on the production Oracle database:
·         DBMS_PIPE, DBMS_OUTPUT, and UTL_RAW
o    Installed as part of a typical database creation
·         PGM, PGM_BQM, PGM_SUP, and UTL_PG
o    These packages are shipped with your Oracle Database Gateway for WebSphere MQ and are present in ORACLE_HOME/dg4mq/admin/deploy
Copy the scripts in this directory to the database server OR configure a connection to the database server
To install the packages we use the script pgmdeploy.sql. The pgmdeploy script connects as scott/tiger so we need to edit the script and change this to a valid user, include the database connection script here also.  Change the line connect SYS/&INPASS2 as sysdba to include the database connection string connect SYS/&INPASS2@oracl as sysdba.
Set the Oracle_SID
         sqlplus /nolog @pgmdeploy.sql
The PQM_UTL8 procedure relies on the Visual workbench Repository so it will be invalid.

Testing the MQ connection


Reload the listener on the Gateway server
$ lsnrctl reload
Use the test.sql script from the ORACLE_HOME/dg4mq/sample directory on the gateway.
Edit the file to change the lines
  objdesc.objectname := '<<Your Queue name>>';
  objdesc.dblinkname := '<<Your DB Link>>';

From SQL prompt execute the script SQL> @test

Notes

No trace files will be written for MQ unless there has been a valid attempt to connect to MQ
The 3 Issues I encountered were
1.       Port not open on the firewall     -No Trace file written
2.       LD_LIBRARY_PATH not set/pointed to correct library      - No Trace file written
3.       Library not declared in an exproc entry in the listener     -Trace file written

Install Weblogic on RHEL 5.5 with ADF

Basic Requirements

·         X-Windows server (e.g. Cygwin, Xming)
·         Ssh client software (e.g. putty)
·         jdk-6u23-linux-x64-rpm.bin
·         wls1034_generic.jar
·         jdevstudio11114install.bin

Install the 64bit JDK

Download jdk-6u23-linux-x64-rpm.bin
Become root by running the su command and entering the root password.
 Extract and install the contents of the downloaded file.
Change directory to where the downloaded file is located and run these commands to first set the executable permissions and then run the binary to extract and run the RPM file:
              
·         chmod a+x jdk-6u23-linux-x64-rpm.bin

·         ./jdk-6u2323-linux-x64-rpm.bin

The script displays a binary license agreement, which you are asked to agree to before installation can proceed. Once you have agreed to the license, the install script creates and runs the file jdk-6u 23-linux-x64.rpm in the current directory.

Install 64bit Weblogic

Download jar file wls1034_generic.jar (from additional platforms column)File may be named .zip, rename the .zip file to be .jar
Navigate to the JDK bin directory
$ ./java -Xmx1024m -jar wls1034_generic.jar -Djava.io.tmpdir=tmpdirpath
  1. Use a custom install and deselect the following which are not needed:
    • Workshop
    • Web 2.0 http pub-sub server
    • Weblogic Web Server Plugins
    • UDDI and Xquery Support
    • Server Examples
  2. Select the JVM  
  3. Complete the install -sticking to the defaults,
    • Uncheck the Quickstart option on the last screen

Install ADF option

Download jdevstudio11114install.bin
$ ./ jdevstudio11114install.bin
  1. Choose existing middleware home in the home type and select the home that you just created for the Weblogic server install
  2. On the product selection screen select ADF Runtime
  3. Run the install.

Configuration

  1. Now run the Configuration Wizard (config.sh)
    • Optionally select the quickstart option
  2. Create a new WebLogic domain
    • Choose the first option on the next screen to pre-configure the domain with
      1.  WebLogic Server
      2. ADF (JSF)
    • Create the admin user as weblogic /<<password>>
    •   Choose production mode
    • On the next screen  customize the ports - choose yes
      1. Assign the server to use ports 80 and 81
    • Just choose next on the RDBMS security store page
    • On the configure the Admin Server page
      1. Set the port to 81
    • On the next page Add one managed server called <<MyManagedServer>>
      1. Set the port to 80
    • No need for clustering in this case so next through the cluster page
    • Create a machine on the next screen.
      1. If you are using a machine with a known DNS name and fixed IP address use that.
    • Next through to the summary screen
    • In the Create WebLogic Domain screen change the name of the domain to <<your-domain-name>> and press create.
    • Finish the wizard.

Start the Admin Server


When installing Weblogic on Red-Hat x86_64 using 32-bits JVM, the Weblogic can't find the performance pack and therefore can't enable native network IO.Copy libmuxer.so into the ORACLE_HOME/wlserver_10.3/server/native/linux/x86_64 from ORACLE_HOME /wlserver_10.3/server/native/linux/server/native/linux/i686
We need a file boot.properties to get the server to start in production mode
o   Create a security directory under the Managed Server Name in Domains etc.
ORACLE_HOME/user_projects/domains/base_domain/servers/AdminServer
§  Create a directory called security
§  Create a file called boot.properties
·         username=Weblogic
password=<password>
Repeat for each managed server
Now from the command line start the Admin Server
$ORACLE_HOME/ wlserver_10.3/server/bin /setWLSEnv.sh
Navigate to $ORACLE_HOME/user_projects/domains/base_domain
/.nohup startWebLogic.sh -Djava.awt.headless=true &
This will start the admin-server in the background; the –Djava.awt.headless=true switch ensures the application displays graphics correctly.
If the boot.properties files is not present the server will fail to start, you will be prompted to enter the Weblogic user but not the password. In order to display the password append
 
-Dweblogic.management.allowPasswordEcho=true to the startWebLogic command
Ø  Once the Admin-Server is started run the console
Ø  http://<<servername/IP>>:81/console
Ø  Log in    Weblogic/<<password>>
Ø  In the console, click deployments in the Domain Structure tree
o   adf.oracle.domain(1.0,11.1.1.0.0)
o   jsf(1.2,1.2.7.1)
o   jstl(1.2,1.2.0.1)
Ø  Press Lock and edit in the “change centre” box at the top left of the screen.
Ø  Drill down through each of the Deployments and select the Targets tab. For each one check the checkbox for both the Managed-Server and the Admin-Server
Ø  Save each deployment change as you make it
Ø  Finally press the Activate Changes button

Start the Managed-Server

Navigate to $ORACLE_HOME/user_projects/domains/base_domain/bin
nohup ./startManagedWebLogic.sh "<<MANAGED-SERVER>>" "http://host-name:81" &
Now we can run ADF applications on both servers
When we deploy an app it will prompt to deploy to either the Admin Server or the managed server.
    • Deploy to the Admin Server in addition to the Managed Server to ensure the security files are installed