部署
NAME | IP | 系统 |
---|---|---|
localhost | 192.168.159.103 | RedHat 8 |
关闭防火墙与SElinux
[root@localhost ~]# systemctl disable --now firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# cat /etc/sysconfig/selinux
SELINUX=disabled
[root@localhost ~]# reboot
创建用户
[root@localhost ~]# useradd -r -M -s /sbin/nologin prometheus
[root@localhost ~]# id prometheus
uid=987(prometheus) gid=983(prometheus) 组=983(prometheus)
下载包
[root@localhost ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.32.0-beta.0/prometheus-2.32.0-beta.0.linux-amd64.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg prometheus-2.32.0-beta.0.linux-amd64.tar.gz
[root@localhost ~]# tar xf prometheus-2.32.0-beta.0.linux-amd64.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
debug kernels prometheus-2.32.0-beta.0.linux-amd64
[root@localhost src]# mv prometheus-2.32.0-beta.0.linux-amd64/ prometheus
[root@localhost src]# ls
debug kernels prometheus
创建文件所需目录
[root@localhost prometheus]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
[root@localhost prometheus]# mkdir -p conf relus data
[root@localhost prometheus]# mv prom
prometheus prometheus.yml promtool
[root@localhost prometheus]# mv prometheus.yml conf
[root@localhost prometheus]# cp prometheus promtool /usr/local/bin/
[root@localhost prometheus]# chown -R prometheus:prometheus /usr/src/prometheus/
添加为系统服务
[root@localhost ~]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=prometheus-server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/src/prometheus/prometheus --config.file=/usr/src/prometheus/conf/prometheus.yml --web.enable-lifecycle --storage.tsdb.path=/usr/src/prometheus/data --storage.tsdb.retention.time=7d --web.max-connections=512 --web.read-timeout=3m --query.max-concurrency=25 --query.timeout=2m
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
查看
[root@localhost ~]# systemctl start prometheus.service
[root@localhost ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:9090 *:*
LISTEN 0 128 [::]:22 [::]:*
网页访问
查看监控状态
把每一个都看一下
因为是命令行,所以这里切换回英文查看
还没有添加规则,所以为空
评论区