侧边栏壁纸
  • 累计撰写 4 篇文章
  • 累计创建 5 个标签
  • 累计收到 1 条评论
标签搜索

目 录CONTENT

文章目录

Prometheus+Grafana 安装配置

jerry
2022-09-16 / 0 评论 / 0 点赞 / 2,167 阅读 / 582 字

基础环境

主机 系统 IP
监控主机 CentOS 7 192.168.1.100
被监控主机 CentOS 7 192.168.1.101

Prometheus

以下操作皆在监控主机(192.168.1.100)上执行

一、关闭机器防火墙

firewall 与 iptables 一样都是服务,所以可以使用 systemctl 服务管理工具来操作

# 关闭防火墙,停止 firewall 服务
systemctl stop firewalld

# 禁用防火墙
systemctl disable firewalld

# 查看防火墙状态
systemctl status firewall
命令 描述
systemctl status firewall 查看防火墙状态
systemctl stop firewalld 关闭防火墙,停止 firewall 服务
systemctl start firewalld 开启防火墙,启动 firewall 服务
systemctl restart firewalld 重启防火墙,重启 firewall 服务
systemctl is-enabled firewalld 查看 firewall 服务是否开机启动
systemctl enable firewalld.service 开机时自动启动 firewall 服务
systemctl disable firewalld.service 开机时自动禁用 firewall 服务

二、安装 Go

由于Prometheus是由go语言开发的,所以在安装Prometheus之前需要先在监控主机上安装go环境

安装包下载地址: https://golang.org/dl/

# 下载安装包
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz

# 创建 Go 安装目录
mkdir -p /usr/local/opt/go

# 解压
tar -zxvf go1.14.2.linux-amd64.tar.gz -C /usr/local/opt/go

# 重命名版本号
cd /usr/local/opt/go
mv go 1.14.2

# 配置环境变量
vim /etc/profile

# 在最后一行添加
GO_HOME=/usr/local/opt/go/1.14.2
export PATH=$PATH:${GO_HOME}/bin

# wq保存退出后source生效
source /etc/profile

# 验证 Go 安装是否成功
go version
## 安装成功返回版本信息
go version go1.14.2 linux/amd64

三、安装 Prometheus

安装包下载地址: https://prometheus.io/download/#prometheus

# 下载安装包
wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz

# 创建 Prometheus 安装目录
mkdir -p /usr/local/opt/prometheus

# 解压
tar -zxvf prometheus-2.18.1.linux-amd64.tar.gz -C /usr/local/opt/prometheus

# 重命名版本号
cd /usr/local/opt/prometheus
mv prometheus-2.18.1.linux-amd64 2.18.1

# 配置环境变量
vim /etc/profile

# 在最后一行添加
PROMETHEUS_HOME=/usr/local/opt/prometheus/2.18.1
export PATH=$PATH:${PROMETHEUS_HOME}/bin

# wq保存退出后source生效
source /etc/profile

# 验证 prometheus 安装是否成功
prometheus --version
## 安装成功返回版本信息
prometheus, version 2.18.1 (branch: HEAD, revision: ecee9c8abfd118f139014cb1b174b08db3f342cf)
  build user:       root@2117a9e64a7e
  build date:       20200507-16:51:47
  go version:       go1.14.2
0

评论区