环境:centos7.8
docker、k8s下都可以使用Prometheus+Grafana
1.查看环境相关信息
(1)查看信息:uname -a
(2)查看版本信息:cat /etc/redhat-release
(3)查看主机名称:hostname
2.软件信息
Prometheus、Grafana:Prometheus和Grafana服务端(收集数据并进行展示)
node_exporter:Prometheus客户端(被收集数据的客户端)
3.相关软件官网地址
Prometheus和node_exporter官网地址:https://prometheus.io/,软件包下载地址:https://prometheus.io/download/
Grafana官网地址:https://grafana.com/,软件包下载地址:https://grafana.com/grafana/download
Prometheus默认端口:9090
node_exporter默认端口:9100
Grafana默认端口:3000
4.Prometheus服务端搭建
(1)关闭防火墙和selinux
关闭防火墙:systemctl stop firewalld
禁用防火墙:systemctl disable firewalld
查看防火墙状态:systemctl status firewalld
关闭并禁用selinux:sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
查找selinux:find / -name selinux find / -type f -name selinux
(2)Prometheus 2.17.1下载
(2.1)切换目录:cd /usr/local/
(2.2)创建目录:mkdir prometheus
(2.3)下载安装包:wget https://github.com/prometheus/prometheus/releases/download/v2.17.1/prometheus-2.17.1.linux-amd64.tar.gz
(2.4)Prometheus安装包已编译,无需安装go语言环境,直接解压缩即可。
切换目录:cd prometheus
解压缩包:tar -zxvf /usr/local/prometheus-2.17.1.linux-amd64.tar.gz
删除目录:rm -rf prometheus-2.17.1.linux-amd64/
切换目录:cd prometheus/
重命名:mv prometheus-2.17.1.linux-amd64 prometheus
(2.5)Prometheus做成软连接
ln -s /usr/local/prometheus/prometheus-2.17.1.linux-amd64 /usr/local/prometheus/prometheus
(2.6)Prometheus数据存储目录
创建用户目录:mkdir -p /var/lib/prometheus
授权读取权限:chmod -r prometheus /var/lib/prometheus/ chown -R prometheus /var/lib/prometheus/
(2.7)运行Prometheus组和用户
创建组:groupadd prometheus
创建用户:useradd -g prometheus -s /sbin/n