node_exporter installation tutorial

1. Download the node_exporter binary file compression package

1. Execute the command download on the node 

wget "https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz" 

 2. Unzip the compressed package

[root@master node_exporter]# ls
node_exporter-1.5.0.linux-amd64.tar.gz
[root@master node_exporter]# tar -xvf node_exporter-1.5.0.linux-amd64.tar.gz
[root@master node_exporter]# ls
node_exporter-1.5.0.linux-amd64  node_exporter-1.5.0.linux-amd64.tar.gz

2. Copy the node_exporter binary file in the node_exporter-1.5.0.linux-amd64 directory to the /usr/local/bin path

[root@master node_exporter]# cd node_exporter-1.5.0.linux-amd64
[root@master node_exporter-1.5.0.linux-amd64]# ls
LICENSE  node_exporter  NOTICE
[root@master node_exporter-1.5.0.linux-amd64]# cp node_exporter  /usr/local/bin/
[root@master node_exporter-1.5.0.linux-amd64]# ls -l /usr/local/bin/node_exporter
-rwxr-xr-x 1 root root 19779640 Jan 30 10:57 /usr/local/bin/node_exporter

3. Create a systemd service file 

Modify the Environment configuration value according to the actual situation.
If the authentication parameters in the command to create a user are not modified in the previous step,
the following does not need to be changed.
Just copy all the text commands below and execute them on the node.

cat <<EOF > /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target 

[Service]
ExecStart=/usr/local/bin/node_exporter\
          --web.listen-address=:9100\
          --collector.systemd\
          --collector.systemd.unit-whitelist=(sshd|nginx).service\
          --collector.processes\
          --collector.tcpstat

[Install]
WantedBy=multi-user.target
EOF

4. Overload system systemd configuration 

执行命令:systemctl daemon-reload

5. Start the service and set the service to start automatically

[root@master node_exporter]# systemctl enable --now node_exporter
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service.

6. Check the running status of the service

Execute the command
to get echo results similar to the following
, mainly depending on the Active attribute value
and the prompts in the log:systemctl status node_exporter active(running)Listening on :9104

systemctl status node_exporter
● node_exporter.service - node_exporter
   Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-01-30 11:02:34 CST; 41s ago
 Main PID: 77865 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─77865 /usr/local/bin/node_exporter --web.listen-address=:9100 --collector.systemd --collector.systemd.unit-whitelist=(sshd|nginx).service --collector.processes --collector.tcpstat

7. Test interface

Use the command access interface on the node
to get a result similar to the following: curl -s { {节点IP}}:9100/metrics

[root@master ~]#curl -s 10.82.42.193:9100/metrics 
......
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 0
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
......

 Or directly use the browser to access and see the relevant mysqld instance indicator information, which is normal{ {节点IP}}:9100/metrics

Guess you like

Origin blog.csdn.net/summer_fish/article/details/128798749