In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install centos7.8 prometheus and grafana, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Installation preparation
Virtual machines: centos7.8 2
In this practice, two virtual machines with centos7.8 installed are used as the practice environment to install prometheus2.8.1 and grafana, and the monitoring of these two hosts is configured in prometheus.
The specific installation plan is as follows:
Hostname
Ip
Os
Cpu
Memory
Disk
Remarks
Prometheus-host
172.22.3.148
Centos7.8
2c
2g
20g
Prometheus
Grafana
Node_exporter
Prometheus-node
172.22.3.149
Centos7.8
2c
2g
20g
Node_exporter
Related installation files
Https://github.com/prometheus/prometheus/releases/download/v2.24.0/prometheus-2.24.0.linux-amd64.tar.gzhttps://dl.grafana.com/oss/release/grafana-7.3.6-1.x86_64.rpmhttps://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
Note: if not specified, the following deployments are all deployed in prometheus-host
Install prometheus
download
# cd / opt# wget https://github.com/prometheus/prometheus/releases/download/v2.8.1/prometheus-2.8.1.linux-amd64.tar.gz
Installation
# cd / opt# tar-zxf prometheus-2.8.1.linux-amd64.tar.gz# mv prometheus-2.8.1.linux-amd64 prometheus
Start
# cd / opt/prometheus#. / prometheus
Create a service and set up automatic startup
# # create service# vi / usr/lib/systemd/system/prometheus.service [Unit] Description=prometheusDocumentation= https://prometheus.io/After=network.target[Service]Type=simpleUser=rootGroup=rootExecStart=/opt/prometheus/prometheus-- config.file=/opt/prometheus/prometheus.ymlRestart=on-failure [Install] WantedBy=multi-user.target# systemctl daemon-reload## setup self-launch # systemctl enable prometheusCreated symlink from / etc/systemd/system/multi-user.target.wants/prometheus.service to / usr/lib/systemd/system/prometheus.service.## launch Service # systemctl start prometheus
Visit prometheus
Enter http://172.22.3.148:9090 in the browser address bar
Install grafana
download
# cd / opt# wget https://dl.grafana.com/oss/release/grafana-7.3.6-1.x86_64.rpm
Installation
# cd / opt# yum install grafana-7.3.6-1.x86_64.rpm
Start
# # servicesystemctl daemon-reloadsystemctl start grafana-server of grafana-server is automatically generated after installation
Set up automatic start
# # setting self-booting # systemctl enable grafana-server
Access grafana and configure the default data source
Enter http://172.22.3.148:3000 in the browser address bar
Log in with the default username password admin/admin
You need to set a new password after logging in for the first time as above.
Data sources need to be configured after granfa installation
Select Prometheus and click Select
Just set URL to http://localhost:9090
Others remain by default, just click the "Save & Test" button directly.
Pop up a prompt to save successfully, and click the "Back" button to return.
You can see that grafana has saved a data source.
Install node_exporter and configure host monitoring with prometheus
download
# cd / usr/local# wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
Installation
# cd / usr/local# tar-zxf node_exporter-1.0.1.linux-amd64.tar.gz# mv node_exporter-1.0.1.linux-amd64/node_exporter. / bin/
Create a service and set up automatic startup
# # create service# vi / usr/lib/systemd/system/node_ exporter.service [unit] Description=node_exporterDocumentation= https://prometheus.io/After=network.target[Service]Type=simpleUser=rootGroup=rootExecStart=/usr/local/bin/node_exporterRestart=on-failure[Install]WantedBy=multi-user.target# systemctl daemon-reload## setup self-startup # systemctl enable node_exporterCreated symlink from / etc/systemd/system/multi-user.target.wants/node_exporter.service to / usr/lib/systemd/system/node_exporter.service.## launch service # systemctl start node_exporter
Configure host prometheus-host monitoring in prometheus
Modify the prometheus configuration file prometheus.yml and add the following configuration under scrape_configs
-job_name: 'prometheus-host' file_sd_configs:-files: [' / opt/prometheus/sd_config/prometheus-host.yml'] refresh_interval: 5s
Add / opt/prometheus/sd_config/prometheus-host.yml file, which is as follows
Cat / opt/prometheus/sd_config/prometheus-host.yml- targets:-172.22.3.149 9100
Note: use promtool to check whether the configuration file is correct each time the configuration is modified
# / opt/prometheus/promtool check config / opt/prometheus/prometheus.yml
Restart prometheus
# systemctl restart prometheus
Enter http://172.22.3.148:9090/targets in the browser address bar
You can see that targets has increased the monitoring of the host prometheus-host
Configure the panel to display the monitoring content of the host prometheus-host in grafana
Click the "+" button to pop up the import panel window
If you enter 8919 in the figure, click Load,grafana to import the panel numbered 8919 directly from the official website as follows
Select the data source Prometheus, continue with "Import", and display the node monitoring interface as follows
Install node_exporter in prometheus-nodes and configure host monitoring with prometheus
Installation steps refer to the steps to install node_exporter in prometheus-host
Configure host prometheus-nodes monitoring in prometheus
Modify the prometheus configuration file prometheus.yml and add the following configuration under scrape_configs
-job_name: 'prometheus-nodes' file_sd_configs:-files: [' / opt/prometheus/sd_config/prometheus-nodes.yml'] refresh_interval: 5s
Add / opt/prometheus/sd_config/prometheus-nodes.yml file, which is as follows
Cat / opt/prometheus/sd_config/prometheus-nodes.yml- targets:-172.22.3.148purl 9100
Restart prometheus
# systemctl restart prometheus
Enter http://172.22.3.148:9090/targets in the browser address bar
You can see that targets has increased the monitoring of the host prometheus-nodes
When you visit grafana, you can also see that prometheus-nodes is added to the node monitoring interface.
The above is all the contents of the article "how to install prometheus and grafana in centos7.8". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.