900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 安利一款 开源 实时的服务器监控工具:Netdata

安利一款 开源 实时的服务器监控工具:Netdata

时间:2023-05-29 20:40:13

相关推荐

安利一款 开源 实时的服务器监控工具:Netdata

Netdata 是一个免费、开源、实时的服务器监控工具,可以可视化和监控实时数据,如 CPU 使用率、RAM 使用率、负载、SWAP 使用率、带宽使用率、磁盘使用率等。它可以帮助系统管理员了解您的系统或应用程序中正在发生的事情以及刚刚发生的事情。它可以安装在任何物理服务器、虚拟机、容器和物联网设备上。它提供了一个交互式 Web 界面来查看您的服务器指标,并支持用于持久存储的各种数据存储。

在本教程中,我们将向您展示如何在 Alma Linux 8 上安装 Netdata 监控工具。

先决条件

运行 Alma Linux 8 的服务器。使用您的服务器 IP 指向的有效域名。在服务器上配置了 root 密码。

安装所需的依赖项

首先,您需要安装 EPEL 存储库和安装 Netdata 所需的其他依赖项,您可以通过运行以下命令来安装所有这些:

dnf install epel-release -ydnf install git libuuid-devel autoconf automake pkgconfig zlib-devel curl findutils libmnl gcc make -y

安装完所有软件包后,您可以继续下一步。

安装网络数据

默认情况下,Netdata 不包含在 Alma Linux 默认存储库中。因此,您需要从源代码安装它。

首先,使用以下命令从 Git 存储库下载最新版本的 Netdata:

git clone --recurse-submodules /netdata/netdata.git --depth=100

下载完成后,将目录更改为 netdata 并使用以下命令安装所有必需的依赖项:

cd netdata ./packaging/installer/install-required-packages.sh --non-interactive --dont-wait netdata

接下来,使用以下命令安装其他软件包:

dnf --enablerepo=powertools install libuv-devel

接下来,运行 Netdata 安装脚本开始安装。

./netdata-installer.sh

您将获得以下输出:

--- real-time performance monitoring, done right! --- You are about to build and install netdata to your system.The build process will use /tmp forany temporary files. You can override this by setting $TMPDIR to awritable directory where you can execute files.It will be installed at these locations:- the daemonat /usr/sbin/netdata- config files in /etc/netdata- web filesin /usr/share/netdata- plugins in /usr/libexec/netdata- cache files in /var/cache/netdata- db files in /var/lib/netdata- log filesin /var/log/netdata- pid file at /var/run/netdata.pid- logrotate file at /etc/logrotate.d/netdataThis installer allows you to change the installation path.Press Control-C and run the same command with --help for help.NOTE:Anonymous usage stats will be collected and sent to Netdata.To opt-out, pass --disable-telemetry option to the installer or exportthe environment variable DISABLE_TELEMETRY to a non-zero or non-empty value(e.g: export DISABLE_TELEMETRY=1).Press ENTER to build and install netdata to your system >

按 Enter 键将 Netdata 安装到您的系统。安装 Netdata 后,您将获得以下输出:

将 netdata.tarball.checksum 设置为“new_installation”

Setting netdata.tarball.checksum to 'new_installation'--- We are done! --- ^|.-. .-. .-. .-. .-. . netdata .-. .-. .-. .-. .-. .-| '-' '-' '-' '-' '-''-' '-' '-' '-' '-' +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->--- is installed and running now! --- enjoy real-time performance and health monitoring...

systemctl start netdatasystemctl enable netdata

您现在可以使用以下命令检查 Netdata 的状态。

systemctl status netdata

您将获得以下输出:

? netdata.service - Real time performance monitoringLoaded: loaded (/usr/lib/systemd/system/netdata.service; enabled; vendor preset: disabled)Active: active (running) since Sat -03-19 04:22:22 UTC; 4min 16s agoMain PID: 58935 (netdata)Tasks: 50 (limit: 11412)Memory: 103.1MCGroup: /system.slice/netdata.service??58935 /usr/sbin/netdata -P /var/run/netdata/netdata.pid -D??58938 /usr/sbin/netdata --special-spawn-server??59063 /usr/libexec/netdata/plugins.d/apps.plugin 1??59064 /usr/libexec/netdata/plugins.d/ebpf.plugin 1??59065 /usr/libexec/netdata/plugins.d/go.d.plugin 1Mar 19 04:22:22 linux systemd[1]: Starting Real time performance monitoring...Mar 19 04:22:22 linux systemd[1]: Started Real time performance monitoring.Mar 19 04:22:22 linux netdata[58935]: CONFIG: cannot load cloud config '/var/lib/netdata/cloud.d/cloud.conf'. Running with internal defaults.Mar 19 04:22:22 linux netdata[58935]: -03-19 04:22:22: netdata INFO : MAIN : CONFIG: cannot load cloud config '/var/lib/netdata/cloud.d/>Mar 19 04:22:22 linux netdata[58935]: -03-19 04:22:22: netdata INFO : MAIN : Found 0 legacy dbengines, setting multidb diskspace to 256MBMar 19 04:22:22 linux netdata[58935]: -03-19 04:22:22: netdata INFO : MAIN : Created file '/var/lib/netdata/dbengine_multihost_size' to >Mar 19 04:22:22 linux netdata[58935]: Found 0 legacy dbengines, setting multidb diskspace to 256MBMar 19 04:22:22 linux netdata[58935]: Created file '/var/lib/netdata/dbengine_multihost_size' to store the computed valueMar 19 04:22:23 linux ebpf.plugin[59064]: Does not have a configuration file inside `/etc/netdata/ebpf.d.conf. It will try to load stock file.Mar 19 04:22:23 linux ebpf.plugin[59064]: Cannot read process groups configuration file '/etc/netdata/apps_groups.conf'. Will try '/usr/lib/n>

此时,Netdata 正在运行并监听 19999 端口。您可以使用以下命令检查它:

ss -antpl | grep netdata

您将获得以下输出:

LISTEN 0128 127.0.0.1:8125 0.0.0.0:* users:(("netdata",pid=58935,fd=29))LISTEN 01280.0.0.0:199990.0.0.0:* users:(("netdata",pid=58935,fd=6)) LISTEN 0128 [::1]:8125[::]:* users:(("netdata",pid=58935,fd=28))LISTEN 0128 [::]:19999 [::]:* users:(("netdata",pid=58935,fd=7))

完成后,您可以继续下一步。

配置防火墙

如果您在系统上使用 firewalld 防火墙,那么您需要允许端口19999和80通过 firewalld。您可以使用以下命令允许它们:

firewall-cmd --permanent --add-port=19999/tcp firewall-cmd --permanent --add-port=80/tcp

接下来,重新加载 firewalld 守护进程以应用更改:

firewall-cmd --reload

完成后,您可以继续下一步。

将 Nginx 配置为 Netdata 的反向代理

将 Nginx 安装和配置为反向代理以访问 Netdata 始终是一个好主意。首先,使用以下命令安装 Nginx 服务器:

dnf install nginx httpd-tools -y

接下来,使用以下命令生成密码文件:

htpasswd -c /etc/nginx/.htpasswd netadmin

设置您的管理员密码,如下所示:

New password: Re-type new password: Adding password for user netadmin

接下来,使用以下命令创建一个 Nginx 虚拟主机配置文件:

nano /etc/nginx/conf.d/netdata.conf

添加以下行:

upstream backend {server 127.0.0.1:19999;keepalive 64;}server {listen 80;server_name ;location / {proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://backend;proxy_http_version 1.1; proxy_pass_request_headers on;proxy_set_header Connection "keep-alive";proxy_store off;auth_basic "Private Property";auth_basic_user_file /etc/nginx/.htpasswd;}}

保存并关闭文件,然后验证 Nginx 是否存在任何语法配置错误:

nginx -t

如果一切正常,您将获得以下输出:

nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

接下来,重新启动 Nginx 服务以应用配置更改:

systemctl restart nginx

您还可以使用以下命令检查 Nginx 状态:

systemctl status nginx

您应该看到以下输出:

? nginx.service - The nginx HTTP and reverse proxy serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)Active: active (running) since Sat -03-19 04:28:44 UTC; 4s agoProcess: 61706 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)Process: 61705 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)Process: 61703 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)Main PID: 61708 (nginx)Tasks: 2 (limit: 11412)Memory: 3.7MCGroup: /system.slice/nginx.service??61708 nginx: master process /usr/sbin/nginx??61709 nginx: worker processMar 19 04:28:44 linux systemd[1]: Starting The nginx HTTP and reverse proxy server...Mar 19 04:28:44 linux nginx[61705]: nginx: the configuration file /etc/nginx/nginx.conf syntax is okMar 19 04:28:44 linux nginx[61705]: nginx: configuration file /etc/nginx/nginx.conf test is successfulMar 19 04:28:44 linux systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argumentMar 19 04:28:44 linux systemd[1]: Started The nginx HTTP and reverse proxy server.

完成后,您可以继续下一步。

访问网络数据仪表板

现在,打开您的 Web 浏览器并使用 URL http://your-server-ip 访问 Netdata 仪表板。您应该看到 Netdata 登录页面:

提供您的管理员用户名、密码,然后单击登录按钮。您应该在以下页面上看到 Netdata 仪表板:

结论

恭喜!您已在 Alma Linux 8 上成功安装了 Netdata 监控工具。您现在可以从 Netdata 仪表板开始实时监控您的服务器矩阵,如果您有任何问题,请随时问我。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。