Prometheus install
wget https://github.com/prometheus/prometheus/releases/download/v2.36.2/prometheus-2.36.2.linux-amd64.tar.gz
tar -xf prometheus-2.36.2.linux-amd64.tar.gz
mv prometheus-2.36.2.linux-amd64 /usr/local/
ln -s /usr/local/prometheus-2.36.2.linux-amd64/ /usr/local/prometheus
useradd -s /sbin/nologin -M prometheus
mkdir /data/prometheus -p
chown -R prometheus:prometheus /usr/local/prometheus/
chown -R prometheus:prometheus /data/prometheus/
vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus
Grafana install
wget https://dl.grafana.com/oss/release/grafana-6.4.2.linux-amd64.tar.gz
tar -zxvf grafana-6.4.2.linux-amd64.tar.gz
mv grafana-6.4.2 /usr/local/
ln -s /usr/local/grafana-6.4.2/ /usr/local/grafana
useradd -s /sbin/nologin -M grafana
mkdir /data/grafana
chown -R grafana:grafana /usr/local/grafana/
chown -R grafana:grafana /data/grafana/
vi /usr/local/grafana/conf/defaults.ini
data = /data/grafana/data
logs = /data/grafana/log
plugins = /data/grafana/plugins
provisioning = /data/grafana/conf/provisioning
vim /etc/systemd/system/grafana-server.service
[Unit]
Description=Grafana
After=network.target
[Service]
User=grafana
Group=grafana
Type=notify
ExecStart=/usr/local/grafana/bin/grafana-server -homepath /usr/local/grafana
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl start grafana-server
systemctl status grafana-server
systemctl enable grafana-server
node exporter install
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -xf node_exporter-0.18.1.linux-amd64.tar.gz
新建一个目录专门安装各种exporter
mkdir -p /usr/local/prometheus_exporter
mv node_exporter-0.18.1.linux-amd64 /usr/local/prometheus_exporter/
cd /usr/local/prometheus_exporter/
ln -s node_exporter-0.18.1.linux-amd64/ node_exporter
nohup /usr/local/prometheus_exporter/node_exporter/node_exporter >/dev/null 2>&1 &
nohup /usr/local/prometheus_exporter/node_exporter/node_exporter >/dev/null 2>&1 &
vi /usr/local/prometheus/prometheus.yml
scrape_configs:
- job_name: 'prometheus'
static_configs:- targets: ['localhost:9090']
采集node exporter监控数据
- job_name: 'node'
static_configs:- targets: ['localhost:9100']
systemctl restart prometheus



网友评论