Storing transaction logs in a relational database

You can choose to store your Liberty transaction logs in a relational database rather than as operating system files. In the WebSphere® Application Server traditional, this feature provides high availability (HA) support without having to use a shared file system.

About this task

The WebSphere Application Server transaction service writes information to a transaction log for every global transaction that involves two or more resources, or that is distributed across multiple servers. These transactions are started or stopped either by applications or by the container in which they are deployed. The transaction service maintains transaction logs to ensure the integrity of transactions. Information is written to the transaction logs in the prepare phase of a distributed transaction, so that if a WebSphere Application Server with active transactions restarts after a failure, the transaction service is able to use the logs to replay any indoubt transactions. This allows the overall system to be brought back to a consistent state.

In previous releases of WebSphere Application Server, the transaction logs were stored as operating system files. In WebSphere Application Server Version 8.5.5 and later, this remains the default configuration but you can choose to store the transaction logs in a relational database management system (RDBMS). This configuration option is aimed at customers that work in an HA environment. In previous releases of WebSphere Application Server, HA transaction support required the use of a shared file system to host the transaction logs, such as an NFSv4-mounted network-attached storage (NAS) or a storage area network (SAN). This new feature allows customers, particularly those customers with an investment in HA database technology, to use their HA database as a shared repository for the transaction logs, as an alternative to using a shared file system.

By default, Liberty transaction logs are stored in operating system files. However, for compatibility with the WebSphere Application Server traditional, and for evaluation and testing purposes, you can configure the transaction logs to be stored in an RDBMS. You can use any database type that is supported by Liberty.

Procedure

To configure the Liberty transaction logs to be stored in an RDBMS, complete the following steps:

  1. Configure a dedicated, non-transactional data source in the Liberty server.xml file.
    The following example extract from the server.xml file shows how to configure Liberty to store its transaction logs in a DB2® database:
    <transaction> 
      <dataSource transactional="false">
        <jdbcDriver libraryRef="DB2JCC4LIB"/>
        <properties.db2.jcc currentSchema="CBIVP"
          databaseName="SAMPLE" driverType="4"
          portNumber="50000" serverName="localhost" 
          user="db2admin" password="{xor}Oz1tPjsyNjE=" />
      </dataSource> 
    </transaction> 
    
    <library id="DB2JCC4LIB">
      <fileset dir="C:/SQLLIB/java" includes="db2jcc4.jar db2jcc_license_cu.jar"/>
    </library>
  2. (optional) Create the database tables.

    Liberty attempts to create the necessary database tables when the server first starts. When creating these databases is not possible, due to insufficient permission for example, the server fails to start. Under these circumstances, you must create the two database tables manually.

    The following DDL structures show how to create the tables on DB2:
    CREATE TABLE WAS_TRAN_LOG(
      SERVER_NAME VARCHAR(128),
      SERVICE_ID SMALLINT,
      RU_ID BIGINT,
      RUSECTION_ID BIGINT,
      RUSECTION_DATA_INDEX SMALLINT,
      DATA LONG VARCHAR FOR BIT DATA) 
    CREATE TABLE WAS_PARTNER_LOG(
      SERVER_NAME VARCHAR(128),
      SERVICE_ID SMALLINT,
      RU_ID BIGINT,
      RUSECTION_ID BIGINT,
      RUSECTION_DATA_INDEX SMALLINT,
      DATA LONG VARCHAR FOR BIT DATA) 
    The following DDL structures show how to create the database table on Oracle:
    CREATE TABLE WAS_TRAN_LOG(
      SERVER_NAME VARCHAR(128),
      SERVICE_ID SMALLINT,
      RU_ID NUMBER(19),
      RUSECTION_ID NUMBER(19),
      RUSECTION_DATA_INDEX SMALLINT,
      DATA BLOB)
    CREATE TABLE WAS_PARTNER_LOG(
      SERVER_NAME VARCHAR(128),
      SERVICE_ID SMALLINT,
      RU_ID NUMBER(19),
      RUSECTION_ID NUMBER(19),
      RUSECTION_DATA_INDEX SMALLINT,
      DATA BLOB)

Icon that indicates the type of topic Task topic

File name: twlp_store_logs_in_rdb.html