seata实际应用时遇到的问题合集

1.端口占用问题:
在linux服务器上启动seata-server时,提示
java.lang.RuntimeException: java.net.BindException: Address already in use
原因:seata-server默认端口为8091,其他服务已使用此端口
解决:启动时修改默认端口,Windows:seata-server.bat -p 18091
linux:sh seata-server.sh -p 18091(linux中默认不会后台启动,如果需要,执行启动命令:
nohup sh seata-server.sh -p 18091 > catalina.out 2>&1 &)

2.执行客户端业务报错:
Could not commit JDBC transaction; nested exception is java.sql.SQLException: io.seata.core.exception.RmTransactionException: Response[ TransactionException[branch register request failed. xid=192.168.1.151:18091:2040210106, msg=Data truncation: Data too long for ]

错误日志并没有打印完全,一头雾水,不知道是那个数据太长,观察seata服务端,也有错误日志:

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'table_name' at row 1
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4230)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2334)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2262)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2246)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at io.seata.core.store.db.LockStoreDataBaseDAO.doAcquireLock(LockStoreDataBaseDAO.java:319)
	... 23 common frames omitted

原因:这里可以明显看出是table_name超出数据库设置的长度了
解决:之前服务端依赖的三个表里的其中一个lock_table修改字段table_name的长度即可
seata实际应用时遇到的问题合集_第1张图片
3.启动客户端报错:

2020-03-14 15:57:17.298 ERROR 12748 --- [imeoutChecker_1] i.s.c.r.netty.NettyClientChannelManager  : no available service 'null' found, please make sure registry config correct

原因:两种可能 1.客户端和服务端的事务组名称不一致 2.没有添加spring-cloud-alibaba-seata的依赖
解决
1.修改服务端和客户端file.conf service下的vgroupMapping.ydc_tx_group = "default"以及客户端properties里的spring.cloud.alibaba.seata.tx-service-group = ydc_tx_group保持一致
如果还是不行检查是否有添加spring-cloud-alibaba-seata的依赖如果没有
2.添加pom依赖

		<dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-seata</artifactId>
            <version>2.1.0.RELEASE</version>
            <exclusions>
                <exclusion>
                    <artifactId>seata-all</artifactId>
                    <groupId>io.seata</groupId>
                </exclusion>
            </exclusions>
        </dependency>

你可能感兴趣的:(分布式事务,mysql,分布式)