打開終端或命令提示符,進(jìn)入您希望安裝Node Exporter的目錄。
-
在終端中運(yùn)行以下命令,使用curl下載Node Exporter的壓縮包:
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.2.0/node_exporter-1.2.0.linux-amd64.tar.gz這將下載Node Exporter v1.2.0的Linux 64位版本壓縮包。請(qǐng)注意,您可以根據(jù)需要選擇不同的版本和操作系統(tǒng)架構(gòu)。
-
解壓縮下載的壓縮包。運(yùn)行以下命令:
tar xvfz node_exporter-1.2.0.linux-amd64.tar.gz這將解壓縮Node Exporter到當(dāng)前目錄。
-
將解壓后的Node Exporter移動(dòng)到/opt目錄。運(yùn)行以下命令:
sudo mv node_exporter-1.2.0.linux-amd64 /opt/node_exporter這將把Node Exporter移動(dòng)到/opt目錄下的node_exporter子目錄中。
-
創(chuàng)建一個(gè)用于Node Exporter的systemd服務(wù)單元文件。在終端中使用root權(quán)限打開一個(gè)文本編輯器,比如vi或nano:
sudo vi /etc/systemd/system/node_exporter.service -
在打開的文件中,輸入以下內(nèi)容:
[Unit] Description=Node Exporter Documentation=https://github.com/prometheus/node_exporter After=network.target [Service] User=node_exporter Group=node_exporter Type=simple ExecStart=/opt/node_exporter/node_exporter [Install] WantedBy=default.target注意,ExecStart行中的路徑應(yīng)為Node Exporter可執(zhí)行文件在/opt目錄下的路徑。
保存并關(guān)閉文件。在vi編輯器中,按下Esc鍵,然后輸入
:wq并按下回車鍵。-
創(chuàng)建一個(gè)名為
node_exporter的系統(tǒng)用戶。運(yùn)行以下命令:sudo useradd --no-create-home --shell /bin/false node_exporter這將創(chuàng)建一個(gè)名為
node_exporter的系統(tǒng)用戶,該用戶無法登錄系統(tǒng)。 -
重新加載systemd配置:
sudo systemctl daemon-reload -
啟用Node Exporter服務(wù),使其在系統(tǒng)啟動(dòng)時(shí)自動(dòng)啟動(dòng):
sudo systemctl enable node_exporter -
啟動(dòng)Node Exporter服務(wù):
sudo systemctl start node_exporter您可以使用以下命令檢查服務(wù)狀態(tài):
sudo systemctl status node_exporter
安裝node_exporter
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。