ubuntu22.04开机自启动Eureka服务

ubuntu22.04开机自启动Eureka服务

1、创建启动脚本eurekaService.sh

shell 复制代码
#我们把启动脚本放在/usr/software目录下
cd /usr/software
vim eurekaService.sh

eurekaService.sh内容为

shell 复制代码
#!/bin/sh
# this is a eurekaService shell to startup at the mechian power on.

echo "eurekaServer-0.0.1-SNAPSHOT.jar service start loading..." 
nohup java -jar /usr/software/eurekaServer-0.0.1-SNAPSHOT.jar > /usr/software/log.txt 2>&1 &
echo "eurekaService loads successful"

2、赋予可执行权限

shell 复制代码
chmod 777 eurekaService.sh

3、新建要启动的Eureka服务文件

shell 复制代码
#新建要启动的服务文件
vim /etc/systemd/system/eureka.service

eureka.service内容为

shell 复制代码
[Unit]
Description=this is eurekaService 
After=network.target
[Service]
Type=forking
ExecStart=/usr/software/eurekaService.sh  #指定上面创建的脚步文件路径
[Install]
WantedBy=multi-user.target  #多用户

4、启动Eureka服务

shell 复制代码
#让系统获取到你刚自定义的service文件并设置开机启动
systemctl daemon-reload
systemctl start eureka.service

systemctl enable eureka.service

#查看日志
systemctl status eureka.service
相关推荐
zz-zjx15 小时前
Kubernetes 的部署方式 (二)通过 kubeasz部署单机版1.34.1
云原生·容器·kubernetes
是小崔啊16 小时前
叩丁狼k8s - 组件篇
云原生·容器·kubernetes
zz-zjx18 小时前
Kubernetes 的部署方式 (一)通过 Minikube 部署
云原生·容器·kubernetes
眠りたいです21 小时前
Docker:Docker image常用命令使用及实操
运维·docker·容器·eureka·镜像
passerma1 天前
云原生构建Cloud Native Build构建项目配置 demo
云原生
2501_940198691 天前
【前瞻创想】Kurator分布式云原生平台:从架构解析到企业级多云集群管理实战指南
分布式·云原生·架构
Justin_191 天前
K8s常见问题
云原生·容器·kubernetes
川211 天前
Nacos和ZooKeeper的选型
分布式·zookeeper·云原生
周杰伦_Jay1 天前
【探索实战】从0到1精通Kurator:分布式云原生平台实战教程
分布式·云原生·kurator
2501_940198692 天前
【前瞻创想】Kurator·云原生实战派:打造下一代分布式云原生基础设施
分布式·云原生