天天看点

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