零:相关问题解决
一般容易忘比如云服务器安全组的开放
docker ps 查看运行中的容器
[root@VM-12-7-centos resources]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
406794a01181 seataio/seata-server:1.4.2 "java -Djava.securit…" 7 days ago Up 7 days 0.0.0.0:8091->8091/tcp seata-server
a374ab5f1856 nacos/nacos-server:1.3.1 "bin/docker-startup.…" 8 days ago Up 7 days 0.0.0.0:8848->8848/tcp nacos
0059b1e18df8 zookeeper:3.7.0 "/docker-entrypoint.…" 3 weeks ago Up 8 days 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zookeeper
a4d77b20c42d xuxueli/xxl-job-admin:2.1.2 "sh -c 'java -jar /a…" 6 months ago Up 8 days 0.0.0.0:8010->8080/tcp xxl-job-admin
查看日志
docker logs 406794a01181
09:59:45.280 INFO --- [ettyServerNIOWorker_1_3_4] i.s.c.r.n.AbstractNettyRemotingServer : channel exx:Adjusted frame length exceeds 8388608: 539959368 - discarded,channel:[id: 0x33f60f16, L:/172.17.0.4:8091 - R:/180.163.220.3:38428]
09:59:45.280 WARN --- [ettyServerNIOWorker_1_3_4] io.netty.channel.DefaultChannelPipeline : An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
==>
报错信息是netty 解码大小相关,百度上搜了一下有说是版本号的,也有说是没有注册到nacos相关原因;
宿主机相关配置检查了一下是没问题的;
然后到容器里查看配置,如下;
发现并没有生效,估计是中间运行了几次容器,容器挂载目录可能失效了,手动修改一下:
registry和file配置文件
[root@VM-12-7-centos resources]# docker exec -it 406794a01181 /bin/sh
/seata-server # ls
classes libs resources sessionStore
/seata-server # cd resources/
/seata-server/resources # ks
/bin/sh: ks: not found
/seata-server/resources # ks
/bin/sh: ks: not found
/seata-server/resources # ls
META-INF README-zh.md README.md file.conf file.conf.example io logback logback.xml registry.conf
/seata-server/resources # vi registry.conf
registry {
# file ...nacos ...eureka...redis...zk...consul...etcd3...sofa
type = "file"
nacos {
application = "seata-server"
保存重启seata和nacos服务,查看日志和nacos客户端,已经有了刚刚的服务
一:拉取Seata镜像
docker pull seataio/seata-server:1.4.2
二:创建Seata容器并指定挂载目录
docker run -d \
--restart always \
--name seata-server \
-p 8091:8091 \
-v /docker-data/seata:/seata-server \
-e SEATA_IP=IP-ADDRESS \
-e SEATA_IP=101.****.62 \
-e SEATA_PORT=8091 \
seataio/seata-server:1.4.2
docker run -d \
--restart always \
--name seata-server \
-p 8091:8091 \
-v /docker-data/seata:/seata-server \
-e SEATA_IP=101.****.62 \
-e SEATA_PORT=8091 \
seataio/seata-server:1.4.2
三:拉取Nacos镜像
docker pull nacos/nacos-server -----拉取nacos镜像
四:创建Nacos容器
大致能运行打开;
docker run \
--name nacos -d \
-p 8848:8848 \
--privileged=true \
--restart=always \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
nacos/nacos-server
五:创建Seata相关表
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for undo_log
-- ----------------------------
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`xid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`context` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime(0) NOT NULL,
`log_modified` datetime(0) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `ux_undo_log`(`xid`, `branch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'seata操作记录表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for branch_table
-- ----------------------------
DROP TABLE IF EXISTS `branch_table`;
CREATE TABLE `branch_table` (
`branch_id` bigint(20) NOT NULL,
`xid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`transaction_id` bigint(20) NULL DEFAULT NULL,
`resource_group_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`resource_id` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`branch_type` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`status` tinyint(4) NULL DEFAULT NULL,
`client_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`application_data` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gmt_create` datetime(6) NULL DEFAULT NULL,
`gmt_modified` datetime(6) NULL DEFAULT NULL,
PRIMARY KEY (`branch_id`) USING BTREE,
INDEX `idx_xid`(`xid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'seata分支事务表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for global_table
-- ----------------------------
DROP TABLE IF EXISTS `global_table`;
CREATE TABLE `global_table` (
`xid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`transaction_id` bigint(20) NULL DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`transaction_service_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`transaction_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`timeout` int(11) NULL DEFAULT NULL,
`begin_time` bigint(20) NULL DEFAULT NULL,
`application_data` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gmt_create` datetime(0) NULL DEFAULT NULL,
`gmt_modified` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`xid`) USING BTREE,
INDEX `idx_gmt_modified_status`(`gmt_modified`, `status`) USING BTREE,
INDEX `idx_transaction_id`(`transaction_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'seata全局事务表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for lock_table
-- ----------------------------
DROP TABLE IF EXISTS `lock_table`;
CREATE TABLE `lock_table` (
`row_key` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`xid` varchar(96) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`transaction_id` bigint(20) NULL DEFAULT NULL,
`branch_id` bigint(20) NOT NULL,
`resource_id` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`table_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`pk` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gmt_create` datetime(0) NULL DEFAULT NULL,
`gmt_modified` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`row_key`) USING BTREE,
INDEX `idx_branch_id`(`branch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'seata锁表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
六:编辑Seata和Nacos相关配置
编辑配置相关文件 vim registry.conf
编辑以下两部分:
注册中心相关指向;
registry {
type = "nacos"
nacos {
# 应用名
application = "seata-server"
# nacos ip 地址
serverAddr = "101.****:8848"
# nacos创建的分组
group = "SEATA_GROUP"
# nacos 创建的命名空间名
namespace = "seata-naming"
cluster = "default"
# nacos登录的账号和密码
username = "nacos"
password = "nacos"
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
# nacos ip 地址
serverAddr = "101.****:8848"
# nacos 创建的命名空间名
namespace = "seata-naming"
# nacos创建的分组
group = "SEATA_GROUP"
# nacos登录的账号和密码
username = "nacos"
password = "nacos"
# nacos配置相当于主键id,唯一标识配置
dataId = "seataServer.properties"
}
file {
name = "file.conf"
}
}
编辑Seata存储数据的相关配置文件 vim file.conf;
这里面连接的库就是上面执行脚本的库;
## transaction log store, only used in seata-server
store {
## store mode: file、db、redis
mode = "db"
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
datasource = "druid"
## mysql/oracle/postgresql/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "com.mysql.cn.jdbc.Driver"
## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
url = "jdbc:mysql://182.****:3307/order-info"
user = "****"
password = "****"
minConn = 5
maxConn = 100
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
七:进入Nacos配置Seata相关信息
根据上一步注释可以看到需要修改补充哪些字段属性;
先在配置管理里面进行相应操作:
填写:Data Id = seataServer.properties
GROUP = SEATA_GROUP
配置内容:
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableClientBatchSendRequest=false
transport.threadFactory.bossThreadPrefix=NettyBoss
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
transport.threadFactory.clientSelectorThreadSize=1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
service.vgroupMapping.storage-service-group=default
service.vgroupMapping.order-service-group=default
service.vgroupMapping.account-service-group=default
service.default.grouplist=192.168.23.3:8091
service.enableDegrade=false
service.disableGlobalTransaction=false
client.rm.asyncCommitBufferLimit=10000
client.rm.lock.retryInterval=10
client.rm.lock.retryTimes=30
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
client.rm.reportRetryCount=5
client.rm.tableMetaCheckEnable=false
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.tm.commitRetryCount=5
client.tm.rollbackRetryCount=5
client.tm.defaultGlobalTransactionTimeout=60000
client.tm.degradeCheck=false
client.tm.degradeCheckAllowTimes=10
client.tm.degradeCheckPeriod=2000
store.mode=db
store.publicKey=
store.file.dir=file_store/data
store.file.maxBranchSessionSize=16384
store.file.maxGlobalSessionSize=512
store.file.fileWriteBufferCacheSize=16384
store.file.flushDiskMode=async
store.file.sessionReloadReadSize=100
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://182.****:3307/order-info?useUnicode=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
store.db.user=****
store.db.password=****
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
store.redis.mode=single
store.redis.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=
store.redis.sentinel.sentinelHosts=
store.redis.maxConn=10
store.redis.minConn=1
store.redis.maxTotal=100
store.redis.database=0
store.redis.password=
store.redis.queryLimit=100
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
client.undo.dataValidation=true
client.undo.logSerialization=jackson
client.undo.onlyCareUpdateColumns=true
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
client.undo.logTable=undo_log
client.undo.compress.enable=true
client.undo.compress.type=zip
client.undo.compress.threshold=64k
log.exceptionRate=100
transport.serialization=seata
transport.compressor=none
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
创建命名空间:
用于后面区分唯一服务和配置 ->
命名空间ID(不填则自动生成):seata-naming
命名空间名:seata
描述:desc
八:容器启动
docker stop seata-container-id 停掉
docker start seata-container-id 开启
docker ps 查看运行中的容器
docker logs containerid 启动打印日志
我遇到的问题放到了开头 第0点