您当前的位置: 首页 > 

杨林伟

暂无认证

  • 2浏览

    0关注

    3337博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

systemctl启动prometheus+grafana环境

杨林伟 发布时间:2022-04-21 16:13:05 ,浏览量:2

01 配置文件

/usr/lib/systemd/system目录新增4个配置文件,分别为:

pushgateway.service文件,内容如下:

[Unit]
Description=Prometheus Push Gateway
After=network.target

[Service]
ExecStart=/opt/prometheus_env/pushgateway-1.4.2.linux-amd64/pushgateway

User=root
[Install]
WantedBy=multi-user.target

node_exporter.service文件,内容如下:

[Unit]
Description=Prometheus Node Exporter
After=network.target

[Service]
ExecStart=/opt/prometheus_env/node_exporter-1.3.1.linux-amd64/node_exporter

User=root
[Install]
WantedBy=multi-user.target

prometheus.service文件,内容如下:

[Unit]
Description=Prometheus Service
After=network.target

[Service]
ExecStart=/opt/prometheus_env/prometheus-2.34.0.linux-amd64/prometheus \
--config.file=/opt/prometheus_env/prometheus-2.34.0.linux-amd64/prometheus.yml \
--web.read-timeout=5m  \
--web.max-connections=10 \
--storage.tsdb.retention=15d \
--storage.tsdb.path=/prometheus/data \
--query.max-concurrency=20 \
--query.timeout=2m

User=root
[Install]
WantedBy=multi-user.target

grafana.service文件,内容如下:

[Unit]
Description=Grafana
After=network.target

[Service]
ExecStart=/opt/prometheus_env/grafana-8.4.7/bin/grafana-server \
 --config=/opt/prometheus_env/grafana-8.4.7/conf/defaults.ini \
 --homepath=/opt/prometheus_env/grafana-8.4.7

[Install]
WantedBy=multi-user.target

02 systemctl命令

重载配置:

systemctl daemon-reload

开启服务:

systemctl start pushgateway
systemctl start node_exporter
systemctl start prometheus
systemctl start grafana

设置开机启动:

systemctl enable pushgateway
systemctl enable node_exporter
systemctl enable prometheus
systemctl enable grafana

查看服务状态:

systemctl status pushgateway
03 其它命令

开启端口,能被浏览器访问(例如开启:3000)

firewall-cmd --zone=public --add-port=3000/tcp --permanent

重启防火墙:

firewall-cmd --reload
关注
打赏
1662376985
查看更多评论
立即登录/注册

微信扫码登录

0.2836s