Promtheus实战系列(一)之环境部署与搭建

一、部署prometheus,grafana和node_exporter

Prometheus开始教程:https://github.com/Alrights/prometheus/blob/master/introductions/FirstSteps.md

1.1 环境(centos7)

1[root@localhost prometheus]# uname -a 2Linux localhost.localdomain 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

1.2 环境部署与服务启动

1// 安装prometheus 2wget https://github.com/prometheus/prometheus/releases/download/v2.9.2/prometheus-2.9.2.linux-amd64.tar.gz 3tar xzvf prometheus-2.9.2.linux-amd64.tar.gz 4mv prometheus-2.9.2.linux-amd64 /usr/local/prometheus

// 添加prometheus用户,非必须 groupadd prometheus useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus

1 2对systemctl不熟的可以了解[鸟哥的Linux私房菜](https://links.jianshu.com/go?to=http%3A%2F%2Flinux.vbird.org%2Flinux_basic%2F0560daemons.php%23daemon) 3

// prometheus系统服务配置 vim /etc/systemd/system/prometheus.service

[Unit] Description=prometheus After=network.target [Service] Type=simple User=prometheus ExecStart=/usr/local/prometheus/prometheus -config.file=/usr/local/prometheus/prometheus.yml -storage.local.path=/var/lib/prometheus Restart=on-failure [Install] WantedBy=multi-user.target

1// 启动prometheus 2systemctl start prometheus 3systemctl status prometheus 4``` 5 6![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/1724e8f3fe630e5b0eb01c9d31955e3c.png) 7 8systemctl\_prometheus.png 9 102. node\_exporter setup 11 12``` 13// 安装node_exporter 14wget https://github.com/prometheus/node_exporter/releases/download/v0.18.0/node_exporter-0.18.0.linux-amd64.tar.gz 15tar -zxvf node_exporter-0.18.0.linux-amd64.tar.gz 16mv node_exporter-0.18.0.linux-amd64 /usr/local/node_exporter

// 系统服务配置node_exporter vim /etc/systemd/system/node_exporter.service

[Unit] Description=node_exporter After=network.target [Service] Type=simple User=prometheus ExecStart=/usr/local/node_exporter/node_exporter Restart=on-failure [Install] WantedBy=multi-user.target

1systemctl start node_exporter 2systemctl status node_exporter 3``` 4 5![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/3ea07e0c25982e1bd7bf180aa2b98753.png) 6 7systemctl\_node\_exporter.png 8 93. add node\_exporter to prometheus.yaml 10 11``` 12vim /usr/local/prometheus/prometheus.yml 13 14 - job_name: 'linux' 15 static_configs: 16 - targets: ['localhost:9100'] 17 labels: 18 instance: node1

systemctl restart prometheus systemctl status prometheus

1 24. grafana setup 3

// 安装grafana wget https://dl.grafana.com/oss/release/grafana-6.1.6-1.x86_64.rpm yum localinstall grafana-6.1.6-1.x86_64.rpm // 启动grafana-server systemctl start grafana-server systemctl status grafana-server

1 2![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/7a65df055e0a6c9b8a20cbe5e65f3945.png) 3 4systemctl\_grafana\_server.png 5 6二、仪表化 7----- 8 9### 2.1 prometheus 10 11prometheus默认端口为9090,可以在浏览器中输入[http://localhost:9090/](https://links.jianshu.com/go?to=http%3A%2F%2Flocalhost%3A9090%2F) 12 13![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/082565e1e0e21fa4d9a5b5dd7dfefac8.png) 14 15prometheus\_first\_start.png 16 17### 2.2 granafa 18 19granafa默认端口为3000,可以在浏览器中输入[http://localhost:3000/](https://links.jianshu.com/go?to=http%3A%2F%2Flocalhost%3A3000%2F) 20 21* granafa首次登录账户名和密码`admin/admin`,可以修改 22* 配置数据源`Data sources->Add data source -> Prometheus`,输入prometheus数据源的信息,主要是输入`name``url` 23 24 ![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/be6feb002f5eaec8634945934bc8e1d2.png) 25 26 grafana\_prometheus\_datasource.png 27 28* 添加Dashboard`New Dashboard->Import Dashboard->输入8919`,配置数据源为Prometheus,即上一步中的`name` 29 30 ![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/e91722b93b249c3abcb4381f62f04bd8.png) 31 32 grafana\_dashboard\_node\_exporter.png 33 34* 配置完保存后即可看到逼格非常高的系统主机节点监控信息,包括CPUIO、网络等信息。 35 36 37 38 ![](https://img-hello-world.oss-cn-beijing.aliyuncs.com/a7a740743d18b92f43025eff67d82a65.png) 39 40 grafana\_first\_dashboard.png 41 42 43三、tips 44------ 45 461. iptables(端口不通) 47

/sbin/iptables -I INPUT -p tcp --dport 9090 -j ACCEPT

1 22. datetime(设置时区) 3

timedatectl list-timezones timedatectl set-timezone Asia/Shanghai

1 2 3 4本文转自 [https://www.jianshu.com/p/65fcff832ad7](https://www.jianshu.com/p/65fcff832ad7),如有侵权,请联系删除。
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )