seata docker 高可用部署的詳細介紹
版本
啟動
通過環(huán)境變量SEATA_CONFIG_NAME指定配置文件位置/root/seata-config/registry.conf
docker run --name seata-server \ -p 8091:8091 \ -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \ -v /User/seata/config:/root/seata-config \ seataio/seata-server
配置文件
實現(xiàn)高可用需要依賴注冊中心,配置中心,數(shù)據(jù)庫
registry.conf
registry { type = "nacos" nacos { application = "seata-server" serverAddr = "192.168.199.2" namespace = "test" group = "SEATA_GROUP" cluster = "default" username = "" password = "" } } config { type = "nacos" nacos { serverAddr = "192.168.199.2" namespace = "test" group = "SEATA_GROUP" username = "" password = "" } }
NACOS配置
注:使用nacos配置,需要在對應(yīng)分組(SEATA_GROUP)下針對配置項目逐條配置文本值,而不是創(chuàng)建包含所有配置的properties文件,可以使用官方源碼中的腳本導(dǎo)入
全部可用配置參考
1. 使用數(shù)據(jù)庫
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://192.168.199.2:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=123456
創(chuàng)建數(shù)據(jù)庫
-- -------------------------------- The script used when storeMode is 'db' -------------------------------- -- the table to store GlobalSession data CREATE TABLE IF NOT EXISTS `global_table` ( `xid` VARCHAR(128) NOT NULL, `transaction_id` BIGINT, `status` TINYINT NOT NULL, `application_id` VARCHAR(32), `transaction_service_group` VARCHAR(32), `transaction_name` VARCHAR(128), `timeout` INT, `begin_time` BIGINT, `application_data` VARCHAR(2000), `gmt_create` DATETIME, `gmt_modified` DATETIME, PRIMARY KEY (`xid`), KEY `idx_gmt_modified_status` (`gmt_modified`, `status`), KEY `idx_transaction_id` (`transaction_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- the table to store BranchSession data CREATE TABLE IF NOT EXISTS `branch_table` ( `branch_id` BIGINT NOT NULL, `xid` VARCHAR(128) NOT NULL, `transaction_id` BIGINT, `resource_group_id` VARCHAR(32), `resource_id` VARCHAR(256), `branch_type` VARCHAR(8), `status` TINYINT, `client_id` VARCHAR(64), `application_data` VARCHAR(2000), `gmt_create` DATETIME(6), `gmt_modified` DATETIME(6), PRIMARY KEY (`branch_id`), KEY `idx_xid` (`xid`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- the table to store lock data CREATE TABLE IF NOT EXISTS `lock_table` ( `row_key` VARCHAR(128) NOT NULL, `xid` VARCHAR(128), `transaction_id` BIGINT, `branch_id` BIGINT NOT NULL, `resource_id` VARCHAR(256), `table_name` VARCHAR(32), `pk` VARCHAR(36), `gmt_create` DATETIME, `gmt_modified` DATETIME, PRIMARY KEY (`row_key`), KEY `idx_branch_id` (`branch_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8;
異常處理
1. 客戶端報錯 Data too long for column ‘a(chǎn)pplication_id'
io.seata.core.exception.TmTransactionException: TransactionException[begin global request failed. xid=null, msg=Data truncation: Data too long for column ‘a(chǎn)pplication_id' at row 1]
at io.seata.tm.DefaultTransactionManager.begin(DefaultTransactionManager.java:55) ~[seata-all-1.3.0.jar:1.3.0]
at io.seata.tm.api.DefaultGlobalTransaction.begin(DefaultGlobalTransaction.java:104) ~[seata-all-1.3.0.jar:1.3.0]
at io.seata.tm.api.TransactionalTemplate.beginTransaction(TransactionalTemplate.java:175) ~[seata-all-1.3.0.jar:1.3.0]
seata數(shù)據(jù)庫global_table.application_id字段默認長度為varchar(32),如果客戶端應(yīng)用ID超長則報此錯
手動修改字段類型增加長度即可
到此這篇關(guān)于seata docker 高可用部署的文章就介紹到這了,更多相關(guān)seata docker部署內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
dockerfile指令構(gòu)建docker鏡像的示例代碼
本文主要介紹了dockerfile指令構(gòu)建docker鏡像的示例代碼,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-04-04在Docker中的ubuntu中安裝Python3和Pip的問題
這篇文章主要介紹了在Docker中的ubuntu中安裝Python3和Pip的問題,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-02-02淺談docker --privileged=true參數(shù)作用
這篇文章主要介紹了淺談docker --privileged=true參數(shù)作用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12Mac上將brew安裝的MySql改用Docker執(zhí)行操作過程
本文分步驟給大家介紹Mac上將brew安裝的MySql改用Docker執(zhí)行操作過程的知識,本文給大家介紹的非常詳細,具有參考借鑒價值,感興趣的朋友一起看看吧2016-11-11docker學(xué)習(xí)筆記之把容器commit成鏡像的方法
本篇文章主要介紹了docker學(xué)習(xí)筆記之把容器commit成鏡像,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05