1. 确保 linux 有 Nacos 正常启动,并知晓正确的端口 用户名 密码
- https://github.com/seata/seata.git 克隆 seata 项目到本地
- 在 Github 下载对应你项目 SpringCloudAlibaba 建议版本的 Seata,我的版本是 2.5.5,建议 Seata 版本 1.3.0
- 下载好后进入 seata/conf 配置目录,修改 file.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| ## transaction log store, only used in seata-server store { ## store mode: file、db、redis mode = "db" #如果单机:file 如果是集群:db 并在下方配置你的Mysql数据源
## 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)/HikariDataSource(hikari) etc. datasource = "druid" ## mysql/oracle/postgresql/h2/oceanbase etc. dbType = "mysql" driverClassName = "com.mysql.jdbc.Driver" url = "jdbc:mysql://sh-cynosdbmysql-grp-o5n8fbw2.sql.tencentcdb.com:20345/seata_server" user = "brath" password = "Lgq081538" minConn = 5 maxConn = 30 globalTable = "global_table" branchTable = "branch_table" lockTable = "lock_table" queryLimit = 100 maxWait = 5000 }
}
|
5. 修改 registry.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| registry { type = "nacos"
nacos { application = "seata-server" serverAddr = "nacosip+端口" group = "SEATA_GROUP" namespace = "命名空间" cluster = "default" username = "账号" password = "密码" } file { name = "file.conf" } }
config { type = "nacos"
nacos { serverAddr = "nacosip+端口" namespace = "命名空间" group = "SEATA_GROUP" username = "账号" password = "密码" } file { name = "file.conf" } }
|
6. 在克隆好的项目中找到 script/confing-center 找到 config.txt 文件
修改
修改数据源
1 2 3
| store.db.url=localhost:3306/seata_server?useUnicode=true&rewriteBatchedStatements=true store.db.user=**** store.db.password=****
|
进入 script\config-center\nacos
如果是 windows 系统请确保安装了 GIT 以及 GIT bash
点击 nacos-config.sh 会自动把 config.txt 配置文件,配置到你的 Nacos 客户端中指定命名空间的配置中心供你的 Seata 使用
7. 进入 Seata/bin
1
| sh seata-server.sh #启动seata服务
|
# 关于我
Brath 是一个热爱技术的 Java 程序猿,公众号「InterviewCoder」定期分享有趣有料的精品原创文章!
非常感谢各位人才能看到这里,原创不易,文章如果有帮助可以关注、点赞、分享或评论,这都是对我的莫大支持!