Seata 环境搭建( 二 )

script -> config-center -> nacos -> nacos-config.sh 。执行nacos-config.sh脚本:
sh nacos-config.sh -h 127.0.0.1 -p 8848 -g SEATA_GROUP -t xxxx -u username -w password参数详解:

  • -h nacos服务IP
  • -p nacos服务端口
  • -u nacos登录名
  • -w nacos登录密码
  • -g nacos 配置的分组名称,默认设置SEATA_GROUP
  • -t 上一步配置的命名空间ID

Seata 环境搭建

文章插图
执行脚本之后,输出以下脚本:
Set server.maxCommitRetryTimeout=-1 successfullySet server.maxRollbackRetryTimeout=-1 successfullySet server.rollbackRetryTimeoutUnlockEnable=false successfullySet server.distributedLockExpireTime=10000 successfullySet server.xaerNotaRetryTimeout=60000 successfullySet server.session.branchAsyncQueueSize=5000 successfullySet server.session.enableBranchAsyncRemove=false successfullySet server.enableParallelRequestHandle=false successfullySet metrics.enabled=false successfullySet metrics.registryType=compact successfullySet metrics.exporterList=prometheus successfullySet metrics.exporterPrometheusPort=9898 successfully再去nacos控制台查看配置:
Seata 环境搭建

文章插图
说明配置上传成功 。上传不成功,大部分原因是配置没有配置成功,比如命名空间ID没配置正确 。
4.修改 appplication.yml找到appplication.yml文件,路径为:seata -> conf -> application.yml,以下三个小节分别配置storeconfigregistry:
Seata 环境搭建

文章插图
4.1 seata.storeseata.store配置seata的存储,修改store.mode="db":
seata:store:# support: file 、 db 、 redismode: db修改数据库连接,将 seata -> conf -> application.example.yml中附带额外配置,将其db相关配置复制至application.yml,修改store.db相关属性 。数据库是步骤一配置的数据库:
seata:store:# support: file 、 db 、 redismode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://xxxxx:3306/seata?rewriteBatchedStatements=trueuser: xxxxpassword: xxxmin-conn: 5max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 100max-wait: 50004.2 seata.configseata.config是配置nacos配置中心相关的配置 。将seata.config.type修改成nacos
seata:config:# support: nacos, consul, apollo, zk, etcd3type: nacos然后添加seata.config.nacos相关的配置:
seata:config:# support: nacos, consul, apollo, zk, etcd3type: nacosnacos:server-addr: 127.0.0.1:8848group : "SEATA_GROUP"namespace: "xxxxx"username: "xxx"password: "xxx"
其中namespace是步骤3中的命名空间ID
4.3 seata.registryseata.registry是配置注册中心相关字段,将seata服务作为一个微服务注册到注册中心 。将registry.type改成nacos,配置如下:
seata:registry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacosnacos:application: "seata-server"serverAddr: 127.0.0.1:8848group: "SEATA_GROUP"namespace: "xxxxxx"username: "xxxx"password: "xxx"

经验总结扩展阅读