docker 运行 seata-server 配置nacos
服务端及源码下载地址:https://seata.apache.org/zh-cn
项目地址: https://github.com/seata/seata
项目官网: https://seata.io/zh-cn/docs/overview/what-is-seata.html
重要bug提示:seata at模式 每个库中的undo_log表的id一定删除掉,不然业务数据添加时返回的id会获取undo_log表中最新id设置到实体里面,1.4.2版本已经废弃id字段了
常见问题: https://seata.io/zh-cn/docs/overview/faq.html 问题10有说明
两个版本方式:
1、拉取镜像
docker pull seataio/seata-server:1.2.0
docker pull seataio/seata-server:1.3.0
docker pull seataio/seata-server:1.4.2
docker pull seataio/seata-server:1.5.2 #配置方式变成了application.yml方式
2、运行镜像
docker run --name seata-server -p 8091:8091 -d seataio/seata-server:1.2.0
docker run --name seata1.3.0 -p 8091:8091 -d seataio/seata-server:1.3.0
docker run --name seata1.4.2 -p 8091:8091 -d seataio/seata-server:1.4.2
3、复制配置文件到主机
docker cp seata-server:/seata-server /home/dockerdata/seata/seata-server
docker cp seata1.3.0:/seata-server /home/dockerdata/seata1.3.0/seata-server
docker cp seata1.4.2:/seata-server /home/dockerdata/seata1.4.2/seata-server
4、停止服务
docker stop seata-server
docker stop seata1.3.0
docker stop seata1.4.2
5、删除服务
docker rm seata-server
docker rm seata1.3.0
docker rm seata1.4.2
6、重新运行服务,至此服务已经启动完成,接下来就是在/home/dockerdata/seata/seata-server目录中修改对应的配置(设置开机自启和关键配置挂载到本地目录方便修改配置)
docker run -d --restart always --name seata-server -p 8091:8091 -v /home/dockerdata/seata/seata-server:/seata-server -e SEATA_IP=172.168.1.35 -e SEATA_PORT=8091 seataio/seata-server:1.2.0
docker run -d --restart always --name seata1.3.0 -p 8091:8091 -v /home/dockerdata/seata1.3.0/seata-server:/seata-server -e SEATA_IP=172.168.1.35 -e SEATA_PORT=8091 seataio/seata-server:1.3.0
docker run -d --restart always --name seata1.4.2 -p 8091:8091 -v /home/dockerdata/seata1.4.2/seata-server:/seata-server -e SEATA_IP=172.168.1.35 -e SEATA_PORT=8091 seataio/seata-server:1.4.2
7、切换到seata配置目录
cd /home/dockerdata/seata/seata-server/resources
cd /home/dockerdata/seata1.3.0/seata-server/resources
cd /home/dockerdata/seata1.4.2/seata-server/resources
8、修改registry.conf文件,修为nacos启用方式,绿色字体为修改的关键地方
registry { # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa type = "nacos" nacos { application = "seata-server" serverAddr = "172.168.1.35:8848" namespace = "89f54c6f-3b21-46a4-bd1b-242ae159c12e" cluster = "default" username = "" password = "" } eureka { serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } redis { serverAddr = "localhost:6379" db = 0 password = "" cluster = "default" timeout = 0 } zk { cluster = "default" serverAddr = "127.0.0.1:2181" sessionTimeout = 6000 connectTimeout = 2000 username = "" password = "" } consul { cluster = "default" serverAddr = "127.0.0.1:8500" } etcd3 { cluster = "default" serverAddr = "http://localhost:2379" } sofa { serverAddr = "127.0.0.1:9603" application = "default" region = "DEFAULT_ZONE" datacenter = "DefaultDataCenter" cluster = "default" group = "SEATA_GROUP" addressWaitTime = "3000" } file { name = "file.conf" } } config { # file、nacos 、apollo、zk、consul、etcd3 type = "file" nacos { serverAddr = "172.168.1.35:8848" namespace = "89f54c6f-3b21-46a4-bd1b-242ae159c12e" group = "DEFAULT_GROUP" username = "" password = "" } consul { serverAddr = "127.0.0.1:8500" } apollo { appId = "seata-server" apolloMeta = "http://192.168.1.204:8801" namespace = "application" } zk { serverAddr = "127.0.0.1:2181" sessionTimeout = 6000 connectTimeout = 2000 username = "" password = "" } etcd3 { serverAddr = "http://localhost:2379" } file { name = "file.conf" } }
项目中的库需要执行,sql文件路径:https://github.com/seata/seata/tree/develop/script/client
seata服务 需要sql https://github.com/seata/seata/tree/develop/script/server
不用的模式执行不同的脚本
建议把sql中的lock_table表中的table_name字段长度改成64,不然某些表名太长会导致异常
具体的注意点查看/home/dockerdata/seata/resources/README-zh.md
9、修改file.conf存储方式为mysql
store { ## store mode: file、db mode = "db" ## file store property file { ## store location dir dir = "sessionStore" # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions maxBranchSessionSize = 16384 # globe session size , if exceeded throws exceptions maxGlobalSessionSize = 512 # file buffer size , if exceeded allocate new buffer fileWriteBufferCacheSize = 16384 # when recover batch read size sessionReloadReadSize = 100 # async, sync flushDiskMode = async } ## database store property db { ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc. datasource = "druid" ## mysql/oracle/postgresql/h2/oceanbase etc. dbType = "mysql" driverClassName = "com.mysql.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai" user = "root" password = "root" minConn = 5 maxConn = 30 globalTable = "global_table" branchTable = "branch_table" lockTable = "lock_table" queryLimit = 100 maxWait = 5000 } }
10、重启服务
docker restart seata-server
docker logs seata-server #查看启动日志
11、可以登录nacos查看服务列表,就会发现seata-server已经注册上来了
分享一个淘宝、京东、拼多多、饿了么、美团、抖音等等买东西后真实返钱小技巧,
打车、外卖领券,充值话费95折好像也可以
使用教程用微信扫下方二维码查看详细说明
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步