yum update -y
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/sysconfig/selinux
# reboot
# 次のコマンドを実行してダウンロードします
wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz
useradd --no-create-home --shell /bin/false prometheus
mkdir /etc/prometheus
mkdir /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus
chown prometheus:prometheus /var/lib/prometheus
tar -xvzf prometheus-2.8.1.linux-amd64.tar.gz
mv prometheus-2.8.1.linux-amd64 prometheuspackage
cp prometheuspackage/prometheus /usr/local/bin/
cp prometheuspackage/promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
cp -r prometheuspackage/consoles /etc/prometheus
cp -r prometheuspackage/console_libraries /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus/consoles
chown -R prometheus:prometheus /etc/prometheus/console_libraries
vim /etc/prometheus/prometheus.yml
# 次の構成をファイルに追加します
global:
scrape_interval: 10s
scrape_configs:- job_name:'prometheus_master'
scrape_interval: 5s
static_configs:- targets:['localhost:9090']
# ファイルの所有権を変更する
chown prometheus:prometheus /etc/prometheus/prometheus.yml
vim /etc/systemd/system/prometheus.service
# 以下をファイルにコピーします
[ Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[ Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
- - config.file /etc/prometheus/prometheus.yml \
- - storage.tsdb.path /var/lib/prometheus/ \
- - web.console.templates=/etc/prometheus/consoles \
- - web.console.libraries=/etc/prometheus/console_libraries
[ Install]
WantedBy=multi-user.target
systemctl daemon-reload
# 起動
systemctl start prometheus
# ステータスを確認する
systemctl status prometheus
firewall-cmd --zone=public--add-port=9090/tcp --permanent
systemctl reload firewalld
http://Server-IP:9090/graph
# ダウンロード
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
tar -xvzf node_exporter-0.17.0.linux-amd64.tar.gz
# ノードの場合_エクスポータ作成ユーザー
useradd -rs /bin/false nodeusr
# バイナリファイルを移動する
mv node_exporter-0.17.0.linux-amd64/node_exporter /usr/local/bin/
vim /etc/systemd/system/node_exporter.service
# 以下をファイルに追加します
[ Unit]
Description=Node Exporter
After=network.target
[ Service]
User=nodeusr
Group=nodeusr
Type=simple
ExecStart=/usr/local/bin/node_exporter
[ Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter
firewall-cmd --zone=public--add-port=9100/tcp --permanent
systemctl restart firewalld
http://IP-Address:9100/metrics
vim /etc/prometheus/prometheus.yml
# スクレイプ構成の下に次の構成を追加します
- job_name:'node_exporter_centos'
scrape_interval: 5s
static_configs:- targets:['10.94.10.209:9100']
systemctl restart prometheus
http://Prometheus-Server-IP:9090/targets
Recommended Posts