node_exporter、grafana 监控服务器系统资源

2021/6/26 22:29:17

本文主要是介绍node_exporter、grafana 监控服务器系统资源,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

日萌社

人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新)


1.node_exporter下载:
	https://prometheus.io/download/

2.修改prometheus配置文件
	job_name: 'prometheus':prometheus配置
	job_name: 'pushgateway':pushgateway配置
	job_name: 'node1':node_exporter在master节点的配置
	job_name: 'node2':node_exporter在slave1节点的配置
	job_name: 'node3':node_exporter在slave2节点的配置
 
	vim /home/hadoop/prometheus/prometheus.yml
		# A scrape configuration containing exactly one endpoint to scrape:
		# Here it's Prometheus itself.
		scrape_configs:
		  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
		  - job_name: 'prometheus'
			# metrics_path defaults to '/metrics'
			# scheme defaults to 'http'.
			static_configs:
			- targets: ['xxx.xxx.xx.xx:9090']
			  labels:
				instance: 'prometheus'
			
		  - job_name: 'pushgateway'
			static_configs:
			- targets: ['xxx.xxx.xx.xx:9091']
			  labels:
				instance: 'pushgateway'
 
		  - job_name: 'slave2'
			static_configs:
			- targets: ['xxx.xxx.xx.xx:9100']
			  labels:
				instance: 'slave2'

		  - job_name: 'slave1'
			static_configs:
			- targets: ['xxx.xxx.xx.xx:9100']
			  labels:
				instance: 'slave1'

		  - job_name: 'master'
			static_configs:
			- targets: ['xxx.xxx.xx.xx:9100']
			  labels:
				instance: 'master'
3.多台机器 每台机器都 安装和启动 node_exporter
	tar zxvf node_exporter-1.0.1.linux-amd64.tar.gz
	mv node_exporter-1.0.1.linux-amd64 node_exporter
	cd /home/hadoop/node_exporter
	./node_exporter &(用了&之后即启动了之后再按一次回车就可以退出打印台)
	ps aux|grep node_exporter
	netstat -anp |grep 9100	
	http://每台机器的IP:9100(查看UI界面)

4.启动 prometheus 
	cd /home/hadoop/prometheus
	./prometheus --config.file=prometheus.yml &(用了&之后即启动了之后再按一次回车就可以退出打印台)
	http://xxx.xxx.xx.xx:9090 打开UI界面
	ps aux|grep prometheus 
	netstat -anp |grep 9090

5.下载 dashboards 仪表盘:Node Exporter for Prometheus Dashboard CN

6.安装 grafana
	tar zxvf grafana-7.1.0.linux-amd64.tar.gz
	mv grafana-7.1.0 grafana
	cd /home/hadoop/grafana

  启动 grafana
	cd /home/hadoop/grafana/bin
	./grafana-server &(用了&之后即启动了之后再按一次回车就可以退出打印台)
	./grafana-server -config="/home/hadoop/grafana/conf/defaults.ini"
	ps aux|grep grafana-server
	netstat -anp |grep 3000
	
  登录 grafana
	http://xxx.xxx.xx.xx:3000 使用默认用户名密码(admin/admin)

  登录报错1:
	Unauthorized
	Invalid or expired reset password code
	path=/api/user/password/reset status=400
	path=/api/user/password status=401
	
  登录报错2:
	grafana登录页面 输入账号密码后又回到登录界面

  解决:
	设置免密码免用户登录,并且是Admin权限登录
	vim /home/hadoop/grafana/conf/defaults.ini
		[auth.anonymous]
		#启用匿名访问
		enabled = true  #默认false
		#为未经身份验证的用户指定角色
		org_role = Admin #默认Viewer



这篇关于node_exporter、grafana 监控服务器系统资源的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程