文章以笔记的形式记录,只记录操作过程,不掺杂理论部分。
软件版本为: Prometheus:2.24.1 Grafana:7.3.7
1.实验环境
文章以Centos-7.4版本为实验环境,关闭Firewall与SELinux服务。
[root@centos7 ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@centos7 ~]# uname -r 3.10.0-693.el7.x86_64
2.快速部署Prometheus
官网:Prometheus下载
清华源下载:下载链接
在这里,我们以二进制的方式进行快速部署。
嗯,网络不好的话还是通过其他途径吧,就比如我,从清华源下载的。
- 下载二进制包
[root@centos7 ~]# mkdir /server [root@centos7 ~]# cd /server [root@centos7 server]# wget https://mirrors.tuna.tsinghua.edu.cn/github-release/prometheus/prometheus/2.24.1%20_%202021-01-20/prometheus-2.24.1.linux-amd64.tar.gz [root@centos7 server]# ls prometheus-2.24.1.linux-amd64.tar.gz
- 解压到指定目录
[root@centos7 server]# mkdir /app [root@centos7 server]# tar xf prometheus-2.24.1.linux-amd64.tar.gz -C /app
- 授权并创建软连接
[root@centos7 server]# cd /app/ [root@centos7 app]# chown -R root:root prometheus-2.24.1.linux-amd64/ [root@centos7 app]# ln -s prometheus-2.24.1.linux-amd64/ prometheus
- 启动Prometheus
注:也可以把服务启动添加到系统服务,Emmmm。。。我懒
[root@centos7 prometheus]# nohup ./prometheus & [1] 15764
- 查看状态
[root@centos7 prometheus]# ss -utpln | grep prometheus tcp LISTEN 0 128 :::9090 :::* users:(("prometheus",pid=15764,fd=7))
在浏览器上测试
- (看到这个页面说明部署成功了)
3.部署Grafana可视化
- 创建Grafana源
[root@centos7 ~]# vim /etc/yum.repos.d/grafana.repo [root@centos7 ~]# cat /etc/yum.repos.d/grafana.repo [grafana] name=grafana baseurl=https://packages.grafana.com/oss/rpm repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packages.grafana.com/gpg.key sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt
- 使用YUM安装Grafana
[root@centos7 ~]# yum install grafana -y [root@centos7 ~]# rpm -qa | grep grafana grafana-7.3.7-1.x86_64
- 启动服务
[root@centos7 ~]# systemctl start grafana-server.service [root@centos7 ~]# systemctl enable grafana-server.service
4.登录浏览器进行配置
- 在浏览器登录grafana,默认账号密码为admin
http://192.168.1.3:3000/
admin
admin
第一次登录需要修改密码,新密码为:123123
添加Prometheus数据源
- (拉到最下方保存并测试)
- 创建仪表盘
(然后点击名称即可查看)
(到此一个没有任何内容的监控平台搭建完成)
(其他内容将在后续的文章中编写)
(未完待续… …)