1.安装
[root@ls_t3rdypvp local]# tar -zxvf seata-server-1.4.2.tar.gz
从官网下载相关的配置文件,我这里是用nacos做注册中心和配置中心
https://github.com/seata/seata/tree/develop/script
先将nacos-config.sh 转换为unix格式,用nodepad打开该文件
将config.txt 上传到/usr/local/seata 目录,把nacos-config.py 和 nacos-config.sh 上传到/usr/local/seata/config 目录
[root@ls_t3rdypvp seata]# ll
total 40
drwxr-xr-x 2 root root 4096 Sep 2 10:50 bin
drwxr-xr-x 4 502 games 4096 Sep 2 10:50 conf
-rw-r--r-- 1 root root 3548 Sep 2 11:14 config.txt
drwxr-xr-x 3 502 games 12288 Sep 2 10:50 lib
-rw-r--r-- 1 502 games 11365 May 13 2019 LICENSE
drwxr-xr-x 2 502 games 4096 Apr 25 16:01 logs
2.修改配置文件
修改registry.conf ,将 注册中心和配置中心换为nacos
[root@ls_t3rdypvp conf]# vim registry.conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "本机ip:8848"
group = "SEATA_GROUP"
namespace = ""
cluster = "default"
username = "nacos"
password = "nacos"
}
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"
aclToken = ""
}
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 = "本机ip:8848"
namespace = ""
group = "SEATA_GROUP"
username = "nacos"
password = "nacos"
dataId = "seataServer.properties"
}
consul {
serverAddr = "127.0.0.1:8500"
aclToken = ""
}
apollo {
appId = "seata-server"
## apolloConfigService will cover apolloMeta
apolloMeta = "http://192.168.1.204:8801"
apolloConfigService = "http://192.168.1.204:8080"
namespace = "application"
apolloAccesskeySecret = ""
cluster = "seata"
}
zk {
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
username = ""
password = ""
nodePath = "/seata/seata.properties"
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}
3.启动
初始化nacos 的配置,启动
[root@ls_t3rdypvp conf]# sh nacos-config.sh 本机Ip
[root@ls_t3rdypvp bin]# sh seata-server.sh -p 8091
4. systemd 管理seata
编辑seata-server.sh文件,在文件末尾添加2行指令
[root@ls_T3RDyPvP bin]# vim seata-server.sh
#!/bin/bash
sh /usr/local/seata/bin/seata-server.sh -p 8091
创建service
vim /lib/systemd/system/seata-server.service
[Unit]
Description=seata-server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/local/seata/bin/seata-server.sh
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动服务
systemctl enable seata-server.service
systemctl daemon-reload
systemctl start seata-server.service
systemctl status seata-server.service
其他指令
systemctl stop seata-server.service
systemctl restart seata-server.service
systemctl reset-failed seata-server.service