centos7開機自啟自己配置自啟檔案步驟和問題

2021-10-12 05:04:57 字數 819 閱讀 9586

systemd 預設從目錄/etc/systemd/system/讀取配置檔案。但是,裡面存放的大部分檔案都是符號鏈結,指向目錄/usr/lib/systemd/system/,真正的配置檔案存放在那個目錄。

1、進入/usr/lib/systemd/system/目錄下建立服務的自啟檔案(以prometheus為例)

cd /usr/lib/systemd/system/

vim prometheus.service

[unit]

description=prometheus

after=network.target

[service]

user=prometheus

type=******

restart=on-failure

execstart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data

execreload=/bin/kill -hup $mainpid

[install]

wantedby=multi-user.target

配置分為三部分「unit」、「service」、「install」,主要在service下配置服務的啟動資訊。

問題:配置好自啟服務配置檔案之後啟動失敗?

1、服務已經開啟了;

2、服務的埠被占用了。

解決方式:

1、關閉服務在開啟;

2、殺掉占用埠的程序在自啟。

Redis 在Centos7下配置開機自啟動

設定redis開機啟動需要如下幾個步驟 編寫配置指令碼 vim etc init.d redis bin sh redis init.d script conceived to work on linux systems as it does use of the proc filesystem.c...

Redis 在Centos7下配置開機自啟動

設定redis開機啟動需要如下幾個步驟 編寫配置指令碼 vim etc init.d redis bin sh redis init.d script conceived to work on linux systems as it does use of the proc filesystem.c...

CentOS 7 設定 Redis 開機自啟

在之前的文章 centos 7 配置 redis 我們已經學習了怎麼安裝配置 redis,不過在那篇文章中並沒有講如何設定 redis 開機自啟。故這次來補充一下 redis 開機自啟的內容。進入 redis 原始碼壓縮包,拷貝 redis 官方提供的啟動指令碼 cd root redis 4.0....