安装版本:prometheus-2.16.0 node-exporter-1.0.1 grafana-7.3.4

安装方式:磁盘安装

程序管理:systemd

程序包下载

https://github.com/prometheus/prometheus/releases/download/v2.16.0/prometheus-2.16.0.freebsd-amd64.tar.gz

https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-arm64.tar.gz

https://dl.grafana.com/oss/release/grafana-7.3.4.linux-arm64.tar.gz

prometheus安装

  1. 上传并解压压缩包到/usr/local目录下

    [[email protected] local]# ls -al prometheus/
    total 134924
    drwxr-xr-x   5 3434 3434      156 Mar 18 11:46 .
    drwxr-xr-x. 21 root root      266 Mar 18 11:28 ..
    drwxr-xr-x   2 3434 3434       38 Feb 14  2020 console_libraries
    drwxr-xr-x   2 3434 3434      173 Feb 14  2020 consoles
    drwx------   3 root root       51 Mar 18 11:15 data
    -rw-r--r--   1 3434 3434    11357 Feb 14  2020 LICENSE
    -rw-r--r--   1 3434 3434     3184 Feb 14  2020 NOTICE
    -rwxr-xr-x   1 3434 3434 78886010 Feb 14  2020 prometheus
    -rw-r--r--   1 3434 3434     1006 Mar 18 11:46 prometheus.yml
    -rwxr-xr-x   1 3434 3434 46227944 Feb 14  2020 promtool
    -rwxr-xr-x   1 3434 3434 13019920 Feb 14  2020 tsdb
    
  2. 修改配置文件prometheus.yml

    ...
    ##  修改监听的网卡
        static_configs:
        - targets: ['0.0.0.0:9090']
       
    ## 以下配置为node-exporter
      - job_name: 'server'
        static_configs:
          - targets: ['175.5.12.56:9100']
    
  3. 编写systemd文件prometheus.service

    [Unit]
    Description=Prometheus
    Documentation=https://prometheus.io/
    After=network.target
       
    [Service]
    Type=simple
    User=root
    ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
    Restart=on-failure
       
    [Install]
    WantedBy=multi-user.target
    
    1. 启动并验证服务
    systemctl start prometheus
    [[email protected] prometheus]# curl 127.0.0.1:9090
    <a href="/graph">Found</a>.
       
    [[email protected] prometheus]#
    

node-exporter安装

  1. 上传文件到/usr/local并解压

    [[email protected] local]# ls -al node_exporter/
    total 18376
    drwxr-xr-x   2 3434 3434       56 Jun 16  2020 .
    drwxr-xr-x. 21 root root      266 Mar 18 11:28 ..
    -rw-r--r--   1 3434 3434    11357 Jun 16  2020 LICENSE
    -rwxr-xr-x   1 3434 3434 18800055 Jun 16  2020 node_exporter
    -rw-r--r--   1 3434 3434      463 Jun 16  2020 NOTICE
    [[email protected] local]#
    
  2. 编写systemd文件node_exporter.service

    [Unit]
    Description=node_exporter
    Documentation=https://prometheus.io/
    After=network.target
       
    [Service]
    Type=simple
    User=root
    ExecStart=/usr/local/node_exporter/node_exporter
    Restart=on-failure
       
    [Install]
    WantedBy=multi-user.target
    
  3. 启动并验证服务

    systemctl start node_exporter
       
    [[email protected] node_exporter]# curl http://175.5.12.56:9100/
    <html>
                            <head><title>Node Exporter</title></head>
                            <body>
                            <h1>Node Exporter</h1>
                            <p><a href="/metrics">Metrics</a></p>
                            </body>
                            </html>[[email protected] node_exporter]#
    [[email protected] node_exporter]#
       
    

grafana安装

  1. 上传到/usr/local并解压

    [[email protected] local]# ls -al grafana/
    total 28
    drwx------   8 root root   157 Mar 18 11:49 .
    drwxr-xr-x. 21 root root   266 Mar 18 11:28 ..
    drwxr-xr-x   2 root root    96 Nov 24 22:31 bin
    drwxr-xr-x   3 root root   107 Mar 18 11:49 conf
    drwx------   5 root root    61 Mar 18 11:59 data
    -rw-r--r--   1 root root 11343 Nov 24 22:20 LICENSE
    -rw-r--r--   1 root root   108 Nov 24 22:20 NOTICE.md
    drwxr-xr-x   3 root root    22 Nov 24 22:31 plugins-bundled
    drwxr-xr-x  12 root root   155 Nov 24 22:31 public
    -rw-r--r--   1 root root  2799 Nov 24 22:20 README.md
    drwxr-xr-x   2 root root  4096 Nov 24 22:31 scripts
    -rw-r--r--   1 root root     5 Nov 24 22:31 VERSION
    [[email protected] local]#
    
  2. 编写systemd文件grafana.service

    [Unit]
    Description=Grafana instance
    Documentation=http://docs.grafana.org
    Wants=network-online.target
    After=network-online.target
       
    [Service]
    User=root
    Type=notify
    Restart=on-failure
    WorkingDirectory=/usr/local/grafana
    RuntimeDirectory=grafana
    RuntimeDirectoryMode=0750
    ExecStart=/usr/local/grafana/bin/grafana-server --config=/usr/local/grafana/conf/defaults.ini
    LimitNOFILE=10000
    TimeoutStopSec=20
       
    [Install]
    WantedBy=multi-user.target
    
  3. 启动并验证

    systemctl start grafana 
       
    [[email protected] ~]# systemctl status grafana
    ● grafana.service - Grafana instance
       Loaded: loaded (/usr/lib/systemd/system/grafana.service; disabled; vendor preset: disabled)
       Active: active (running) since Thu 2021-03-18 12:26:38 CST; 2min 5s ago
         Docs: http://docs.grafana.org
     Main PID: 78311 (grafana-server)
        Tasks: 37
       Memory: 60.1M
       CGroup: /system.slice/grafana.service
               └─78311 /usr/local/grafana/bin/grafana-server --config=/usr/local/grafana/conf/defaults.ini
       
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Path Plugins" logger=settings path=/usr/loc>
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Path Provisioning" logger=settings path=/us>
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="App mode production" logger=settings
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=sq>
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Starting DB migrations" logger=migrator
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Starting plugin search" logger=plugins
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="Registering plugin" logger=plugins id=input
    Mar 18 12:26:38 dbmaster systemd[1]: Started Grafana instance.
    Mar 18 12:26:38 dbmaster grafana-server[78311]: t=2021-03-18T12:26:38+0800 lvl=info msg="HTTP Server Listen" logger=http.server addr>
    Mar 18 12:28:26 dbmaster grafana-server[78311]: t=2021-03-18T12:28:26+0800 lvl=info msg="Request Completed" logger=context userId=0 >
       
    [[email protected] ~]# curl 127.0.0.1:3000
    <a href="/login">Found</a>.
       
    [[email protected] ~]#