Configuring a Node

  • Default ports of each component
Default node port: 9100 Default mysql port: 9104 Default redis port: 9121 Default Process port: 9256 Default AlertManager port: 9093Copy the code

Operates as a system monitor at the system level

  • Also download and upload the binary package on the official website first

  • Unzip and start

[root@prometheus_node01 ~]# tar xf node_exi-0.18.1.linux-amd64.tar. gz -c /usr/local/[root@prometheus_node01 ~]# ln -sv /usr/local/node_xxx. Linux -amd64 /usr/local/prometheus_node / [root@prometheus_node01 ~]# nohup /usr/local/Prometheus_node/node_exporter &Copy the code
  • Configure Systemd to start node_exporter
[root@prometheus_node01 ~]# vim /lib/systemd/system/node_exporter.service [Unit] Description=Node_exporter After=network.target [Service] ExecStart=/usr/local/Prometheus_node/node_exporter [Install] WantedBy=multi-user.target # [root@prometheus_node01 ~]# systemctl daemon-reload [root@prometheus_node01 ~]# systemctl start node_exporter [root@prometheus_node01 ~]# systemctl enable node_exporterCopy the code
  • Add the job task on the server of Prometheus
[root@prometheus ~]# vim /usr/local/Prometheus/prometheus/prometheus.yml - job_name: 'node_exporter' static_configs: -targets: [172.16.214.140:9100]Copy the code

To refresh the Targets on the monitoring interface, the red down of the node changes to green Up, indicating that the configuration is successful.

Configure the mysql_exporter component

  • To download and upload the binary package, run the following command:
[root@prometheus_mysqld ~]# tar xf mysqLD_support-0.12.1.linux-amd64.tar. gz -c /usr/local/[root@prometheus_mysqld ~]# Ln - sv/usr/local/mysqld_exporter - 0.12.1. Linux - amd64 / / usr/local/Prometheus_mysqldCopy the code
  • Used as a monitoring user in mysql and authorized
mysql> CREATE USER 'mysqld_exporter'@'%' IDENTIFIED BY 'mysqld_exporter'; mysql> GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysqld_exporter'@'%' identified by 'mysqld_exporter'; mysql> GRANT SELECT ON *.* TO 'mysqld_exporter'@'%'; # If the prompt password is too simple, make it more complex, or cancel the password responsibility ruleCopy the code
  • Write a configuration file for mysqLD_EXPORTER
[root@prometheus_mysqld ~]# vim /usr/local/Prometheus_mysqld/.my.cnf
[client]
user=mysqld_exporter
password=mysqld_exporter
port=3307
Copy the code
  • Start the mysqLD_exporter component
[root@prometheus_mysqld ~]# nohup /usr/local/Prometheus_mysqld/mysqld_exporter --config.my-cnf=/usr/local/Prometheus_mysqld/.my.cnf &
Copy the code

Go to the Targets TAB on the monitoring page and refresh the information. If down changes to Up, the monitored object on this node is successfully configured.

  • Configure systemd to start mysqLD_exporter
[root@prometheus_mysqld ~]# vim /lib/systemd/system/mysqld_exporter.service [Unit] Description=Mysqld_exporter After=network.target [Service] ExecStart=/usr/local/Prometheus_mysqld/mysqld_exporter --config.my-cnf=/usr/local/ prometheus_mysql/.my. CNF [Install] WantedBy=multi-user [root@prometheus_mysqld ~]# systemctl daemon-reload [root@prometheus_mysqld ~]# systemctl start mysqld_exporter [root@prometheus_mysqld ~]# systemctl enable mysqld_exporterCopy the code
  • Add the job task on the server of Prometheus
[root@prometheus ~]# vim /usr/local/Prometheus/prometheus/prometheus.yml - job_name: 'node_mysqld' static_configs: -targets: [172.16.214.140:9104]Copy the code

Configure the redis_exporter component

  • Download address
Wget HTTP: / / https://github.com/oliver006/redis_exporter/releases/download/v1.3.4/redis_exporter-v1.3.4.linux-amd64.tar.gzCopy the code

To install a specified historical version, click here to enter the redis_exporter component library

  • Json package download address
https://grafana.com/api/dashboards/763/revisions/1/download
Copy the code
  • Configuration redis_exporter
[root@prometheus_redis ~]# tar xf redis_exi-v1.3.4.linux-amd64.tar. gz -c /usr/local/[root@prometheus_redis ~]# ln Linux -amd64/ /usr/local/Prometheus_redis [root@prometheus_redis ~]# nohup /usr/local/Prometheus_redis/redis_exporter redis//localhost:6379 -web.listenaddress 0.0.0.0:9121&Copy the code
  • Configure systemd to start redis_exporter
[root@prometheus_redis ~]# vim /lib/systemd/system/redis_exporter.service [Unit] Description=Redis_exporter After=network.target [Service] ExecStart=/usr/local/Prometheus_redis/redis_exporter redis//localhost:6379 -web. Listenaddress 0.0.0.0:9121 [Install] WantedBy=multi-user. Target daemon-reload [root@prometheus_redis ~]# systemctl start redis_exporter [root@prometheus_redis ~]# systemctl enable redis_exporterCopy the code
  • Add the job task on the server of Prometheus
[root@prometheus ~]# vim /usr/local/Prometheus/prometheus/prometheus.yml - job_name: 'node_redis' static_configs: -targets: [172.16.214.140:9121]Copy the code

Configuration process – exporter

  • Download address
Wget HTTP: / / https://github.com/ncabatoff/process-exporter/releases/download/v0.4.0/process-exporter-0.4.0.linux-amd64.tar.gzCopy the code
  • Configuration file path
[root@prometheus ~]# tar xf process-exi-0.4.0.linux-amd64.tar. gz -c /usr/local/[root@prometheus ~]# ln-sv / usr/local/process - exporter - 0.4.0. Linux - amd64 / / usr/local/Prometheus_processCopy the code
  • Modifying a Configuration File
[root@prometheus ~]# vim /usr/local/Prometheus_process/process-exporter-ncabatoff.yaml
process_names:
  - name: "{{.Matches}}"
    cmdline:
    - 'redis-server'
  - name: "{{.Matches}}"
    cmdline:
    - 'mysqld'
  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.zookeeper.server.quorum.QuorumPeerMain'
  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer'
  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.hadoop.hdfs.qjournal.server.JournalNode'
Copy the code

Note CMdline: unique identifier of the selected process. You can query it from ps -ef. If the process does not exist, no data is collected for the process.

  • To start the process – exporter
[root@prometheus ~]# nohup /usr/local/Prometheus_process/process-exporter -config.path=/usr/local/Prometheus_process/process-exporter-ncabatoff.yaml  &
Copy the code
  • Configure Systemd to start process-exporter
[root@prometheus_redis ~]# vim /lib/systemd/system/process-exporter.service [Unit] Description=Redis_exporter After=network.target [Service] ExecStart=/usr/local/Prometheus_process/process-exporter -config.path=/usr/local/Prometheus_process/process-exporter-ncabatoff.yaml [Install] WantedBy=multi-user.target # [root@prometheus_redis ~]# systemctl daemon-reload [root@prometheus_redis ~]# systemctl start process-exporter [root@prometheus_redis ~]# systemctl enable process-exporterCopy the code
  • Add the job task on the server of Prometheus
/ root @ Prometheus ~ # vim/usr/local/Prometheus Prometheus/Prometheus. Yml - job_name: 'process' static_configs: - the targets: [' 192.168.137.128:9256]Copy the code

extension

  • The export component modifies the listening port
If you need to modify the listening port of the export component or other configuration, it is recommended to use --help to check the configuration parameters. mysqld_exporter [<flags>] Flags: -h, --help Show context-sensitive help (also try --help-long and --help-man). --web.listen-address=":9104" Address to listen On web interface and Telemetry. # example /usr/local/prometheus_node /node_exporter --web.listen-address=":9200"Copy the code