
# 新建一个挂载目录
mkdir /mnt/cdrom
# 将 /dev/cdrom 挂载到 /mnt/cdrom 目录上
mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
sudo ./VBoxLinuxAdditions.run
关机虚拟机,添加共享文件夹,设置自动挂载,并且设置挂载点(linux内的文件夹地址)
将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
进去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
生效systemd文件
systemctl daemon-reload
# 进入解压后的文件夹
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 &
这里使用修改后的端口访问:
http://127.0.0.1:9099

配置网络为NAT并且设置端口转发

开放端口9099
firewall-cmd --zone=public --add-port=9099/tcp --permanent
firewall-cmd --reload
其它的语句:
# 查看防火墙状态
systemctl status firewalld
# 开启防火墙
systemctl status firewalld
# 关闭防火墙
systemctl stop firewalld
http://127.0.0.1:9099
方法同上,下载,解压,移动,启动
nohup ./pushgateway --web.listen-address :9091 > ./pushgateway.log 2>&1 &
# 查看状态
ps -ef|grep prometheus
#重启
systemctl restart prometheus
#对于后台启动的服务可以先查看状态然后使用kill命令杀死进程
kill 6330
https://blog.csdn.net/weixin_51659640/article/details/122616326

启动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
consul agent -dev -client 0.0.0.0 -ui10.0.2.2访问docker run --name consul -p 8500:8500 -d consul:1.13.1# 查看正在运行的容器
docker ps -s
# 删除指定的容器
docker rm 容器号
# 关闭所有的容器
docker stop $(docker ps -a | awk '{ print $1}' | tail -n +2)
docker pull prom/prometheussudo docker run -d -p 9090:9090 --name prom prom/prometheus --config.file=/data/prometheus/prometheus.yml