Helping the Industrial Internet of Things, the service domain of industrial big data: node_exporter plug-in [37]

foreword

Tools required for the project:
Link: https://pan.baidu.com/s/1sIa8nninf2Fz6YqE3vUpqQ?pwd=5wr3
Extraction code: 5wr3
– Shared from Baidu Netdisk super member V4

06: node_exporter plugin

  • Goal : To realize the installation of node_exporter plug-in and monitor Linux indicators

  • implement

    • Upload and install

      cd ~
      rz
      tar zxvf node_exporter-1.1.2.linux-amd64.tar.gz -C /opt/prometheus-2.26/
      mv /opt/prometheus-2.26/node_exporter-1.1.2.linux-amd64 /opt/prometheus-2.26/node_exporter
      
    • register

      # 创建并编辑文件
      vim /etc/systemd/system/node_exporter.service
      
      [Unit]
      Description=node_exporter
      Documentation=Prometheus node_exporter plugin
      
      [Service]
      ExecStart=/opt/prometheus-2.26/node_exporter/node_exporter
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
      
    • start up

      # 设置开机自启动
      systemctl enable node_exporter
      # 启动服务
      systemctl start node_exporter
      # 查看服务状态
      systemctl status node_exporter
      
    • Configure Prometheus

      vim /opt/prometheus-2.26/prometheus.yml
      
      scrape_configs:
      
        - job_name: 'prometheus'
          static_configs:
            - targets: ['localhost:9090']
        # 增加以下内容
        - job_name: 'linux'
          static_configs:
          - targets: ['localhost:9100']
            labels:
              instance: node1  
      
      • restart prometheus

        systemctl restart prometheus.service
        
    • Verification : http://node1:9090

      image-20211005184614853

      image-20211005184633663

      • View the CPU usage of the current host: node_cpu_seconds_total

        image-20211005184748505

      • View the CPU load of the current host: node_load15

        image-20211005184828208

  • summary

    • Realize the installation and monitoring of Linux indicators of node_exporter plug-in

07: mysqld_exportor plugin

  • Goal : To realize the installation of mysqld_exportor plug-in and monitor MySQL indicators

  • implement

    • Upload and install

      cd ~
      rz
      tar zxvf mysqld_exporter-0.13.0-rc.0.linux-amd64.tar.gz -C /opt/prometheus-2.26/
      mv /opt/prometheus-2.26/mysqld_exporter-0.13.0-rc.0.linux-amd64/ /opt/prometheus-2.26/mysqld_exporter/
      
    • Configure MySQL user authorization

      mysql -uroot -p
      SHOW VARIABLES LIKE 'validate_password%';
      set global validate_password_policy=LOW; 
      set global validate_password_length=6;
      # 授权
      GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost' IDENTIFIED BY '123456' WITH MAX_USER_CONNECTIONS 3;
      flush privileges;
      
      • DDL: Data Definition Language: Building Databases and Tables
      • DML: data manipulation language: add, delete, modify
      • DQL: Data Query Language: Query
      • DCL:grant、revoke
    • registration service

      vim /etc/systemd/system/mysqld_exporter.service
      
      [Unit]
      Description=mysqld_exporter
      Documentation=Prometheus mysql exporter plugin
      
      [Service]
      Type=simple
      User=mysql
      Environment=DATA_SOURCE_NAME=mysql_exporter:123456@(localhost:3306)/
      ExecStart=/opt/prometheus-2.26/mysqld_exporter/mysqld_exporter --config.my-cnf /etc/my.cnf \
        --collect.slave_status \
        --collect.slave_hosts \
        --log.level=error \
        --collect.info_schema.processlist \
        --collect.info_schema.innodb_metrics \
        --collect.info_schema.innodb_tablespaces \
        --collect.info_schema.innodb_cmp \
        --collect.info_schema.innodb_cmpmem 
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
      
    • start service

      # 设置开机自启动
      systemctl enable mysqld_exporter
      # 启动服务
      systemctl start mysqld_exporter
      # 查看服务状态
      systemctl status mysqld_exporter
      
    • Configure Prometheus

      vim /opt/prometheus-2.26/prometheus.yml
      
      scrape_configs:
        # 增加以下内容
        - job_name: 'mysql'
          scrape_interval: 1s
          static_configs:
          - targets: ['localhost:9104']
            labels:
              instance: 'mysqld_exporter'
      
      • restart prometheus

        systemctl restart prometheus.service
        
    • verify

      • mysql_exporter_collector_duration_seconds

        image-20211005202253808

  • summary

    • Realize the installation and monitoring of MySQL indicators of mysqld_exportor plug-in

Guess you like

Origin blog.csdn.net/xianyu120/article/details/132326851
Recommended