1. 下载Prometheus
2. 使用VirtualBox的共享文件夹将压缩包传入linux
- 进入增强文件夹
- 启动终端并且切换root权限
# 新建一个挂载目录
mkdir /mnt/cdrom
# 将 /dev/cdrom 挂载到 /mnt/cdrom 目录上
mount /dev/cdrom /mnt/cdrom
- 进入增强工具挂载的目录
cd /mnt/cdrom
- 安装运行
sudo ./VBoxLinuxAdditions.run
3. 在linux安装Prometheus
- 安装Prometheus
打开终端并且切换root
账户
# 新建目录
mkdir -p /data/prometheus/
# 进入目标目录
cd /data/prometheus/
# 解压
tar -vxzf prometheus-2.28.1.linux-amd64.tar.gz
# 移动到安装目录
mv prometheus-2.28.1.linux-amd64 /usr/local/prometheus
# 进入目录
cd /usr/local/prometheus
- 将Prometheus配置为系统服务
进去systemd目录
cd /usr/lib/systemd/system
创建文件。这里的Vim语法,使用:wq
保存
vim prometheus.service
# 添加如下内容
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
4. 启动Prometheus
# 进入解压后的文件夹
cd /data/prometheus/prometheus-2.28.1.linux-amd64
# 前台启动
./prometheus --config.file=prometheus.yml
# 前台指定端口启动
./prometheus --config.file=prometheus.yml --web.listen-address=:9099
# 后台启动prometheus,并且重定向输入日志到当前目录的prometheus.out
nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
5. 访问Prometheus
这里使用修改后的端口访问:
http://127.0.0.1:9099
6. 使用外部主机访问内部linux的Prometheus
-
配置网络为NAT并且设置端口转发
-
开放端口9099
firewall-cmd --zone=public --add-port=9099/tcp --permanent
- 重启防火墙生效
firewall-cmd --reload
其它的语句:
# 查看防火墙状态
systemctl status firewalld
# 开启防火墙
systemctl status firewalld
# 关闭防火墙
systemctl stop firewalld
7. 主机直接访问
http://127.0.0.1:9099
8. pushgateway的安装
方法同上,下载,解压,移动,启动
nohup ./pushgateway --web.listen-address :9091 > ./pushgateway.log 2>&1 &
# 查看状态
ps -ef|grep prometheus
#重启
systemctl restart prometheus
#对于后台启动的服务可以先查看状态然后使用kill命令杀死进程
kill 6330
9. 服务器时间不一致解决
https://blog.csdn.net/weixin_51659640/article/details/122616326
10. 防火墙常见命令
启动cansul:
./consul agent -dev
启动pushgateway:nohup ./pushgateway --web.listen-address :9091 > ./pushgateway.log 2>&1 &
启动node_exporter: ./node_exporter
启动普罗米修斯:nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
查看状态:ps -ef|grep prometheus
11. windows浏览器无法访问虚拟机上Linux部署的consul
- linux 8500端口已经开放
- 设置了端口转发
- 关闭防火墙
- 启动consul
consul agent -dev -client 0.0.0.0 -ui
12. 虚拟机访问主机服务
- 不需要端口转发
- 直接使用
10.0.2.2
访问
原文地址:https://www.jb51.cc/wenti/3288703.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。