1)下载服务端:
wget https://github.com/prometheus/prometheus/releases/download/v2.43.0-rc.0/prometheus-2.43.0-rc.0.linux-amd64.tar.gztar zxvf prometheus-2.43.0-rc.0.linux-amd64.tar.gz
#解压
tar -xvf prometheus-2.32.1.linux-amd64.tar.gz
#移动至某个文件夹
mv prometheus-2.32.1.linux-amd64 /usr/local/prometheus
cd /usr/local/prometheus/
cp -ar prometheus.yml prometheus.yml-bak
2)修改配置文件/usr/local/prometheus/prometheus.yml
#修改配置文件
## 第六行添加
scrape_timeout: 10s
## 最后一行localhost改为本机的ip(其实不改也可以,为了分辨,建议修改)
- targets: ["172.16.11.209:9090"]
3)启动方式;
#进入这个文件,默认是没有的,直接进入就行
vim /usr/lib/systemd/system/prometheus.service
#将下面的全部写进去
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--storage.tsdb.path=/usr/local/prometheus/data/ \
--storage.tsdb.retention=15d \
--web.enable-lifecycle
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
#启动
systemctl restart prometheus
#设置开机自启
systemctl enable prometheus
#查看端口是否启动9090
netstat -anput | grep 9090
3)页面访问和配置
输入IP:端口
graph查看服务器cpu数据 process_cpu_seconds_total
(1)下载服务端
#下载node客户端
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz
#解压node_exporter压缩包
tar xf node_exporter-1.6.0.linux-amd64.tar.gz
#移动到固定文件夹
mv node_exporter-1.6.0.linux-amd64 /usr/local/prometheus_node
(2)设置启动方式
vim /usr/lib/systemd/system/node_exporter.service
#将下面的全部写进去
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/prometheus_node/node_exporter \
--collector.ntp \
--collector.mountstats \
--collector.systemd \
--collector.tcpstat
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
(3)启动
#启动
systemctl restart node_exporter
#设置开机自启
systemctl enable node_exporter
#查看端口是否启动9100
netstat -anput | grep 9100
(4)页面访问
(5) 服务端配置客户端
#进入prometheus的配置文件中
vim /usr/local/prometheus/prometheus.yml
重启服务端
systemctl restart prometheus
(6)检测配置文件方法如下:
监测 Prometheus配置文件是否正确
#进入prometheus目录
cd /usr/local/prometheus/
#执行promtool,监测配置是否正确
./promtool check config prometheus.yml
安装地址
#先创建清华的yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim qinghua.repo
[qinghua]
name=qinghua
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]# yum makecache
#安装软件
yum -y install grafana-9.1.0-1.x86_64.rpm
#开启服务
systemctl start grafana-server
#看端口
netstat -nlpt|grep 3000
访问端口ip:3000,账号密码: admin/admin ,如果到忘记密码,找回密码:
grafana-cli admin reset-admin-password admin
grafana默认配置文件目录 /etc/grafana/grafana.ini
http://www.dtmao.cc/Html5/117753.html