OceanBase
English日本語简体中文
ドキュメントホーム
製品
エコシステム
リリース

データベース

OceanBase CloudOceanBaseデータベース

データベース

OceanBase CloudOceanBaseデータベース
OceanBase CloudOceanBaseデータベース

OceanBaseデータベース

  • エコシステム統合の概要
  • ORMフレームワーク
    • Java
      • SpringBootサンプルプログラム
      • SpringBatchサンプルプログラム
      • Spring JDBCサンプルプログラム
      • SpringDataJPAサンプルプログラム
      • Hibernateサンプルプログラム
      • MyBatisサンプルプログラム
    • Python
      • SQLAlchemyによるOceanBaseデータベース接続サンプルプログラム
      • peeweeによるOceanBaseデータベース接続サンプルプログラム
      • Tortoise ORM による OceanBase データベース接続サンプルプログラム
    • Go
      • GORMサンプルプログラム
    • Rust
      • SeaORM による OceanBase データベース接続サンプルプログラム
    • Ruby
      • ActiveRecordによるOceanBaseデータベース接続サンプルプログラム
      • Sequel で OceanBase データベースに接続するサンプルプログラム
      • Ruby on RailsによるOceanBaseデータベース接続サンプルプログラム
    • Node.js
      • SequelizeでOceanBaseデータベースに接続する
      • TypeORMを使用してOceanBaseデータベースに接続する
      • Prismaを使用してOceanBaseデータベースに接続する
      • Drizzle ORMを使用してOceanBaseデータベースに接続する
    • C#
      • Dapperを使用してOceanBaseデータベースに接続する
      • SqlSugarを使用してOceanBaseデータベースに接続する
      • FreeSQLを使用してOceanBaseデータベースに接続する
    • PHP
      • Yii 2.0 ORMサンプルプログラム
      • Laravel Eloquent ORMサンプルプログラム
  • データベースのバージョン管理
    • Liquibaseを使用したOceanBaseデータベースのバージョンの管理
    • Flywayを使用してOceanBaseデータベースを統合し、バージョン管理を実現する
  • データ統合
    • dbtを使用したOceanBaseデータの分析
    • Flink DirectLoadを使用したOceanBaseのダイレクトインポート
    • SeaTunnelを使用したOceanBaseデータの読み取りと同期
    • Maxwellを使用したOceanBaseデータの読み取り
    • Debeziumを使用してOceanBaseに接続し、データを取得する
    • Spark Catalogを使用してOceanBaseデータベースに接続する
    • Apache NiFiを使用してOceanBaseデータベースと統合する
  • SQL開発
    • WebLogicを使用してOceanBaseデータベースに接続する
    • DBeaverを使用してOceanBaseデータベースに接続する
    • Navicatを使用してOceanBaseデータベースに接続する
    • DataGripでOceanBaseデータベースに接続する
    • TablePlusでOceanBaseデータベースに接続する
    • DMSを使用したOceanBaseデータベースの管理
  • 編成とスケジューリング
    • AirflowとOceanBaseデータベースの連携
    • PowerJobとOceanBaseデータベースの連携
    • DolphinSchedulerにOceanBaseデータソースを設定する
    • LinkisとOceanBaseデータベースの統合
  • 可視化ツール
    • SupersetとOceanBaseを使用したデータ分析
    • Power BIでOceanBaseに接続してデータを取得する
    • Quick BIでOceanBaseに接続してデータを取得する
    • Bytebaseを使用したOceanBaseインスタンスの管理
  • データベース管理
    • NineDataを使用したOceanBaseデータソースの管理
    • Bytebaseを使用したOceanBaseインスタンスの管理
  • AI
    • OpenAI
    • Qwen
    • OceanBaseデータベースとLangChainの統合
    • OceanBaseデータベースのベクトル検索機能とLlamaIndexの連携
    • OceanBaseデータベースのベクトル検索機能とDifyの連携
    • OceanBaseデータベースとn8nの連携
    • OceanBase MCP ServerとTraeの連携
    • OceanBaseデータベースとSpring AI Alibabaの連携
    • OceanBase MCP ServerとClineの連携
    • OceanBase MCP ServerとCursorの連携
    • OceanBase MCP ServerとContinueの連携
    • Google GenAI Toolboxを使用して独自のOceanBase MCP Serverを構築する
    • OceanBaseデータベースとCamelAIの連携
    • OceanBase VectorとFirecrawlの連携
    • OceanBase VectorとHugging Faceの連携
    • OceanBase VectorとOllamaの連携
    • OceanBaseデータベースとGoogle Geminiの連携
    • OceanBase VectorとCloudflare Workers AIの連携
    • OceanBase VectorとJina AIの連携
    • OceanBase MCP ServerとAugment Codeの連携
    • OceanBase MCP ServerとClaude Codeの連携
    • OceanBase MCP ServerとKiroの連携

PDF をダウンロード

このページには現在中国語/日本語版がなく、英語版を表示しています。
ドキュメントフィードバック
  1. ドキュメントセンター
  2. OceanBaseデータベース
  3. master

Use Seata to implement distributed transaction management for OceanBase Database

最終更新:2026-09-04 07:40:45

Version compatibility
Limitations
Limitations on SQL statements
Prerequisites
Procedure
Step 1: Obtain the connection string of OceanBase Database
Step 2: Prepare the Seata sample project
Step 3: Create a database and initialize data
Step 4: Configure the application connection information
Step 5: Start Seata-Server
Step 6: Start the sample services
Step 7: Test distributed transactions
Verify the results

Apache Seata is an open-source distributed transaction solution that provides high-performance and easy-to-use distributed transaction services in a microservices architecture. This topic describes how to integrate Seata with the Dubbo microservices framework to implement distributed transaction management for OceanBase Database. It covers the use of the AT mode, the creation of the undo_log table, and the testing of transaction commit and rollback.

Version compatibility

Seata is integrated with OceanBase Database. We recommend that you use the following versions:

  • OceanBase Database: ≥ V4.2.1
  • Seata-Server: ≥ V2.1.0

Limitations

When you use Seata with OceanBase Database, note the following limitations:

Limitations on SQL statements

  • Seata transactions support only some features of the INSERT, UPDATE, and DELETE statements.
  • DDL statements such as CREATE, ALTER, and DROP are not supported.
  • Stored procedures, functions, and triggers cannot be called.
  • The supported SQL statements are being expanded. We recommend that you use only the SQL statements supported by Seata.

Prerequisites

Before you use Seata, make sure that:

  • You have installed Seata-Server. For more information, see Download Seata-Server.
  • You have deployed OceanBase Database and created a MySQL mode user tenant.
  • You have cloned the seata-samples project to your local computer and imported it to your development tool. Then, find the /at-sample/dubbo-samples-seata subproject.

Procedure

Step 1: Obtain the connection string of OceanBase Database

Contact the OceanBase Database deployment personnel to obtain the connection string, for example:

obclient -h$host -P$port -u$user_name -p$password -D$database_name

Parameter description:

  • $host: the IP address for connection. For ODP connection, use the ODP address. For direct connection, use the OBServer IP address.

  • $port: the connection port. For ODP connection, the default value is 2883. For direct connection, the default value is 2881.

  • $database_name: the database name.

    Notice

    The user for connecting to the tenant must have the CREATE, INSERT, DROP, and SELECT privileges on the database.

  • $user_name: the connection account. For ODP connection, the format is user@tenant#cluster or cluster:tenant:user. For direct connection, the format is user@tenant.

  • $password: the account password.

Example:

obclient -hxxx.xxx.xxx.xxx -P2881 -utest_user001@mysql001 -p****** -Dtest

Step 2: Prepare the Seata sample project

  1. Clone the sample project.

    Clone the Seata sample project from GitHub to your local machine:

    git clone https://github.com/apache/incubator-seata-samples
    
  2. Import the project.

    Import the project into your development tool:

    cd incubator-seata-samples/
    ls -l
    
  3. Locate the subproject.

    Find the /at-sample/dubbo-samples-seata subproject.

    ls -l  at-sample/springboot-dubbo-seata/
    

    The following subprojects are displayed:

    drwxr-xr-x 3 root root 4096 Apr 22 14:50 springboot-dubbo-seata-account
    drwxr-xr-x 3 root root 4096 Apr 22 14:50 springboot-dubbo-seata-business
    drwxr-xr-x 3 root root 4096 Apr 22 14:50 springboot-dubbo-seata-common
    drwxr-xr-x 3 root root 4096 Apr 22 14:50 springboot-dubbo-seata-order
    drwxr-xr-x 3 root root 4096 Apr 22 14:50 springboot-dubbo-seata-storage
    

Step 3: Create a database and initialize data

Create a test database in OceanBase Database and execute the following SQL script:

  1. Create the undo_log table (required for the Seata AT mode):

    -- for AT mode you must to init this sql for you business database. the seata server not need it.
    CREATE TABLE IF NOT EXISTS `undo_log`
    (
        `branch_id`     BIGINT       NOT NULL COMMENT 'branch transaction id',
        `xid`           VARCHAR(128) NOT NULL COMMENT 'global transaction id',
        `context`       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
        `rollback_info` LONGBLOB     NOT NULL COMMENT 'rollback info',
        `log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
        `log_created`   DATETIME(6)  NOT NULL COMMENT 'create datetime',
        `log_modified`  DATETIME(6)  NOT NULL COMMENT 'modify datetime',
        UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
        ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
    ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
    
  2. Create the business table and initialize the test data:

    DROP TABLE IF EXISTS `stock_tbl`;
    CREATE TABLE `stock_tbl`
    (
        `id`             int(11) NOT NULL AUTO_INCREMENT,
        `commodity_code` varchar(255) DEFAULT NULL,
        `count`          int(11) DEFAULT 0,
        PRIMARY KEY (`id`),
        UNIQUE KEY (`commodity_code`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    DROP TABLE IF EXISTS `order_tbl`;
    CREATE TABLE `order_tbl`
    (
        `id`             int(11) NOT NULL AUTO_INCREMENT,
        `user_id`        varchar(255) DEFAULT NULL,
        `commodity_code` varchar(255) DEFAULT NULL,
        `count`          int(11) DEFAULT 0,
        `money`          int(11) DEFAULT 0,
        PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    DROP TABLE IF EXISTS `account_tbl`;
    CREATE TABLE `account_tbl`
    (
        `id`      int(11) NOT NULL AUTO_INCREMENT,
        `user_id` varchar(255) DEFAULT NULL,
        `money`   int(11) DEFAULT 0,
        PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    ---INITIALIZE THE ACCOUNT TABLE
    INSERT INTO account_tbl(`user_id`,`money`) VALUES('ACC_001','1000');
    ---INITIALIZE THE STOCK TABLE
    INSERT INTO stock_tbl(`commodity_code`,`count`) VALUES('STOCK_001','100');
    

Step 4: Configure the application connection information

Update the database connection information in the following three submodules to match your OceanBase Database connection information:

  • dubbo-samples-seata-account
  • dubbo-samples-seata-order
  • dubbo-samples-seata-stock

Example:

url: jdbc:mysql://$host:$port/$database_name?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useOldAliasMetadataBehavior=true
username: $user_name
password: $password

Notice

Please replace $host, $port, $database_name, $user_name, and $password with your actual OceanBase Database connection information.

Description of the Seata configuration parameters

Parameter
Required
Default value
Type
Description
seata.tx-service-group Yes - String The name of the transaction service group.
seata.service.vgroup-mapping.default_tx_group Yes - String The transaction group mapping configuration.
seata.service.default.grouplist Yes - String The list of Seata-Server addresses.
seata.enable-auto-data-source-proxy No true Boolean Specifies whether to enable automatic data source proxy.
seata.client.tm.degrade-check-period No 2000 Integer The degradation check cycle of the transaction manager (TM) in milliseconds.
seata.client.tm.degrade-check-allow-times No 10 Integer The maximum number of times that the degradation check is allowed.
seata.client.rm.report-retry-count No 5 Integer The number of retries for reporting.
seata.client.rm.table-meta-check-enable No false Boolean Specifies whether to enable table metadata check.
seata.client.rm.report-success-enable No false Boolean Specifies whether to enable report success.

Example:

seata:
  tx-service-group: my_tx_group
  service:
    vgroup-mapping:
      my_tx_group: default
    default:
      grouplist: 127.0.0.1:8091
  enable-auto-data-source-proxy: true

Step 5: Start Seata-Server

  1. Download the binary package of Seata-Server from the Seata-Server GitHub repository and decompress it:

    wget https://github.com/apache/incubator-seata/archive/refs/tags/v2.6.0.tar.gz
    
  2. Go to the bin directory of the decompressed package:

    tar -zxvf v2.6.0.tar.gz
    cd incubator-seata-2.6.0/distribution/bin
    
  3. Execute the corresponding startup command based on your operating system:

    • For Mac OS or Linux:

      ./seata-server.sh
      
    • For Windows:

      ./seata-server.bat
      

Step 6: Start the sample services

Start the following subprojects in sequence:

  1. Account Service
  2. Order Service
  3. Stock Service
  4. Business Service

Step 7: Test distributed transactions

Test distributed transactions by accessing the following links:

  1. Test the successful commit process of a distributed transaction:

    Access: http://$test_host:$test_port/test/commit?userId=ACC_001&commodityCode=STOCK_001&orderCount=1

    When a distributed transaction is successfully committed, the data in the business tables will be updated normally. Please observe the data in the database tables.

  2. Test the rollback process of a distributed transaction:

    Access: http://$test_host:$test_port/test/rollback?userId=ACC_001&commodityCode=STOCK_001&orderCount=1

    When a distributed transaction is rolled back, the data in the business tables will remain unchanged. Please observe the data in the database tables.

Notice

Please replace $test_host and $test_port with the actual test service address and port.

Verify the results

  1. Verify that the transaction is successfully committed: After accessing the test link for a successful transaction commit, check if the data in the account_tbl, stock_tbl, and order_tbl tables in the database has been updated as expected.
  2. Verify that the transaction is rolled back: After accessing the test link for a failed transaction rollback, check if the data in the database tables remains unchanged to confirm that the transaction rollback was effective.
  3. Verify the status of the Seata-Server: Ensure that the Seata-Server is running normally. You can check the logs to confirm the transaction coordination status.

次のトピック

エコシステム統合の概要
次へ
このページの内容
Version compatibility
Limitations
Limitations on SQL statements
Prerequisites
Procedure
Step 1: Obtain the connection string of OceanBase Database
Step 2: Prepare the Seata sample project
Step 3: Create a database and initialize data
Step 4: Configure the application connection information
Step 5: Start Seata-Server
Step 6: Start the sample services
Step 7: Test distributed transactions
Verify the results