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
相关推荐
CodexDave1 小时前
数据库连接池耗尽:排查顺序与三层兜底
服务器·前端·数据库·git·云原生·容器·kubernetes
Zhu7584 小时前
在k8s部署alist 3.62.0
云原生·容器·kubernetes
阿里云云原生18 小时前
阿里云 Agent Native Cloud:让智能体成为企业原生的能力
云原生·agent
小码哥哥18 小时前
云原生时代的企业AI知识库:从云生态融合到多云知识治理
人工智能·云原生
IT小辉同学21 小时前
# Milvus v3.0-beta docker-compose 启动失败完整排错教程
docker·eureka·milvus
人间凡尔赛1 天前
Post-Kubernetes 时代:2026 云原生架构从 Cloud Native 到 AI Native 的范式跃迁
云原生·架构·kubernetes
AOwhisky1 天前
Python 学习笔记(第十一期)——运维自动化(上·后篇):进程级监控与子进程管理——psutil进阶
运维·开发语言·python·学习·云原生·运维开发
tryxr2 天前
Spring Cloud eureka
spring·spring cloud·eureka
L-影2 天前
单体与微服务区别
微服务·云原生·架构
Geek-Chow2 天前
Kubernetes HPA Behavior When Deployment Is Scaled to 0
云原生·容器·kubernetes