本帖最后由 vinny 于 2021-12-25 19:58 编辑
黑五买了一堆鸡,不把探针升个级? 记得论坛放过,最近又搭了一次,就当做个笔记 面板鸡先安装好docker,被监控的不用 grafana-把数据转换为图形 prometheus-带有时间坐标的数据库 node_exporter-把机器的数据上报
1.grafana安装面板鸡执行
- mkdir /data/grafana/storage
- chmod 777 /data/grafana/storage
- # 启动 grafana
- docker run -d -p 3000:3000 –name=grafana -v /data/grafana/storage:/var/lib/grafana grafana/grafana
复制代码
访问http://ip:3000/login,默认账号密码都是admin
2.node_exporter配置(被控鸡执行)
-
- #!/bin/bash
- wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
- tar xvf node_exporter-1.3.1.linux-amd64.tar.gz
- mv node_exporter-1.3.1.linux-amd64 /usr/local/bin/node_exporter
-
- groupadd prometheus
- useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
- mkdir /usr/local/prometheus
- chown prometheus.prometheus -R /usr/local/prometheus
-
- cat > /etc/systemd/system/node_exporter.service << EOF
- [Unit]
- Description=node_exporter
- Documentation=https://prometheus.io/
- After=network.target
- [Service]
- Type=simple
- User=prometheus
- ExecStart=/usr/local/bin/node_exporter/node_exporter –collector.processes –collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($|/)
- Restart=on-failure
- [Install]
- WantedBy=multi-user.target
- EOF
-
- systemctl daemon-reload
- systemctl restart node_exporter.service
- systemctl enable node_exporter.service
-
- systemctl start node_exporter.service
- systemctl status node_exporter
复制代码
执行后防火墙放行9100端口,访问 IP:9100,有输出就成功 3.prometheus安装面板鸡执行
-
- mkdir /data/prometheus
- vim prometheus.yml
-
- ————
- #配置文件
- global:
- scrape_interval: 60s
- evaluation_interval: 60s
-
- scrape_configs:
- – job_name: prometheus
- static_configs:
- – targets: [‘localhost:9090’]
- labels:
- instance: prometheus
- – job_name: 名称
- static_configs:
- – targets: [‘被监控ip1:9100’]
- labels:
- instance: 名称1
- – targets: [‘被监控ip2:9100’]
- labels:
- instance: 名称2
复制代码
- # 启动prometheus
-
- docker run -d -p 9090:9090 -v /data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
复制代码
访问http://面板鸡ip:9090,有页面即安装成功 4.数据库与监控链接 主要是修改上面配置文件的ip,prometheus 每次修改配置重启后配置才能应用。 当如图所示显示up时,表示prometheus 接收到node_exporter传输到的信息。 5.数据可视化 grafana登陆后,参考这个教程设置面板
- https://blog.csdn.net/shengjie87/article/details/117993751?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-5.no_search_link&spm=1001.2101.3001.4242.4
复制代码
在创建dashboard时直接导入https://grafana.com/grafana/dashboards/8919 这个面板,即可 论坛大佬多,班门弄斧了,有问题请大佬赐教
当然还要设置防火墙,只允许面板鸡访问被监控鸡端口,并做好9090端口的屏蔽
|