Linux安装nacos和seata

1.Linux安装nacos文档

https://blog.csdn.net/qq_46112274/article/details/123117926

2.单机启动时修改启动脚本

脚本文件路径:nacos/bin/startup.sh
找到MODE参数,修改为standalone


image.png

3.Linux安装seata文档

https://blog.csdn.net/EDT777/article/details/114706278

4.seata安装完,创建启动和停止的脚本

启动脚本:start.sh
启动命令:sh start.sh
脚本中的seata路径需要自己核对修改一下
我特意在网上找了各个命令的作用,加了很多注释

#!/bin/sh
export LANG="en_US.UTF-8"
cd /usr/local/seata/bin
runMessage=`ps aux | grep \`cat pidfile.txt\``
projectStartCommand="sh seata-server.sh"
if [[ $runMessage == *$projectStartCommand* ]]
then
    echo "Application has starting ,restarting..."
    kill -9 `cat pidfile.txt`
    # -h: 注册到注册中心的ip
    # -p: Server rpc 监听端口(默认8091)
    # -n: Server node,多个Server时,需区分各自节点,用于生成不同区间的transactionId,以免冲突
    # >seata.log 作业的所有输出被重定向到seata.log的文件中,如果是">>seata.log"表示将输出以追加的方式重定向到seata.log中
    # 2>1 将错误信息合并到标准信息中打印
    # & 后台执行
    # echo $! > pidfile.txt 把进程号打印到pidfile.txt中
    nohup sh seata-server.sh -h 127.0.0.1 -p 8091 -n 1  >seata.log 2>1 & echo $! > pidfile.txt
else
    echo "Application has stopped ,starting..."
    nohup sh seata-server.sh -h 127.0.0.1 -p 8091 -n 1  >seata.log 2>1 & echo $! > pidfile.txt
fi

停止脚本:stop.sh
停止命令:sh stop.sh
脚本中的seata路径需要自己核对修改一下

#!/bin/sh
cd /usr/local/seata/bin
PID=$(cat pidfile.txt)
if [ ${PID} ]; 
then
    echo 'Application is stpping...'
    echo kill $PID DONE
    kill $PID
else
    echo 'Application is already stopped...'
fi

你可能感兴趣的:(Linux安装nacos和seata)