一、下载并安装

github官网地址:

https://github.com/seata/seata/releases/download/v0.9.0/seata-server-0.9.0.tar.gz

因下载比较慢,我将下载好的资源上传了CSDN:https://download.csdn.net/download/JackRen_Developer/11982282

下载好后上传ubuntu自己的路径:

这是我自己的路经

二、导入配置

本文使用nacos作为配置中心和服务发现,file、apollo、redis、zk、consul等也可以举一反三。

我们这里用默认的导入先让seata-server跑起来,过后对着file.conf和java程序启动后的报错调整,重新导入即可。

vim /root/work/ziyun56.seata/seata-server-0.9.0/conf/nacos-config.txt
transport.type=TCPtransport.server=NIOtransport.heartbeat=truetransport.thread-factory.boss-thread-prefix=NettyBosstransport.thread-factory.worker-thread-prefix=NettyServerNIOWorkertransport.thread-factory.server-executor-thread-prefix=NettyServerBizHandlertransport.thread-factory.share-boss-worker=falsetransport.thread-factory.client-selector-thread-prefix=NettyClientSelectortransport.thread-factory.client-selector-thread-size=1transport.thread-factory.client-worker-thread-prefix=NettyClientWorkerThreadtransport.thread-factory.boss-thread-size=1transport.thread-factory.worker-thread-size=8transport.shutdown.wait=3service.vgroup_mapping.my_test_tx_group=defaultservice.vgroup_mapping.user-web-fescar-service-group=defaultservice.vgroup_mapping.user-fescar-service-group=defaultservice.vgroup_mapping.order-fescar-service-group=defaultservice.vgroup_mapping.business-service-fescar-service-group=defaultservice.vgroup_mapping.account-service-fescar-service-group=defaultservice.vgroup_mapping.storage-service-fescar-service-group=defaultservice.vgroup_mapping.order-service-fescar-service-group=defaultservice.default.grouplist=172.16.10.122:8091service.enableDegrade=falseservice.disable=falseservice.max.commit.retry.timeout=-1service.max.rollback.retry.timeout=-1client.async.commit.buffer.limit=10000client.lock.retry.internal=10client.lock.retry.times=30client.lock.retry.policy.branch-rollback-on-conflict=trueclient.table.meta.check.enable=trueclient.report.retry.count=5client.tm.commit.retry.count=1client.tm.rollback.retry.count=1store.mode=filestore.file.dir=file_store/datastore.file.max-branch-session-size=16384store.file.max-global-session-size=512store.file.file-write-buffer-cache-size=16384store.file.flush-disk-mode=asyncstore.file.session.reload.read_size=100store.db.datasource=dbcpstore.db.db-type=mysqlstore.db.driver-class-name=com.mysql.jdbc.Driverstore.db.url=jdbc:mysql://172.16.10.105:3307/seata?useUnicode=truestore.db.user=rootstore.db.password=rootstore.db.min-conn=1store.db.max-conn=3store.db.global.table=global_tablestore.db.branch.table=branch_tablestore.db.query-limit=100store.db.lock-table=lock_tablerecovery.committing-retry-period=1000recovery.asyn-committing-retry-period=1000recovery.rollbacking-retry-period=1000recovery.timeout-retry-period=1000transaction.undo.data.validation=truetransaction.undo.log.serialization=jacksontransaction.undo.log.save.days=7transaction.undo.log.delete.period=86400000transaction.undo.log.table=undo_logtransport.serialization=seatatransport.compressor=nonemetrics.enabled=falsemetrics.registry-type=compactmetrics.exporter-list=prometheusmetrics.exporter-prometheus-port=9898support.spring.datasource.autoproxy=false
vim /root/work/ziyun56.seata/seata-server-0.9.0/conf/nacos-config.sh
for line in $(cat nacos-config.txt)改为for line in $(cat /root/work/ziyun56.seata/seata-server-0.9.0/conf/nacos-config.txt)

导入配置到nacos。

格式为:

sh nacos-config.sh $Nacos-Server-IP

因为nacos-config.sh脚本中已经把8848端口写死,如果你的nacos-server不是8848端口,请修改nacos-config.sh

bash /root/work/ziyun56.seata/seata-server-0.9.0/conf/nacos-config.sh 172.16.10.121

其中172.16.10.121是nacos的ip

脚本执行最后输出 “init nacos config finished, please start seata-server.” 说明推送配置成功。若想进一步确认可登陆Nacos控制台->配置列表->筛选查询Group为FESCAR_GROUP的配置项。

三、启动seata-server(事务协调器)

修改日志目录(非必须)

vim /root/work/ziyun56.seata/seata-server-0.9.0/conf/logback.xml

修改为:

<!--<property name="LOG_HOME" value="${user.home}/logs/seata"/>-->    <property name="LOG_HOME" value="/root/work/ziyun56.seata/seata-server-0.9.0/logs"/>

配置修改:

vim /root/work/ziyun56.seata/seata-server-0.9.0/conf/registry.conf
registry {  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa  type = "nacos"  nacos {    serverAddr = "172.16.10.121"    namespace = "public"    cluster = "default"  }  eureka {    serviceUrl = "http://localhost:8761/eureka"    application = "default"    weight = "1"  }  redis {    serverAddr = "localhost:6379"    db = "0"  }  zk {    cluster = "default"    serverAddr = "127.0.0.1:2181"    session.timeout = 6000    connect.timeout = 2000  }  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 = "nacos"  nacos {    serverAddr = "172.16.10.121"    namespace = "public"    cluster = "default"  }  consul {    serverAddr = "127.0.0.1:8500"  }  apollo {    app.id = "seata-server"    apollo.meta = "http://192.168.1.204:8801"  }  zk {    serverAddr = "127.0.0.1:2181"    session.timeout = 6000    connect.timeout = 2000  }  etcd3 {    serverAddr = "http://localhost:2379"  }  file {    name = "file.conf"  }}

其中修改的:

只需要修改这两处,其他的地方不需要动

注:serverAddr不要填端口号   public为小写

启动格式sh seata-server.sh $LISTEN_PORT $PATH_FOR_PERSISTENT_DATA $IP(此参数可选)

$IP参数 用于多IP环境下指定 Fescar-Server 注册服务的IP    虽然是可选,但还是要填,之前我偷懒没填,一大堆虚拟ip各种乱定位。

命令启动

sh /root/work/ziyun56.seata/seata-server-0.9.0bin/seata-server.sh -p 8091 -h 172.16.10.121

方便启动,定义服务,先写个启动脚本:

#!/bin/bashexport JAVA_HOME=/root/work/jdk1.8.0_92/sh /root/work/ziyun56.seata/seata-server-0.9.0/bin/seata-server.sh -p 8091 -h 172.16.10.121

第一个命令是我ubuntu没有安装jdk环境,所以我下载了一个传上去了

然后编辑服务:

vim /lib/systemd/system/seata-server.service
[Unit]Description=seata-serverAfter=syslog.target network.target remote-fs.target nss-lookup.target[Service]Type=simpleExecStart=/root/work/ziyun56.seata/seata-server-0.9.0/startup.shRestart=alwaysPrivateTmp=true[Install]WantedBy=multi-user.target

赋予权限

chmod 777 /root/work/ziyun56.seata/seata-server-0.9.0r/startup.shchmod 777 /lib/systemd/system/seata-server.service

启用服务

systemctl enable seata-server.servicesystemctl daemon-reload

运行

systemctl start seata-server.service

查看状态

systemctl status seata-server.service

查看进程

ps -ef|grep seata-server

运行成功后可在Nacos控制台的 服务列表 看到 服务名serverAddr的条目

最后修改日期: 2023年12月24日