首页 > 其他分享 >prometheus-部署

prometheus-部署

时间:2022-12-05 14:15:05浏览次数:65  
标签:amd64 部署 prometheus linux go root 2.25

1. prometheus-部署

  • 部署方式

  • prometheus二进制部署

    • 下载地址: https://prometheus.io/download/

      [root@harbor ~]# wget  https://github.com/prometheus/prometheus/releases/download/v2.25.2/prometheus-2.25.2.linux-amd64.tar.gz  
      
  • 解压prometheus包

    [root@harbor ~]# ll
    总用量 607824
    -rw-------. 1 root root      1637 1月   4 15:44 anaconda-ks.cfg
    drwxr-xr-x. 4 root root       191 1月  11 17:26 harbor
    -rw-r--r--. 1 root root 556130191 1月   5 11:37 harbor-offline-installer-v2.1.0.tgz
    -rw-r--r--. 1 root root  66277199 3月  17 04:25 prometheus-2.25.2.linux-amd64.tar.gz
    [root@harbor ~]# tar -zxvf prometheus-2.25.2.linux-amd64.tar.gz 
    prometheus-2.25.2.linux-amd64/
    prometheus-2.25.2.linux-amd64/consoles/
    prometheus-2.25.2.linux-amd64/consoles/index.html.example
    prometheus-2.25.2.linux-amd64/consoles/node-cpu.html
    prometheus-2.25.2.linux-amd64/consoles/node-disk.html
    prometheus-2.25.2.linux-amd64/consoles/node-overview.html
    prometheus-2.25.2.linux-amd64/consoles/node.html
    prometheus-2.25.2.linux-amd64/consoles/prometheus-overview.html
    prometheus-2.25.2.linux-amd64/consoles/prometheus.html
    prometheus-2.25.2.linux-amd64/console_libraries/
    prometheus-2.25.2.linux-amd64/console_libraries/menu.lib
    prometheus-2.25.2.linux-amd64/console_libraries/prom.lib
    prometheus-2.25.2.linux-amd64/prometheus.yml
    prometheus-2.25.2.linux-amd64/LICENSE
    prometheus-2.25.2.linux-amd64/NOTICE
    prometheus-2.25.2.linux-amd64/prometheus
    prometheus-2.25.2.linux-amd64/promtool
    
  • 查看prometheus目录结构

    [root@harbor ~]# cd prometheus-2.25.2.linux-amd64/
    [root@harbor prometheus-2.25.2.linux-amd64]# ll
    总用量 167980
    drwxr-xr-x. 2 3434 3434       38 3月  17 04:20 console_libraries
    drwxr-xr-x. 2 3434 3434      173 3月  17 04:20 consoles
    -rw-r--r--. 1 3434 3434    11357 3月  17 04:20 LICENSE
    -rw-r--r--. 1 3434 3434     3420 3月  17 04:20 NOTICE
    -rwxr-xr-x. 1 3434 3434 91044140 3月  17 02:10 prometheus
    -rw-r--r--. 1 3434 3434      926 3月  17 04:20 prometheus.yml
    -rwxr-xr-x. 1 3434 3434 80944687 3月  17 02:12 promtool
    
  • prometheus常用参数

    ./premetheus -h 命令行常用参数:
    	 --config.file="prometheus.yml"     # 指定配置文件
    	--web.listen-address="0.0.0.0:9090"       # 监听地址和端口
    	--log.level=info             # 日志级别
    	--alertmanager.timeout=10s          # 与报警组件的超时时间
    	--storage.tsdb.path="data/"             # 数据目录
      --storage.tsdb.retention.time=15d        # 数据保存时间,默认15天
    
  • 启动prometheus服务

    [root@harbor prometheus-2.25.2.linux-amd64]# ./prometheus 
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:366 msg="No time or size retention was set so using the default time retention" duration=15d
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:404 msg="Starting Prometheus" version="(version=2.25.2, branch=HEAD, revision=bda05a23ada314a0b9806a362da39b7a1a4e04c3)"
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:409 build_context="(go=go1.15.10, user=root@de38ec01ef10, date=20210316-18:07:52)"
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:410 host_details="(Linux 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 harbor (none))"
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:411 fd_limits="(soft=1024, hard=4096)"
    level=info ts=2021-03-22T09:24:11.938Z caller=main.go:412 vm_limits="(soft=unlimited, hard=unlimited)"
    level=info ts=2021-03-22T09:24:11.941Z caller=web.go:532 component=web msg="Start listening for connections" address=0.0.0.0:9090
    level=info ts=2021-03-22T09:24:11.943Z caller=main.go:779 msg="Starting TSDB ..."
    level=info ts=2021-03-22T09:24:11.947Z caller=tls_config.go:191 component=web msg="TLS is disabled." http2=false
    level=info ts=2021-03-22T09:24:11.948Z caller=head.go:668 component=tsdb msg="Replaying on-disk memory mappable chunks if any"
    level=info ts=2021-03-22T09:24:11.948Z caller=head.go:682 component=tsdb msg="On-disk memory mappable chunks replay completed" duration=8.606µs
    level=info ts=2021-03-22T09:24:11.948Z caller=head.go:688 component=tsdb msg="Replaying WAL, this may take a while"
    level=info ts=2021-03-22T09:24:11.948Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
    level=info ts=2021-03-22T09:24:11.948Z caller=head.go:745 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=30.562µs wal_replay_duration=214.992µs total_replay_duration=279.469µs
    level=info ts=2021-03-22T09:24:11.949Z caller=main.go:799 fs_type=XFS_SUPER_MAGIC
    level=info ts=2021-03-22T09:24:11.949Z caller=main.go:802 msg="TSDB started"
    level=info ts=2021-03-22T09:24:11.949Z caller=main.go:928 msg="Loading configuration file" filename=prometheus.yml
    level=info ts=2021-03-22T09:24:12.194Z caller=main.go:959 msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=244.627216ms remote_storage=5.175µs web_handler=312ns query_engine=2.575µs scrape=244.060033ms scrape_sd=80.981µs notify=65.014µs notify_sd=43.933µs rules=18.737µs
    level=info ts=2021-03-22T09:24:12.194Z caller=main.go:751 msg="Server is ready to receive web requests."
    
    
  • 验证端口是否启动了

    [root@harbor ~]# netstat -lntup |grep 9090
    tcp6       0      0 :::9090                 :::*                    LISTEN      28015/./prometheus 
    
  • 浏览器访问测试
    image

  • 移动prometheus服务

    [root@iZj6cbgktk3zjpge312vq2Z system]# cd /root
    [root@iZj6cbgktk3zjpge312vq2Z opt]# ll
    total 4
    drwxr-xr-x 5 3434 3434 4096 May 20 15:59 prometheus-2.25.2.linux-amd64
    -rw-r--r-- 1 root root 66277199 May 20 15:59  prometheus-2.25.2.linux-amd64.tar.gz
    [root@iZj6cbgktk3zjpge312vq2Z opt]# mkdir -p /opt/monitor
    [root@iZj6cbgktk3zjpge312vq2Z opt]# mv prometheus-2.25.2.linux-amd64 prometheus
    [root@iZj6cbgktk3zjpge312vq2Z opt]# mv prometheus /opt/monitor/
    
  • 编写prometheus服务

    [root@iZj6cbgktk3zjpge312vq2Z prometheus]# cd  /usr/lib/systemd/system/
    [root@iZj6cbgktk3zjpge312vq2Z system]# vi prometheus.service
    [root@iZj6cbgktk3zjpge312vq2Z system]# cat prometheus.service
    [Unit]
    Description=prometheus
    [Service]
    ExecStart=/opt/monitor/prometheus/prometheus --config.file=/opt/monitor/prometheus/prometheus.yml
    ExecReload=/bin/kill -HUP $MAINPID
    KillMode=process
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    
  • 启动

    systemctl daemon-reload
    systemctl start prometheus
    systemctl enable prometheus
    

标签:amd64,部署,prometheus,linux,go,root,2.25
From: https://www.cnblogs.com/scajy/p/16952109.html

相关文章