Sunteți pe pagina 1din 32

2006 BEA Systems, Inc.

Distributed Transaction
Applications Administration
At the end of this module, you will be able to:
Understand the distributed transaction architecture
used in XA Tuxedo applications
Configure Tuxedo applications to support XA
transactions
Deploy and manage Tuxedo transaction logs
Monitor and troubleshoot an XA Tuxedo application
Module 11
Distributed Transaction Applications Administration-1
2006 BEA Systems, Inc. 322
Road Map
1. Transactions Overview
ACID Properties
The Extended Architecture (XA) Standard
The Two-Phase Commit (2PC) Protocol
Tuxedo Transaction Manager Service (TMS) Servers
2. Configuring Tuxedo for Transaction Support
Distributed Transaction Applications Administration-2
2006 BEA Systems, Inc. 323
Transaction Definitions
The term transaction is used in a variety of different
contexts:
1. A blocking call from one process to another (RPC).
2. A database client application updates one or more records
in a database.
Local Transaction
3. An application updates records in more than one system.
Global Transaction
While the general definition is technically applicable
to all of these:
This module specifically covers Tuxedos role in managing
global transactions.
Distributed Transaction Applications Administration-3
2006 BEA Systems, Inc. 324
When Transactions Are Needed
DATABASE
Client
SERVER
Client
ORACLE
MQSeries
When an application interacts with a single database only,
typically the database itself will manage the transaction.
A transaction involving multiple systems will need a
transaction manager to coordinate the transaction
activity among the systems. The transaction boundary is
determined by the transaction originator which scopes
the work to be done within the distributed transaction.
Transaction Boundary
SERVER
SERVER
Distributed Transaction Applications Administration-4
2006 BEA Systems, Inc. 325
ACID Properties
ACID properties of Transactions and
Databases are:
Atomicity all or nothing
Consistency state transformation
Isolation no concurrency anomalies
Durability survive failures
Distributed Transaction Applications Administration-5
2006 BEA Systems, Inc. 326
The XA Standard
The Extended Architecture (XA) is the standard
interface used by resource clients and a Transaction
Manager Service (TMS) to access a Resource Manager
(RM).
XA is widely supported in all of the major database and
messaging products.
Allows TMS servers to coordinate distributed global
transactions with one or more RMs.
The XA Protocol is used only by the system software
Application programmers do not need to deal directly with
the XA interface.
Distributed Transaction Applications Administration-6
2006 BEA Systems, Inc. 327
XA Resource Managers
Storage mechanisms are referred to as application
resources, typically a database.
In XA terminology, application resources are accessed
via a Resource Manager (RM), such as the RDBMS
Server.
Server A
Application
Resource
(anything that
supports XA)
Resource
Manager
Transaction
Manager
Server B
Distributed Transaction Applications Administration-7
2006 BEA Systems, Inc. 328
Two-Phase Commit
XA defines a Two-Phase Commit (2PC) protocol to
support Distributed Transactions using XIDs.
The TMS manages the committing of transactions (on
behalf of the application):
Requesting the participating RMs to prepare to commit the
transaction.
If all RMs respond OK, the TMS tells all of them to
commit.
If any of the RMs fail to respond, the TMS tells the other
RMs to abort (roll back their part of the transaction).
Distributed Transaction Applications Administration-8
2006 BEA Systems, Inc. 329
Transactions in Tuxedo
Tuxedo supports distributed transactions by
Generating a global transaction identifier (GTRID)
understood by all participants corresponding to an XID.
Tracking active transactions through the TLOG.
Providing access notification to RMs.
Coordinating the 2PC.
Initiating recovery if failures occur.
Multiple TMS servers may be involved, each is
specifically configured to communicate with a specific
RM.
Tuxedo requires limiting one specific RM per Server Group.
Multiple RMs will require multiple Tuxedo Server Groups.
Distributed Transaction Applications Administration-9
2006 BEA Systems, Inc. 330
XA Distributed Transaction Processing
WITHDRAW
TMS 1
RM 1
(RDBMS)
ATMI
Client
TLOG
XID
GTRID
tpcommit
tpabort
SQL
w/XID
DEPOSIT
TMS 2
TLOG
RM 2
(RDBMS)
XID
Transaction
Coordination
BB
tpbegin
tpcall
w/GTRID
tpcall
w/GTRID
7
7
6
5
4
3
2
1
8
7
SQL
w/XID
Distributed Transaction Applications Administration-10
2006 BEA Systems, Inc. 331
Two-Phase Commit (CMTRET COMPLETE)
Application commit
call returns
TMS returns
control
to application
Initiator
RMs commit
(CMTRET COMPLETE)

TMS tells all RMs
to commit
PHASE 2

TMS receives
acknowledgements
TMS writes
GTRID to TLOG
PHASE 1
Sites precommit
and acknowledge
TMS sends
precommit
message
Application
requests
commit
time
TMS
(Coordinator)
RMs
(Participants)
Distributed Transaction Applications Administration-11
2006 BEA Systems, Inc. 332
Two-Phase Commit (CMTRET LOGGED)
Application commit
call returns
Initiator
RMs commit
returns control
to application
(CMTRET LOGGED)

TMS tells all RMs
to commit AND
PHASE 2

TMS receives
acknowledgements
TMS writes
GTRID to TLOG
PHASE 1
Sites precommit
and acknowledge
TMS sends
precommit
message
Application
requests
commit
time
TMS
(Coordinator)
RMs
(Participants)
Distributed Transaction Applications Administration-12
2006 BEA Systems, Inc. 333
Section Review
Leverage the XA standard to support global
transactions
Understand the role of TMS servers and Resource
Managers in XA transactions
Recognize the trade-offs between a complete or a
logged two-phase commit

In this section, we learned how to:
Distributed Transaction Applications Administration-13
2006 BEA Systems, Inc. 334
Road Map
1. Transactions Overview
2. Configuring Tuxedo for Transaction Support
Creating the Transaction Log Device and TLOG
Defining Transaction Management Service (TMS) Server
eExecutables
Configuring RESOURCES, MACHINES, GROUPS, and
SERVICES Sections for XA Support

Distributed Transaction Applications Administration-14
2006 BEA Systems, Inc. 335
Configuring Transaction Support
Below is a summary of the sections and parameters
used to configure XA transaction support:
Transaction Management Service (TMS) server
TMSNAME
GROUPS
Logical name of the transaction log Default: TLOG TLOGNAME
MACHINES
Transaction timeout for AUTOTRAN Default: 30s TRANTIME
String used with XA RM tpclose() call CLOSEINFO
String used with XA RM tpopen() call OPENINFO
Automates transactions for service Default: N
Number of TMS servers to boot Min: 2 Default: 3
Offset page in TLOGDEVICE Default: 0
Size of TLOG in physical pages Default: 100
Specifies the device (or file) containing TLOG
Configures early or late XA 2PC Default: COMPLETE
Total # of concurrent transactions Default: 100
Description
TLOGSIZE
TLOGOFFSET
CMTRET
MAXGTT
RESOURCES
TLOGDEVICE
AUTOTRAN
SERVICES
TMSCOUNT
Parameter Section
Distributed Transaction Applications Administration-15
2006 BEA Systems, Inc. 336
Configuring RESOURCES
MAXGTT is the total number of global transaction
identifiers (GTRIDs) allocated per machine. May be
overridden in MACHINES section.
This value corresponds to maximum number of concurrent
in-flight transactions.
Late commit implementation
Early commit implementation
For RM vendors
implementing XA
Have committed
COMPLETE
Have pre-committed
Global Transactions
commit when participants
LOGGED
CMTRET
Example RESOURCES section configuration:
*RESOURCES
MAXGTT 350
CMTRET LOGGED
Distributed Transaction Applications Administration-16
2006 BEA Systems, Inc. 337
Configuring MACHINES
Each Machine supporting XA transactions needs its
own TLOG:
TLOGDEVICE: A binary file or raw disk device
TLOGNAME: A logical name for the TLOG
TLOGSIZE: The size of the TLOG in physical pages
TLOGDEVICE = C:\student\bin\TUXFS
TLOGNAME = myTLOG
Example of an XA configuration in the MACHINES section:
*MACHINES
TUXSTUDENT LMID=SITE1 APPDIR=C:\apps
TUXDIR=C:\bea\tuxedo9.0
TUXCONFIG=C:\apps\tuxconfig




TLOGDEVICE=C:\apps\APPDEVICE
TLOGNAME=AppTLOG
TLOGSIZE=350
Distributed Transaction Applications Administration-17
2006 BEA Systems, Inc. 338
Configuring the TLOG
The tuxconfig binary must first be loaded from the
UBBCONFIG text file using tmloadcf.
Enter tmadmin (in boot mode)
crdl creates the binary file or raw disk device
crlog initializes the TLOG on the device (default offset is 0)
Example tmadmin usage:
C:\ tmadmin
...
No bulletin board exists. Entering boot mode.

> crdl b 400 z C:\apps\APPDEVICE
Device created: C:\apps\APPDEVICE

> crlog m SITE1
crlog successfully completed
The z value must exactly match
the TLOGDEVICE parameter
Distributed Transaction Applications Administration-18
2006 BEA Systems, Inc. 339
Defining the TMS
Each server group containing servers that participate in
global transactions will need their own defined TMS.
Tuxedo provides these three TMS server executables:
TMS_QM: used for TUXEDO/Q System Queuespaces.
TMS_SQL: used for TUXEDO/SQL System Databases.
TMS: the null TMS used for servers that may participate in
a global transaction but do not access an XA-compliant RM.
Tuxedo provides the buildtms utility to create your
own TMS compatible with your XA-compliant RM.
If necessary, add a line that describes your particular RM in
the $TUXDIR/udataobj/RM file.
Distributed Transaction Applications Administration-19
2006 BEA Systems, Inc. 340
Building an RM-specific TMS Server
Example RM File Adding an Oracle Server Info String:

# BEA makes no attempt to keep the information in the following samples
# up to date. To make sure you have correct and complete information
# for your platform and RM version, please consult your RM vendor.

# ORACLE 8i


# INFORMIX-Online 5
INFORMIX-OnLine:infx_xa_switch:${INFORMIXDIR}/lib/esql/libinfxxa.a -lx
# INFORMIX-Online 6
#INFORMIX-OnLine:infx_xa_switch:${INFORMIXDIR}/lib/esql/libinfxxa.a
${INFORMIXDIR}/lib/esql/libsql.a ${INFORMIXDIR}/lib/libasf.a ${INFORMIXDIR}/lib/netlib.a
${INFORMIXDIR}/lib/esql/libgen.a ${INFORMIXDIR}/lib/esql/libos.a -lsocket -lm
#ident "@(#) tuxedo/cmdtux/nt/RM $Revision: 1.3 $"
TUXEDO/D;tuxd_switch;%TUXDIR%\lib\librms.lib %TUXDIR%\lib\libfs.lib
TUXEDO/SQL;tuxsql_switch;%TUXDIR%\lib\libsql.lib %TUXDIR%\lib\libusort.lib
%TUXDIR%\lib\librms.lib %TUXDIR%\lib\libfs.lib
NONE;tmnull_switch;
TUXEDO/QM;tuxq_switch;%TUXDIR%\lib\libqm.lib
#ident "@(#)RM 1.3

Building an Oracle TMS:


ORACLE_XA;xaosw;%ORACLE_HOME%\pro80\lib\msvc\sqllib80.lib
%ORACLE_HOME%\rdbms80\xa\xa80.lib %ORACLE_HOME%\OCI80\LIB\MSVC\ORA803.LIB
Oracle RM
libraries
Must match the tag
name in the RM file
TMS executable
name
buildtms o TMS_ORA -r ORACLE_XA
Distributed Transaction Applications Administration-20
2006 BEA Systems, Inc. 341
Building a Tuxedo Server Executable
All server executables assigned to the same group will
also need to be complied with the same RM libraries.
Use buildserver with the r option.
The r value refers to the same entry in the RM file used by
the buildtms utility.
The XA libraries are used to support embedded SQL
statements.
Building an application server executable accessing an XA RM:
buildserver o DBServer f DBServer.c
s TRANSFER


Must match the tag
name in the RM file
-r ORACLE_XA
Distributed Transaction Applications Administration-21
2006 BEA Systems, Inc. 342
Configuring GROUPS
Set TMSNAME to the name of the TMS executable.
TMSCOUNT is the number to boot. Default: 3 Min: 2
The OPENINFO parameter specifies the connection
string that will be used by each TMS server and each
application server in this group.
Example XA group configured in the GROUPS section :
*GROUPS
ORAGRP
GRPNO=5 LMID=SITE1




TMSNAME=TMS_ORA TMSCOUNT=2
OPENINFO=ORACLE_XA:Oracle_XA+Acc=P/system/manager
+SesTm=100+LogDir=.+DbgFl=0x7
+MaxCur=15+Threads=true
Distributed Transaction Applications Administration-22
2006 BEA Systems, Inc. 343
Configuring SERVICES
AUTOTRAN=Y|N
A Service configured with the AUTOTRAN=Y parameter will
be automatically started in transaction mode if the requestor
has not already initiated a transaction. Default: N
TRANTIME=<seconds>
Specifies the default timeout value in seconds for a
transaction automatically started for this service. Default: 30s
Example SERVICES section entries:
*SERVICES
DEPOSIT AUTOTRAN=Y TRANTIME=20
TRANSFER AUTOTRAN=Y TRANTIME=60
Distributed Transaction Applications Administration-23
2006 BEA Systems, Inc. 344
Transaction Scenarios
Immediate Rollback
Client or server-started transaction terminates abnormally
Rollback before a Tx Timeout occurs
Participant service returns failure (TPSVCFAIL)
Tuxedo software experiences an operating system or
network-access error
Rollback caused by a Tx Timeout
Participant service terminates abnormally
Timeout due to computer or network failure
No Tuxedo
Administration
action is
required for
any of these
scenarios!
Distributed Transaction Applications Administration-24
2006 BEA Systems, Inc. 345
Heuristic Conditions
Short Term Failure
Coordinator continues to attempt to contact the remote site/s
Remote site/s TMS servers will contact Coordinator site after
recovery to determine the status
Long Term Failure during the second phase of the 2PC
If Coordinator site has failed, Administrator may need to get
a backup machine started
Administrator will need to migrate the TLOG to backup (if
the TLOG disk is accessible)
No Administrator action is
required for this condition
If necessary, use
tmadmin commands...
Distributed Transaction Applications Administration-25
2006 BEA Systems, Inc. 346
Aborting and Committing Transactions
The Tuxedo Administrator may need to manually
commit or abort in-flight transactions if:
The TMS Coordinator site becomes partitioned.
The transaction originator terminates before committing
the transaction.
tmadmin commands:
Commit transactions of a TMS of a
group. Fails if not pre-committed or
marked aborted
Abort transactions of a TMS of a group
View information on active transactions
Description
printtrans (pt)
aborttrans (abort)
committrans (commit)
Command
Distributed Transaction Applications Administration-26
2006 BEA Systems, Inc. 347
Monitoring Transactions
printtrans displays global transaction information
in the TLOG for either the specified machine or the
default machine.
Provides information on gtrid number, status, time
left, and number of participants.
The verbose option
also provides the
group involved and
the coordinator
Distributed Transaction Applications Administration-27
2006 BEA Systems, Inc. 348
Transaction Log Commands
During a Server Group migration, use the following
commands to dump, load and restart the TLOG.
Syntax for dumplog, loadtlog, and logstart:
dumptlog [-z config][-o offset][-n name][-g groupname] filename
loadtlog -m LMID filename
logstart LMID
Name of the destination ASCII text file
filename
Description
loadtlog Options
Name and path location of TLOGDEVICE
-z config
TLOG offset (in bytes)
-o offset
Machine where the TLOG will be loaded to
-m LMID
Only the transactions for this group where the
TMS was the coordinator are dumped
-g groupname
TLOGNAME; defaults to TLOG
-n name
Description
dumptlog Options
Distributed Transaction Applications Administration-28
2006 BEA Systems, Inc. 349
Migrating the Transaction Log
BEFORE
stop -R GRP1
dumptlog ab_tlogfile
AFTER
Group GRP1
TLOG
Server
TMS
Group GRP1
TLOG
Server
TMS
Machine AB
Machine AB
Machine XY
Machine XY
loadtlog -m XY ab_tlogfile
logstart XY
migg GRP1
tmadmin
transfer ab_tlogfile to XY
DOWN
tmadmin
1
2
3
Distributed Transaction Applications Administration-29
2006 BEA Systems, Inc. 350
Section Review
Create the Transaction Log Device and TLOG
Define and deploy Transaction Management Service
(TMS) server executables
Configure RESOURCES, MACHINES, GROUPS, and
SERVICES sections for XA Support
In this section, we learned how to:
Distributed Transaction Applications Administration-30
2006 BEA Systems, Inc. 351
Lab Exercise
For details on the exercise, refer to the Lab Guide.
If questions arise, ask the instructor.
The instructor will determine the stop time.
Lab 12 TRAN: Configure and Deploy an XA
Tuxedo Application
Distributed Transaction Applications Administration-31
2006 BEA Systems, Inc. 352
Module Review
Leverage the distributed transaction architecture
used in XA Tuxedo applications
Configure Tuxedo applications to support XA
transactions
Deploy and manage Tuxedo transaction logs
Monitor and troubleshoot an XA Tuxedo
application
In this module, we learned how to:
Distributed Transaction Applications Administration-32

S-ar putea să vă placă și