天天看點

docker釋出LCN5.0.2分布式事務服務端(LCN官方推薦)

第一種方式:

注:官方提供的方式(此種方式docker能釋出成功,TxManager背景也能正常通路,但是微服務項目啟動的時候報錯)

1、增加外部配置檔案運作. 需要在主控端器上有檔案 application-dev.properties

      我的配置檔案路徑 /usr/local/laoxu/docker_project/lcn/application-dev.properties

内容如下:

spring.application.name=TransactionManager
server.port=7970
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.1.81:3306/tx-manager?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
#第一次運作項目,初始化用create建立表,以後用none或者update
spring.jpa.hibernate.ddl-auto=none

#TxManager Ip,預設為127.0.0.1
tx-lcn.manager.host=192.168.1.81
#TM監聽scoket端口,預設為8070
tx-lcn.manager.port=8070
#TM背景登入密碼
tx-lcn.manager.admin-key=123456

#心跳檢測時間(ms)
tx-lcn.manager.heart-time=15000
#分布式事務執行總時間(ms)
tx-lcn.manager.dtx-time=30000
#參數延遲删除時間ms
tx-lcn.message.netty.attr-delay-time=10000
#事務處理并發等級,預設為機器核心數5倍
tx-lcn.manager.concurrent-level=150

#redis位址
spring.redis.host=192.168.1.81
#redis端口
spring.redis.port=6379
#redis密碼
#spring.redis.password=123456

#是否啟用日志
#tx-lcn.logger.enabled=true
#設定日志級别
#logging.level.com.codingapi=debug

# 雪花算法的sequence位長度,預設為12位
tx-lcn.manager.seq-len=12
 
# 異常回調開關。開啟時請制定ex-url
tx-lcn.manager.ex-url-enabled=false
 
# 事務異常通知(任何http協定位址。未指定協定時,為TM提供内置功能接口)。預設是郵件通知
tx-lcn.manager.ex-url=/provider/email-to/***@**.com

           

2、執行指令,使用  -v  檔案挂載

docker run -d -p 7970:7970 -p 8070:8070  \
--name tm -v /usr/local/laoxu/docker_project/lcn:/usr/local/laoxu/docker_project/lcn  \
-e spring.profiles.active=dev  \
-e spring.config.additional-location=/usr/local/laoxu/docker_project/lcn/application-dev.properties  \
codingapi/txlcn-tm
           

我使用官方的docker釋出方法,采用LCN分布式事務的微服務項目啟動報錯,報錯内容如下:

While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either than the input has been truncated or that an embedded message misreported its own length.

如果報錯請采用第二種方式(自己打包,建構鏡像,docker釋出)

第二種方式:https://blog.csdn.net/qq_42714869/article/details/90514762