上次介绍的是在Windows环境下配置Prometheus和Grafana,详见https://blog.csdn.net/qq_28323595/article/details/108624022,本次介绍Linux下操作步骤。
1.安装Prometheus
1.1 下载与上传
下载Prometheushttps://prometheus.io/download/,我下载的是prometheus-2.21.0.linux-amd64.tar.gz。
可以使用xftp上传,也可以使用rz命令
1.2 解压
tar -xzvf prometheus-2.21.0.linux-amd64.tar.gz -C /usr/local/
1.3 重命名
mv /usr/local/prometheus-2.21.0.linux-amd64 /usr/local/prometheus
1.4 修改prometheus.yml
将默认的localhost:9090改为你服务器的ip,端口号可以不改
1.5 启动Prometheus
cd /usr/local/prometheus
./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
注:&表示后台运行
1.6 查看是否启动成功
命令:
lsof -i:9090
在浏览器中访问http://192.168.110.25:9090,查看结果,如果出现红框中的东西表示启动成功。
2. Grafana
2.1 下载与上传
下载地址https://grafana.com/grafana/download,我下载的是grafana-7.1.5-1.x86_64.rpm,下载完成后上传到Linux。
2.2 安装
rpm -ivh grafana-7.1.5-1.x86_64.rpm
2.3 启动
systemctl start grafana-server
2.4 查看是否启动成功
默认开启的是3000端口
在浏览器中访问http://你的ip:3000,用户名和密码都是admin,具体使用步骤可以参考https://blog.csdn.net/qq_28323595/article/details/108624022
3. 监控Springboot
如需监控SpringBoot只需按照https://blog.csdn.net/qq_28323595/article/details/108624022中的步骤3操作,然后打包部署到服务器,最后修改prometheus.yml重新启动prometheus就可以。