seata2.0 下载安装部署,使用nacos为配置中心、注册中心

目录

1、nacos新建配置

2、下载seata安装包​​​​​​​

3、修改seata配置文件

4、启动seata server

1、nacos新建配置

请确保后台已经启动 Nacos 服务。

首先你需要在nacos新建配置,此处dataId为seataServer.properties

seata2.0 下载安装部署,使用nacos为配置中心、注册中心_第1张图片​​​​​​​配置内容参考(主要是中文备注的部分修改)

​​​​​​​
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableTmClientBatchSendRequest=false
transport.enableRmClientBatchSendRequest=true
transport.enableTcServerBatchSendResponse=false
transport.rpcRmRequestTimeout=30000
transport.rpcTmRequestTimeout=30000
transport.rpcTcRequestTimeout=30000
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
transport.serialization=seata
transport.compressor=none



# 配置事务分组,客户端的配置要与此service.vgroup_mapping的后缀对应
#(例如:客户端bootstrap.yml配置属性spring.cloud.alibaba.seata.tx-service-group=default_tx_group)

service.vgroupMapping.default_tx_group=default
#这里的地址需要配置成seata所在服务器的地址
service.default.grouplist=127.0.0.1:8091
service.enableDegrade=false
service.disableGlobalTransaction=false


 
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h 
tcc.contextJsonParserType=fastjson
log.exceptionRate=100


#此处对于数据存储使用的是数据库存储
store.mode=db  

#当store.mode=db时,配置以下数据库的连接信息
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver

#数据库的表创建在seata/script/server/db/mysql.sql文件
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=123456

store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.distributedLockTable=distributed_lock
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000

 
#当store.mode=redis时,配置以下数据库的连接信息
#store.redis.mode=single
#store.redis.type=pipeline
#store.redis.single.host=127.0.0.1
#store.redis.single.port=6379
#store.redis.sentinel.masterName=
#store.redis.sentinel.sentinelHosts=
#store.redis.sentinel.sentinelPassword=
#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
server.distributedLockExpireTime=10000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=true
server.enableParallelHandleBranch=false

  
 
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

2、​​​​​​​​​​​​​​下载seata安装包

seata2.0 下载安装部署,使用nacos为配置中心、注册中心_第2张图片

3、修改seata配置文件

配置文件seata/conf/application.yml,加入对应的配置中心

(主要是seata部分,用中文备注的配置)

#  Copyright 1999-2019 Seata.io Group.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

server:
  port: 7091

spring:
  application:
    name: seata-server

logging:
  config: classpath:logback-spring.xml
  file:
    path: ${log.home:${user.home}/logs/seata}
  extend:
    logstash-appender:
      destination: 127.0.0.1:4560
    kafka-appender:
      bootstrap-servers: 127.0.0.1:9092
      topic: logback_to_logstash

console:
  user:
    username: seata
    password: seata
seata:
  config:
    # support: nacos, consul, apollo, zk, etcd3
    # 使用nacos作为配置中心
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
     
# 命名空间
      namespace: public
 
    # Group
      group: SEATA_GROUP
      username:
      password:
      context-path:

      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key:
      #secret-key:

      # 配置管理中的dataId(首先你需要在nacos新建配置,此处dataId为seataServer.properties,配置内容参考上一节)
      data-id: seataServer.properties
  registry:
    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    # 使用nacos作为注册中心
    type: nacos
    nacos:
      # 注册到nacos的服务名
      application: seata-server
      server-addr: 127.0.0.1:8848
      # 分组名称
      group: SEATA_GROUP
      # 命名空间
      namespace: public
      cluster: default
      username:
      password:
      context-path:
      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key:
      #secret-key:
  # 因为在配置中心中已配置了store部分,所以此处不必再配置    
  # store:
    # support: file 、 db 、 redis 、 raft
    # mode: db
  #  server:
  #    service-port: 8091 #If not configured, the default is '${server.port} + 1000'
  security:
    secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
    tokenValidityInMilliseconds: 1800000
    ignore:
      urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/metadata/v1/**
 

4、启动seata server

切换到seata的bin目录,输入命令:./seata-server.sh

seata2.0 下载安装部署,使用nacos为配置中心、注册中心_第3张图片

 可以看到提示已经启动成功,也可以到提示的日志目录查看日志文件,也可以输入http://localhost:7091

seata2.0 下载安装部署,使用nacos为配置中心、注册中心_第4张图片

另外在nacos也可以看到seata-server注册成功 

seata2.0 下载安装部署,使用nacos为配置中心、注册中心_第5张图片

你可能感兴趣的:(java,开发语言,seata)