yum update -y
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/sysconfig/selinux
# reboot
# Execute the following command to download
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
# Add the following configuration to the file
global:
scrape_interval: 10s
scrape_configs:- job_name:'prometheus_master'
scrape_interval: 5s
static_configs:- targets:['localhost:9090']
# Change file ownership
chown prometheus:prometheus /etc/prometheus/prometheus.yml
vim /etc/systemd/system/prometheus.service
# Copy the following to the file
[ 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
# start up
systemctl start prometheus
# Check status
systemctl status prometheus
firewall-cmd --zone=public--add-port=9090/tcp --permanent
systemctl reload firewalld
http://Server-IP:9090/graph
# download
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
# For node_exporter create user
useradd -rs /bin/false nodeusr
# Move binary files
mv node_exporter-0.17.0.linux-amd64/node_exporter /usr/local/bin/
vim /etc/systemd/system/node_exporter.service
# Add the following to the file
[ 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
# Add the following configuration under scrape configuration
- 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