IT基础设施:使用netdata监控CentOS7性能

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介: 背景作为一个Linux狗,必须要掌握一个专门的系统监控工具,能随时了解系统资源的占用情况,如应用的内存使用规律,应用的网络峰值时段,CPU使用情况等信息,对优化应用性能,保证服务器健康运行有着极为重要的作用。

背景

作为一个Linux狗,必须要掌握一个专门的系统监控工具,能随时了解系统资源的占用情况,如应用的内存使用规律,应用的网络峰值时段,CPU使用情况等信息,对优化应用性能,保证服务器健康运行有着极为重要的作用。

工具

netdata

Netdata是一款秒级数据收集与可视化呈现的Linux服务器性能监测工具,他具有这样一些特性:

  • 高实时性:Netdata是用纯C编写的,关键系统插件也是用C语言编写的。 它的速度只能与本机控制台系统管理工具进行比较。当netdata在现代计算机上运行时(即使在CELERON处理器上),大多数图表查询都会在不到3毫秒的时间内得到回复!
  • 不占用系统IO:除了日志系统外,netdata将不会使用任何磁盘的IO资源,您也可以通过配置文件禁用掉日志系统。
  • 不需要root权限
  • 自带Web服务系统
  • 开箱即用,上手不需要写任何配置
  • 可视化的QOS
  • 安装便捷,根据安装文档指示,有些系统可以直接从软件库中安装,树莓派上我通过克隆安装成功,CentOS上有一键安装脚本
  • 告警系统,通过配置文件,我们可以配置netdata在某些指标达到阀值的时候进行告警。

nginx

鼎鼎大名的代理服务器,不用多说。

过程

本次安装的机器是CentOS7 64位,我们选择64位的安装脚本

bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh) 

接下来它会自动下载安装包

 --- Checking the latest version of static build... --- 
[/home]# /usr/bin/curl https://raw.githubusercontent.com/firehol/binary-packages/master/netdata-latest.gz.run 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    59  100    59    0     0     51      0  0:00:01  0:00:01 --:--:--    51
 OK   

 --- Downloading static netdata binary: netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run --- 
[/home]# /usr/bin/curl https://raw.githubusercontent.com/firehol/binary-packages/master/netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 5602k  100 5602k    0     0  19712      0  0:04:51  0:04:51 --:--:-- 32001
 OK   

 --- Installing netdata --- 
[/home]# sh /tmp/netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run 

  ^
  |.-.   .-.   .-.   .-.   .  netdata                                        
  |   '-'   '-'   '-'   '-'   real-time performance monitoring, done right!  
  +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->

  (C) Copyright 2017, Costa Tsaousis
  All rights reserved
  Released under GPL v3+

  You are about to install netdata to this system.
  netdata will be installed at:

                    /opt/netdata

  The following changes will be made to your system:

  # USERS / GROUPS
  User 'netdata' and group 'netdata' will be added, if not present.

  # LOGROTATE
  This file will be installed if logrotate is present.

   - /etc/logrotate.d/netdata

  # SYSTEM INIT
  This file will be installed if this system runs with systemd:

   - /etc/systemd/system/netdata.service 

   or, for older Centos, Debian/Ubuntu or OpenRC Gentoo:

   - /etc/init.d/netdata         will be created

  
  This package can also update a netdata installation that has been
  created with another version of it.

  Your netdata configuration will be retained.
  After installation, netdata will be (re-)started.

  netdata re-distributes a lot of open source software components.
  Check its full license at:
  https://github.com/firehol/netdata/blob/master/LICENSE.md
Please type y to accept, n otherwise: 

输入y确认安装,下面列出了详细的安装过程。

Creating directory /opt/netdata
Verifying archive integrity...  100%   All good.
Uncompressing netdata, the real-time performance and health monitoring system  100%  
 --- Checking new configuration files --- 
[/opt/netdata]# mkdir -p etc/netdata 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d.conf etc/netdata/node.d.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/health.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/nginx.conf etc/netdata/health.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_listen.conf etc/netdata/health.d/tcp_listen.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/zfs.conf etc/netdata/health.d/zfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/apache.conf etc/netdata/health.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/named.conf etc/netdata/health.d/named.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/nginx_plus.conf etc/netdata/health.d/nginx_plus.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/squid.conf etc/netdata/health.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/udp_errors.conf etc/netdata/health.d/udp_errors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_resets.conf etc/netdata/health.d/tcp_resets.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/portcheck.conf etc/netdata/health.d/portcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/elasticsearch.conf etc/netdata/health.d/elasticsearch.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ceph.conf etc/netdata/health.d/ceph.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/isc_dhcpd.conf etc/netdata/health.d/isc_dhcpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/bcache.conf etc/netdata/health.d/bcache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/qos.conf etc/netdata/health.d/qos.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/stiebeleltron.conf etc/netdata/health.d/stiebeleltron.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/retroshare.conf etc/netdata/health.d/retroshare.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mysql.conf etc/netdata/health.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/beanstalkd.conf etc/netdata/health.d/beanstalkd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/postgres.conf etc/netdata/health.d/postgres.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_orphans.conf etc/netdata/health.d/tcp_orphans.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/haproxy.conf etc/netdata/health.d/haproxy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/entropy.conf etc/netdata/health.d/entropy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/cpu.conf etc/netdata/health.d/cpu.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipfs.conf etc/netdata/health.d/ipfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/varnish.conf etc/netdata/health.d/varnish.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/disks.conf etc/netdata/health.d/disks.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_conn.conf etc/netdata/health.d/tcp_conn.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/btrfs.conf etc/netdata/health.d/btrfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/lighttpd.conf etc/netdata/health.d/lighttpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/net.conf etc/netdata/health.d/net.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/softnet.conf etc/netdata/health.d/softnet.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/redis.conf etc/netdata/health.d/redis.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/web_log.conf etc/netdata/health.d/web_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/memory.conf etc/netdata/health.d/memory.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipmi.conf etc/netdata/health.d/ipmi.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ram.conf etc/netdata/health.d/ram.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/netfilter.conf etc/netdata/health.d/netfilter.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_mem.conf etc/netdata/health.d/tcp_mem.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mongodb.conf etc/netdata/health.d/mongodb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/boinc.conf etc/netdata/health.d/boinc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/swap.conf etc/netdata/health.d/swap.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/backend.conf etc/netdata/health.d/backend.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipc.conf etc/netdata/health.d/ipc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/fronius.conf etc/netdata/health.d/fronius.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/apcupsd.conf etc/netdata/health.d/apcupsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mdstat.conf etc/netdata/health.d/mdstat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/couchdb.conf etc/netdata/health.d/couchdb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/memcached.conf etc/netdata/health.d/memcached.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/megacli.conf etc/netdata/health.d/megacli.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/fping.conf etc/netdata/health.d/fping.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/httpcheck.conf etc/netdata/health.d/httpcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/bind_rndc.conf etc/netdata/health.d/bind_rndc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d.conf etc/netdata/python.d.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health_alarm_notify.conf etc/netdata/health_alarm_notify.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health_email_recipients.conf etc/netdata/health_email_recipients.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/apps_groups.conf etc/netdata/apps_groups.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/python.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nginx.conf etc/netdata/python.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dovecot.conf etc/netdata/python.d/dovecot.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/apache.conf etc/netdata/python.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/exim.conf etc/netdata/python.d/exim.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/rabbitmq.conf etc/netdata/python.d/rabbitmq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/spigotmc.conf etc/netdata/python.d/spigotmc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nginx_plus.conf etc/netdata/python.d/nginx_plus.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/squid.conf etc/netdata/python.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/w1sensor.conf etc/netdata/python.d/w1sensor.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/tomcat.conf etc/netdata/python.d/tomcat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/fail2ban.conf etc/netdata/python.d/fail2ban.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/postfix.conf etc/netdata/python.d/postfix.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/powerdns.conf etc/netdata/python.d/powerdns.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ntpd.conf etc/netdata/python.d/ntpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/portcheck.conf etc/netdata/python.d/portcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dns_query_time.conf etc/netdata/python.d/dns_query_time.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/elasticsearch.conf etc/netdata/python.d/elasticsearch.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/freeradius.conf etc/netdata/python.d/freeradius.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ceph.conf etc/netdata/python.d/ceph.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/isc_dhcpd.conf etc/netdata/python.d/isc_dhcpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nsd.conf etc/netdata/python.d/nsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/logind.conf etc/netdata/python.d/logind.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/samba.conf etc/netdata/python.d/samba.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/retroshare.conf etc/netdata/python.d/retroshare.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/phpfpm.conf etc/netdata/python.d/phpfpm.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mysql.conf etc/netdata/python.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/smartd_log.conf etc/netdata/python.d/smartd_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/postgres.conf etc/netdata/python.d/postgres.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/haproxy.conf etc/netdata/python.d/haproxy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/cpufreq.conf etc/netdata/python.d/cpufreq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ipfs.conf etc/netdata/python.d/ipfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/varnish.conf etc/netdata/python.d/varnish.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/hddtemp.conf etc/netdata/python.d/hddtemp.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/puppet.conf etc/netdata/python.d/puppet.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/unbound.conf etc/netdata/python.d/unbound.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/redis.conf etc/netdata/python.d/redis.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/web_log.conf etc/netdata/python.d/web_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dnsdist.conf etc/netdata/python.d/dnsdist.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mongodb.conf etc/netdata/python.d/mongodb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/boinc.conf etc/netdata/python.d/boinc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/springboot.conf etc/netdata/python.d/springboot.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/litespeed.conf etc/netdata/python.d/litespeed.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/icecast.conf etc/netdata/python.d/icecast.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/example.conf etc/netdata/python.d/example.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mdstat.conf etc/netdata/python.d/mdstat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/couchdb.conf etc/netdata/python.d/couchdb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/chrony.conf etc/netdata/python.d/chrony.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/memcached.conf etc/netdata/python.d/memcached.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/megacli.conf etc/netdata/python.d/megacli.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/traefik.conf etc/netdata/python.d/traefik.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/httpcheck.conf etc/netdata/python.d/httpcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ovpn_status_log.conf etc/netdata/python.d/ovpn_status_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/sensors.conf etc/netdata/python.d/sensors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/bind_rndc.conf etc/netdata/python.d/bind_rndc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/go_expvar.conf etc/netdata/python.d/go_expvar.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/beanstalk.conf etc/netdata/python.d/beanstalk.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d.conf etc/netdata/charts.d.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/stream.conf etc/netdata/stream.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/statsd.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/statsd.d/example.conf etc/netdata/statsd.d/example.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/node.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/named.conf.md etc/netdata/node.d/named.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/README.md etc/netdata/node.d/README.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/sma_webbox.conf.md etc/netdata/node.d/sma_webbox.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/stiebeleltron.conf.md etc/netdata/node.d/stiebeleltron.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/snmp.conf.md etc/netdata/node.d/snmp.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/fronius.conf.md etc/netdata/node.d/fronius.conf.md 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/charts.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/nginx.conf etc/netdata/charts.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/nut.conf etc/netdata/charts.d/nut.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/libreswan.conf etc/netdata/charts.d/libreswan.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/apache.conf etc/netdata/charts.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/exim.conf etc/netdata/charts.d/exim.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/squid.conf etc/netdata/charts.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/tomcat.conf etc/netdata/charts.d/tomcat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/postfix.conf etc/netdata/charts.d/postfix.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/phpfpm.conf etc/netdata/charts.d/phpfpm.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/mysql.conf etc/netdata/charts.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/cpufreq.conf etc/netdata/charts.d/cpufreq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/hddtemp.conf etc/netdata/charts.d/hddtemp.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/cpu_apps.conf etc/netdata/charts.d/cpu_apps.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/load_average.conf etc/netdata/charts.d/load_average.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/opensips.conf etc/netdata/charts.d/opensips.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/apcupsd.conf etc/netdata/charts.d/apcupsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/example.conf etc/netdata/charts.d/example.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/mem_apps.conf etc/netdata/charts.d/mem_apps.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/ap.conf etc/netdata/charts.d/ap.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/sensors.conf etc/netdata/charts.d/sensors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/fping.conf etc/netdata/fping.conf 
 OK   

[/opt/netdata]# rm -rf etc.new 
 OK   

 --- Add user netdata to required user groups --- 
Adding netdata user group ...
[/opt/netdata]# groupadd -r netdata 
 OK   

Adding netdata user account with home /opt/netdata ...
[/opt/netdata]# useradd -r -g netdata -c netdata -s /usr/sbin/nologin --no-create-home -d /opt/netdata netdata 
 OK   

Group 'docker' does not exist.
Adding netdata user to the nginx group ...
[/opt/netdata]# usermod -a -G nginx netdata 
 OK   

Group 'varnish' does not exist.
Group 'haproxy' does not exist.
Adding netdata user to the adm group ...
[/opt/netdata]# usermod -a -G adm netdata 
 OK   

Group 'nsd' does not exist.
Group 'proxy' does not exist.
Group 'squid' does not exist.
Group 'ceph' does not exist.
Adding netdata user to the nobody group ...
[/opt/netdata]# usermod -a -G nobody netdata 
 OK   

 --- Check SSL certificates paths --- 
Creating /opt/netdata/.curlrc with cacert=/etc/ssl/certs/ca-bundle.crt
 --- Install logrotate configuration for netdata --- 
[/opt/netdata]# cp system/netdata.logrotate /etc/logrotate.d/netdata 
 OK   

[/opt/netdata]# chmod 644 /etc/logrotate.d/netdata 
 OK   

 --- Install netdata at system init --- 
Installing systemd service...
[/opt/netdata]# cp system/netdata.service /etc/systemd/system/netdata.service 
 OK   

[/opt/netdata]# systemctl daemon-reload 
 OK   

[/opt/netdata]# systemctl enable netdata 
Created symlink from /etc/systemd/system/multi-user.target.wants/netdata.service to /etc/systemd/system/netdata.service.
 OK   

 --- creating quick links --- 
[/opt/netdata]# ln -s bin sbin 
 OK   

[/opt/netdata/usr]# ln -s ../bin bin 
 OK   

[/opt/netdata/usr]# ln -s ../bin sbin 
 OK   

[/opt/netdata/usr]# ln -s . local 
 OK   

[/opt/netdata]# ln -s etc/netdata netdata-configs 
 OK   

[/opt/netdata]# ln -s usr/share/netdata/web netdata-web-files 
 OK   

[/opt/netdata]# ln -s usr/libexec/netdata netdata-plugins 
 OK   

[/opt/netdata]# ln -s var/lib/netdata netdata-dbs 
 OK   

[/opt/netdata]# ln -s var/cache/netdata netdata-metrics 
 OK   

[/opt/netdata]# ln -s var/log/netdata netdata-logs 
 OK   

 --- fix permissions --- 
[/opt/netdata]# chmod g+rx\,o+rx /opt 
 OK   

[/opt/netdata]# chown -R netdata:netdata /opt/netdata 
 OK   

 --- fix plugin permissions --- 
[/opt/netdata]# chown root:netdata usr/libexec/netdata/plugins.d/apps.plugin 
 OK   

[/opt/netdata]# chmod 4750 usr/libexec/netdata/plugins.d/apps.plugin 
 OK   

[/opt/netdata]# chown root:netdata usr/libexec/netdata/plugins.d/cgroup-network 
 OK   

[/opt/netdata]# chmod 4750 usr/libexec/netdata/plugins.d/cgroup-network 
 OK   

[/opt/netdata]# chown root:netdata bin/fping 
 OK   

[/opt/netdata]# chmod 4750 bin/fping 
 OK   

 --- starting netdata --- 
 --- Start netdata --- 
[/opt/netdata]# /usr/bin/systemctl stop netdata 
 OK   

[/opt/netdata]# /usr/bin/systemctl restart netdata 
 OK   


-------------------------------------------------------------------------------

Downloading default configuration from netdata...
[/opt/netdata]# curl -s -o /opt/netdata/etc/netdata/netdata.conf.new http://localhost:19999/netdata.conf 
 OK   

[/opt/netdata]# mv /opt/netdata/etc/netdata/netdata.conf.new /opt/netdata/etc/netdata/netdata.conf 
 OK   

 OK  New configuration saved for you to edit at /opt/netdata/etc/netdata/netdata.conf 

[/opt/netdata]# chown netdata:netdata /opt/netdata/etc/netdata/netdata.conf 
 OK   

[/opt/netdata]# chmod 0664 /opt/netdata/etc/netdata/netdata.conf 
 OK   


  ^
  |.-.   .-.   .-.   .-.   .-.   .  netdata                          .-.   .-
  |   '-'   '-'   '-'   '-'   '-'   is installed and running now!  -'   '-'  
  +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->

 OK   


安装后默认是通过http://xxx:19999/访问

由于netdata没有帐号密码体系,为保护服务器隐私,我们要使用nginx反代,通过域名访问,并使用账号密码授权。

首先,我们安装apache工具集,我们需要其中的htpasswd为我们生成用户信息(PS:网上找到的资料是apache2-utils,但我们在CentOS7的源中已经搜索不到这个包)。

yum install httpd-tools -y

安装过程如下:

Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos.1 will be installed
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-80.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-80.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================
 Package                              Arch                            Version                                        Repository                        Size
============================================================================================================================================================
Installing:
 httpd-tools                          x86_64                          2.4.6-80.el7.centos.1                          updates                           90 k
Installing for dependencies:
 apr                                  x86_64                          1.4.8-3.el7_4.1                                os                               103 k
 apr-util                             x86_64                          1.5.2-6.el7                                    os                                92 k

Transaction Summary
============================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 285 k
Installed size: 584 k
Is this ok [y/d/N]: y
Downloading packages:
(1/3): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                               |  92 kB  00:00:00     
(2/3): apr-1.4.8-3.el7_4.1.x86_64.rpm                                                                                                | 103 kB  00:00:00     
(3/3): httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm                                                                                  |  90 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                       1.7 MB/s | 285 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                                                                                               1/3 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                                                              2/3 
  Installing : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                 3/3 
  Verifying  : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                 1/3 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                                              2/3 
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                                                                                               3/3 

Installed:
  httpd-tools.x86_64 0:2.4.6-80.el7.centos.1                                                                                                                

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                                                 apr-util.x86_64 0:1.5.2-6.el7                                                

Complete!

接下来创建目录,创建账号


mkdir /usr/local/nginx
htpasswd -c /usr/local/nginx/passwd.db username
pwd
re-type pwd

添加一个nginx的配置vim /etc/nginx/conf.d/netdata.conf,内容如下

upstream netdatahttp
{
        server 127.0.0.1:19999;
}

server {

  listen *:80;
  server_name netdata.xxx.com;
  auth_basic "netdata";
  auth_basic_user_file /usr/local/nginx/passwd.db;

  location /
  {
        proxy_pass http://netdatahttp;

        proxy_redirect off;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real_IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

打开域名测试一下效果

img_20cf60e6f363999505be23b2f3a3ecdb.png
要求输入账号密码

输入密码后

img_6fd04f1e885446bbb5574ee0ff43ce7b.png
总览
img_0762e0c49f3f3ca55708535a1e8b6164.png
应用的内存使用情况

引用

1.netdata官方安装指南
2.Running behind nginx(通过 nginx 保护 netdata)
3.netdata开源地址

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
监控 关系型数据库 MySQL
企业实战(8)CentOS 6.8安装Zabbix-agent 5.0监控主机性能与Mysql数据库
企业实战(8)CentOS 6.8安装Zabbix-agent 5.0监控主机性能与Mysql数据库
182 1
|
4月前
|
Linux
家族风云录:Red Hat与它的“调皮弟弟”CentOS,一场IT界的欢乐大戏 🎭
在IT界,Red Hat家族光芒四射,特别是RHEL这位稳重大哥,以卓越的安全性和稳定性守护企业级服务器。而CentOS则是家族里的调皮弟弟,继承RHEL的优点,以更亲民的姿态活跃在技术前沿。两者虽性格不同,却情谊深厚,共同书写着IT江湖的传奇故事。🌈👨‍👩‍👧‍👦🎉
60 0
|
6月前
|
弹性计算 安全 Cloud Native
Alibaba Cloud Linux镜像系统超好用!兼容CentOS生态,性能稳定性绝对可以!
Alibaba Cloud Linux是阿里云的自研Linux发行版,兼容CentOS/RHEL,提供长期免费支持。它针对云服务器ECS优化,适用于多种场景,如Web服务、云原生应用等。Alibaba Cloud Linux 3基于Anolis OS 8,提供安全、高性能、十年维护及丰富的开源生态。用户可在ECS购买时选择镜像安装,支持多架构并提供热补丁、解决方案和快速启动版。更换ECS操作系统是免费的。
801 5
|
7月前
|
存储 监控 Linux
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
【2月更文挑战第17天】Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
206 1
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
|
7月前
|
监控 网络协议 Unix
centos7 zabbix安装客户端agent -配置监控远程主机 在需要监控的电脑上安装
centos7 zabbix安装客户端agent -配置监控远程主机 在需要监控的电脑上安装
211 0
|
7月前
|
存储 监控 Linux
Ganglia【部署 01】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
Ganglia【部署 01】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
130 0
|
7月前
|
存储 监控 前端开发
zabbix概述及简单的在centos7安装Zabbix5.0及添加监控对象
Zabbix是一种开源的企业级监控解决方案,用于实时监控网络、服务器、应用程序等各种设备和服务的性能和可用性,并提供通知和报警功能。它具有灵活可扩展、可定制化的特点,可以满足不同规模和需求的监控需求。
423 0
|
监控 关系型数据库 MySQL
Zabbix分布式监控实战(二)——CentOS 7.5安装Zabbix-agent 5.0监控Mysql数据库
Zabbix分布式监控实战(二)——CentOS 7.5安装Zabbix-agent 5.0监控Mysql数据库
255 0
|
Prometheus 监控 Cloud Native
【实战】CentOS7 Prometheus+Grafana面板搭建+监控node_exporter+监控mysqld_exporter
有3台主机(CentOS7): 192.168.188.100 服务端 192.168.188.101 客户端 192.168.188.102 客户端 100部署Prometheus(9090)+Grafana(3000) 101部署node_exporter(39100)模块,监控该服务器所用资源情况 102部署mysqld_exporter(39200)模块,监控该服务器上的数据库使用情况
766 0