Tuxedo 9.0 for AIX与Oracle 10 XA连接
系统说明
TUXEDO版本:9.0 安装目录 /opt/bea/tuxedo9.0
ORACLE版本:10.2.0.1 安装目录 /u01/app/oracle
一、Tuxedo 9 for AIX的安装
1、创建一个用户为Tuxedo,用户组为bea
2、创建/opt/bea为tuxedo的安装目录,
$mkdir /opt/bea
$chown tuxedo.bea /opt/bea
$chmod 770 /opt/bea
#bootinfo -k
64
$ sh tuxedo9_aix53_64.bin -i console
Preparing to install...
WARNING: /tmp does not have enough disk space!
Attempting to use /home/tuxedo for install base and tmp dir.
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
Launching installer...
Preparing CONSOLE Mode Installation...
===============================================================================
Choose Locale...
----------------
->1- English
CHOOSE LOCALE BY NUMBER: 1
===============================================================================
(created with InstallAnywhere by Zero G)
-------------------------------------------------------------------------------
===============================================================================
Introduction
------------
BEA End User Clickwrap 001205
Copyright (c) BEA Systems, Inc.
All Rights Reserved.
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y
===============================================================================
Choose Install Set
------------------
Please choose the Install Set to be installed by this installer.
->1- Full Install
2- Server Install
3- Full Client Install
4- Jolt Client Install
5- ATMI Client Install
6- CORBA Client Install
7- Customize...
ENTER THE NUMBER FOR THE INSTALL SET, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
: 1
===============================================================================
Choose BEA Home
---------------
1- Create new BEA Home
2- Use existing BEA Home
Enter a number: 2
1- /opt/bea
Existing BEA Home directory: 1
===============================================================================
Choose Product Directory
------------------------
1- Modify Current Selection (/opt/bea/tuxedo9.0)
2- Use Current Selection (/opt/bea/tuxedo9.0)
Enter a number: 2
===============================================================================
Pre-Installation Summary
------------------------
Please Review the Following Before Continuing:
Product Name:
Tuxedo 9.0
Install Folder:
/opt/bea/tuxedo9.0
Link Folder:
/home/tuxedo
Disk Space Information (for Installation Target):
Required: 386,803,702 bytes
Available: 2,625,392,640 bytes
PRESS <ENTER> TO CONTINUE:
===============================================================================
Ready To Install
----------------
InstallAnywhere is now ready to install Tuxedo 9.0 onto your system at the
following location:
/opt/bea/tuxedo9.0
PRESS <ENTER> TO INSTALL:
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Configure tlisten Service
-------------------------
Password: tuxedo
Verify Password: tuxedo
Password Accepted! Press "Enter" to continue.
===============================================================================
SSL Installation Choice.
------------------------
Would you like to install SSL Support?
->1- Yes
2- No
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:
: 2
===============================================================================
License Installation Choice
---------------------------
Would you like to install your license now?
->1- Yes
2- No
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:
: 2
===============================================================================
Installation Complete
---------------------
Congratulations. Tuxedo 9.0 has been successfully installed to:
/opt/bea/tuxedo9.0
PRESS <ENTER> TO EXIT THE INSTALLER:
安装完毕,需要把license文件重命名为lic.txt copy到$TUXDIR/udataobj/
二、TUxedo 9 连接 Oracle 10g配置
前提是在Tuxedo 9 上安装Oracle 10g client还有安装C编译器(不一定要用Visual Age C/C++ 7,这里我用的是pro c),设置Tuxedo用户能够通过sqlplus连接oracle数据库
1、ORACLE的的配置
sqlplus system@testcrm
SQL> @$ORACLE_HOME\rdbms\admin\xaview.sql
SQL>grant select on v$xatrans$ to public with grant option;
SQL>grant select on v$pending_xatrans$ to public with grant option;
SQL>grant select EMP to Scott
SQL>GRANT SELECT ON DBA_PENDING_TRANSACTIONS TO Scott;
注:scott默认为lock,需要用alter user scott account unlock,解锁。
2、设置Tuxedo用户的.profile文件
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.TH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin
/X11:/sbin:.
TUXDIR=/opt/bea/tuxedo9.0
APPDIR=/opt/bea/tuxedo9.0/test
TUXCONFIG=$APPDIR/tuxconfig
CCOMP=/usr/vac/bin
PATH=$PATH:$TUXDIR/bin:$CCOMP
:$ORACLE_HOME/bin
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client_1
export ORACLE_SID=ORCL
export ORACLE_TERM=vt100
export NLS_LANG="AMERICAN_America.ZHS16GBK"
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/network/lib:/usr/lib:$ORACLE_HOME/lib:$TUXDIR/lib
export PATH APPDIR TUXDIR TUXCONFIG CCOMP
if [ -s "$MAIL" ] # This is at Shell startup. In normal
then echo "$MAILMSG" # operation, the Shell checks
fi
3、修改$TUXDIR\udataobj目录下的RM文件
把以Oracle_XA:xaosw:开头的一行用#注释掉,并加入一行:
Oracle_XA:xaosw:-L${ORACLE_HOME}/lib ${ORACLE_HOME}/precomp/lib/cobsqlintf.o -lclntsh
注意空格
3、在TUXEDO用户下创建TMS文件:TMS_ORA10g,TUXEDO通过TMS_ORA10g与ORACLE数据库采用XA协议进行通讯
buildtms -o $TUXAPP/TMS_ORA10g -r Oracle_XA
4、配置 UBBCONFIG
#ghts Reserved.
#ident "@(#) samples/atmi/simpapp/ubbsimple $Revision: 1.5 $"
#Skeleton UBBCONFIG file for the TUXEDO Simple Application.
#Replace the <bracketed> items with the appropriate values.
*RESOURCES
IPCKEY 32770
#DOMAINID simpapp
MASTER simple
MAXACCESSERS 100
MAXSERVERS 50
MAXSERVICES 100
MODEL SHM
LDBAL N
*MACHINES
"Server" LMID=simple
APPDIR="/opt/bea/tuxedo9.0/test"
TUXCONFIG="/opt/bea/tuxedo9.0/test/tuxconfig"
TUXDIR="/opt/bea/tuxedo9.0"
TLOGDEVICE = "/opt/bea/tuxedo9.0/test/TLOG"
TLOGNAME=TLOG
TLOGSIZE=100
*GROUPS
GROUP1 LMID=simple GRPNO=1 OPENINFO="ORACLE_XA:Oracle_XA+Acc=P/scott/scott+sqlNet=ORCL+SesTm=100+LogDir=.+MaxCur=5"
TMSNAME="TMS_ORA10g" TMSCOUNT=2
*SERVERS
DEFAULT:
CLOPT="-A"
test SRVGRP=GROUP1 SRVID=1
*SERVICES
注意OPENINFO中P/scott/scott+sqlNet=ORCL需要根据实际情况自定义,还有机器名“server”,必须与uname -n显示的机器名一致
使用
$tmloadcf -y ubbsimple 生产TUXCONFIG文件
5、用TMADMIN创建TLOG文件,TUXEDO用一个文件TLOG记录对数据库操作的日志。用于协调分布式数据库的提交与回滚。
$tmadmin
>crdl -b 500 -z $TUXAPP/TLOG
>crlog -m simple
>q
6、重命名下列文件,因为下列文件名与ORACLE带的文件名有冲突
TUXEDO安装路径$TUXDIR/include目录下的下面文件
把sqlca.h 改名为 sqlca.h.bak
把sqlcode.h 改名为 sqlcode.h.bak
把sqlda.h 改名为 sqlda.h.bak
7、服务端的程序:test.pc,功能:根据客户端传的EMPNO到表EMP中取ENAME的值,并把它返回给客户端
编写客户端程序: testcli.c 功能:调用TUXEDO服务端的服务TEST,取EMPNO=7900所对应的ENAME的值,并显示出来
这里为没有写代码,因为我发现我到网搜索的测试代码都没法通过。
五、编译服务端程序
1.用ORACLE的PROC把test.pc 文件预编译成test.c文件
$ proc test.pc include=$TUXDIR\include
2.用buildserver把test.c编译成可执行文件,注意-r 后带的Oracle_XA 与RM文件中的一致。
$ buildserver -o test -f test.c -r Oracle_XA -s TEST
编译客户端程序
$ buildclient -o testcli -f testcli.c
8、用 tmboot –y 启动TUXEDO
应能看到所有的SERVER都启动成功。这时,我们的服务端程序test 会自动与ORACLE数据库建立连接,并一直保持这个连接,
直到TUXEDO系统或ORACLE数据库关闭。所以在我们的程序test.pc中看不到与数据库连接的语句,因为现在与数据库的连接由TUXEDO自动管理。
如果TMS_ORA10g启动失败会在当前目录生成一个*.trc文件,记录失败的原因,同时TUXEDO的ULOG文件中也会有一些错误信息。可参考这些错误信息进行错误分析。
$ tmboot -y
Booting all admin and server processes in /opt/bea/tuxedo9.0/test/tuxconfig
INFO: BEA Tuxedo, Version 9.0, 64-bit, Patch Level 002
INFO: Serial #: 454493271161-2143645176821, Expiration NONE, Maxusers 5
INFO: Licensed to: Shenzhen Edensoft Information
Booting admin processes ...
exec BBL -A :
process id=409822 ... Started.
Booting server processes ...
exec TMS_ORA10g -A :
process id=282686 ... Started.
exec TMS_ORA10g -A :
process id=401624 ... Started.
exec test -A :
process id=397522 ... Started.
4 processes started.
9、运行客户端程序
运行后应能看到服务端返回的结果。
$ testcli
如果编写的程序没有问题,就能返回值