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
相关推荐
张忠琳1 天前
【SR-IOV cni】(Part 4) SR-IOV Network Device Plugin 3.11.0 — 超深度架构分析
网络·云原生·kubernetes·cni·sriov
木雷坞1 天前
6月 Docker 国内镜像源配置:daemon.json、/v2/ 连通性和 pull 验证
docker·eureka·json
Henry-SAP1 天前
SAP(ERP) BOM变更实时同步MRP方案
数据库·云原生
量子物理学1 天前
ubuntu安装docker
ubuntu·docker·eureka
devilnumber1 天前
Kubernetes(K8s)重要知识点复习与记录
云原生·容器·kubernetes
IT策士1 天前
第 47 篇 k8s之生产级考量:高可用、备份与升级
云原生·容器·kubernetes
小义_1 天前
【Linux 1】
linux·运维·云原生·红帽
IT策士1 天前
第48篇 k8s之常见问题排查与排错指南
云原生·容器·kubernetes
努力搬砖的咸鱼1 天前
容器编排底层原理:Kubernetes 网络模型与 CNI 插件
网络·微服务·云原生·容器·架构·kubernetes
Plastic garden1 天前
K8s介绍(2)POD架构
云原生·容器·kubernetes