Prometheus监控-主平台安装

2021-06-10 11:46:29 浏览数 (1)

同步时间

代码语言:javascript复制
yum -y install ntpdate  #同步时间 timedatectl set-timezone Asia/Shanghaintpdate ntp.aliyun.comhwclock -wsed -i 's%SYNC_HWCLOCK=no%SYNC_HWCLOCK=yes%' /etc/sysconfig/ntpdateecho "* 23 * * * root /usr/sbin/ntpdate ntp.aliyun.com" >> /etc/crontab && crontab /etc/crontab

下载安装文件

代码语言:javascript复制
wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gztar -xvf prometheus-2.27.1.linux-amd64.tar.gz  -C /usr/local/cd /usr/local/mv prometheus-2.27.1.linux-amd64/ prometheus

创建用户和数据存储目录

代码语言:javascript复制
useradd -M -s /sbin/nologin  prometheusmkdir -pv /data/prometheuschown -R prometheus:prometheus  /usr/local/prometheus/    /data/prometheus/

创建Systemd服务启动prometheus

代码语言:javascript复制
cat >/usr/lib/systemd/system/prometheus.service <<EOF[Unit]Description=PrometheusAfter=network.target[Service]Type=simpleEnvironment="GOMAXPROCS=4"User=prometheusGroup=prometheusExecReload=/bin/kill -HUP $MAINPIDExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --storage.tsdb.retention.time=30d --web.console.libraries=/usr/local/prometheus/console_libraries --web.console.templates=/usr/local/prometheus/consoles --web.listen-address=0.0.0.0:9090 --web.read-timeout=5m --web.max-connections=10 --query.max-concurrency=20 --query.timeout=2m --web.enable-lifecyclePrivateTmp=truePrivateDevices=trueProtectHome=trueNoNewPrivileges=trueLimitNOFILE=infinityReadWriteDirectories=/data/prometheusProtectSystem=fullSyslogIdentifier=prometheusRestart=always[Install]WantedBy=multi-user.targetEOF

启动

代码语言:javascript复制
systemctl daemon-reloadsystemctl enable prometheussystemctl start prometheussystemctl status prometheus

放行防火墙

代码语言:javascript复制
firewall-cmd --zone=public --add-port=9090/tcp --permanent  firewall-cmd --reload# systemctl stop firewalld && systemctl disable firewalld

查看端口

代码语言:javascript复制
[root@localhost ~]# netstat -tnpl | grep prometheustcp6       0      0 :::9090                 :::*                    LISTEN      1745/prometheus     

打开 prometheus 的 web 界面

http://ip:9090

更多内容, 豌豆日志 https://pealog.com/496.html

0 人点赞