
0. ENV
prometheus-2.27.0-rc.0.linux-amd64prometheus-2.33.0-rc.0.linux-amd64
升级涉及配置文件、数据、规则文件等

1. 升级前prometheus配置信息
1.1 查看当前版本
当前版本为2.27.0-rc.0
[root@monitor ~]# /monitor/prometheus/prometheus --versionprometheus, version 2.27.0-rc.0 (branch: HEAD, revision: aedd4fa95cf304870da35ab6ee7376a38d8e0c49)build user: root@be3fd1fa26a3build date: 20210509-23:01:47go version: go1.16.4platform: linux/amd64
1.2 配置信息
[root@monitor prometheus]# systemctl status prometheus● prometheus.service - prometheusLoaded: loaded (/usr/lib/systemd/system/prometheus.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2021-06-03 13:40:54 CST; 7 months 12 days agoMain PID: 103114 (prometheus)CGroup: /system.slice/prometheus.service└─103114 /monitor/prometheus/prometheus --config.file=/monitor/prometheus/prometheus.yml --storage.tsdb.path=/monitor/prometheus/data --storage.tsdb.retention=15d --web.read-timeout=5m --web.max-connections=10 --query.max-...--config.file=/monitor/prometheus/prometheus.yml #prometheus配置文件--storage.tsdb.path=/monitor/prometheus/data #prometheus 存储数据路径--storage.tsdb.retention=15d #prometheus采集数据保留时间,15天--web.read-timeout=5m #请求链接的最大等待时间,5分钟--web.max-connections=10 #最大链接数,10个链接--query.max-concurrency=20 #最大支持的并发查询量--query.timeout=2m #单个查询超时时间,2分钟--web.enable-lifecycle #热加载--web.enable-admin-api #可以删除时序数据
也可以通过进程查看
[root@monitor ~]# ps -ef | grep prometheus | grep -v grepprometh+ 96081 1 2 Jan14 ? 02:35:55 /monitor/prometheus/prometheus --config.file=/monitor/prometheus/prometheus.yml --storage.tsdb.path=/monitor/data --storage.tsdb.retention=30d --web.read-timeout=5m --web.max-connections=10 --query.max-concurrency=20 --query.timeout=2m --web.enable-lifecycle --web.enable-admin-api

2. 升级
2.1 介质下载
下载页面:
https://prometheus.io/download/
也可直接下载:
wget https://github.com/prometheus/prometheus/releases/download/v2.33.0-rc.0/prometheus-2.33.0-rc.0.linux-amd64.tar.gz
2.2 停止服务
systemctl stop prometheus
2.3 升级GO语言(可选)
prometheus及相关组件如node_exporter、mysqld_exporter都是GO语言开发,需要先安装golang。# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo# yum -y install go# go versiongo version go1.15.14 linux/amd64
2.4 解压安装新版本
1) 二进制版,解压prometheus即用
# tar zxvf prometheus-2.33.0-rc.0.linux-amd64.tar.gz -C /monitor/
2) 创建软连接,便于管理
删除2.27.0版本的软连接
[root@monitor monitor]# rm prometheusrm: remove symbolic link ‘prometheus’? y
创建新版本的软连接
# ln -sv /monitor/prometheus-2.33.0-rc.0.linux-amd64/ /monitor/prometheus

3. 恢复配置及数据等
3.1 恢复配置文件
[root@monitor ~]# cd /monitor/prometheus/ && cp prometheus.yml prometheus.yml.orig[root@monitor prometheus]# cp /monitor/prometheus-2.27.0-rc.0.linux-amd64/prometheus.yml /monitor/prometheus/
3.2 恢复数据
将数据连接到/monitor/prometheus/data下
# ln -sv /monitor/data /monitor/prometheus/data
3.3 恢复规则
# ln -sv /monitor/rules /monitor/prometheus/rules

4. 启动服务
前台启动:
cd /monitor/prometheus && ./prometheus --config.file=/monitor/prometheus/prometheus.yml --storage.tsdb.path=/monitor/data
后台启动:
cd /monitor/prometheus && nohup ./prometheus --config.file=/monitor/prometheus/prometheus.yml >> ./log/prometheus_stdout.log 2>&1 &
使用服务启动(前提是进行过服务配置)
systemctl start prometheus

5. 验证数据访问
浏览器访问
http://IP:9090/targets

6. refrence
https://prometheus.io/docs/prometheus/latest/migration/
往期推荐
文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




