如何在Debian 10上安装LibreNMS
admin
2023-07-31 07:41:06
0

LibreNMS是一种自动发现基于PHP / MySQL / SNMP的网络监控,其中包括对广泛网络硬件的支持。和操作系统,包括Cisco,Linux,FreeBSD,Juniper,HP等。LibreNMS是Observium社区支持的分支。LibreNSM-logoLibreNSM-logo

在Debian 10 Buster上安装LibreNMS

步骤1.在运行下面的教程之前,重要的是通过apt在终端中运行以下命令来确保系统是最新的:

sudo apt update

步骤2.安装必需的软件包。

在下面运行以下命令以安装依赖项必需的软件包:

sudo apt install acl curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nmap python-memcache python-mysqldb rrdtool snmp snmpd whois python3-pymysql python3-dotenv python3-redis python3-setuptools

步骤3.安装LEMP堆栈。

需要Debian 10 LEMP服务器。如果您尚未安装LEMP,则可以在此处按照我们的教程进行操作。

步骤4.在Debian 10上安装LibreNMS。

在安装之前,我们为LibreNMS创建一个用户:

useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data

现在我们从官方网站下载LibreNMS:

cd /opt
git clone https://github.com/librenms/librenms.git

接下来,更改文件夹所有权权限:

chown -R librenms:librenms /opt/librenms
chmod 770 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

步骤4.为LibreNMS配置MariaDB。

默认情况下,不会对MariaDB进行加固。您可以使用mysql_secure_installation脚本保护MariaDB 。您应该仔细阅读每个步骤,并在每个步骤下面仔细进行操作,这将设置root密码,删除匿名用户,禁止远程root登录以及删除测试数据库和对安全MariaDB的访问权限:

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

接下来,我们将需要登录到MariaDB控制台并为LibreNMS创建数据库。运行以下命令:

mysql -u root -p

这将提示您输入密码,因此输入您的MariaDB根密码,然后按Enter。登录数据库服务器后,您需要为LibreNMS安装创建数据库:

MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]> CREATE USER \'librenms\'@\'localhost\' IDENTIFIED BY \'password\';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO \'librenms\'@\'localhost\';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

成功创建数据库后,现在打开MariaDB配置文件,并在部分下添加以下行:[mysqld]

nano /etc/mysql/mariadb.conf.d/50-server.cnf

在此部分中,请添加:[mysqld]

innodb_file_per_table=1
lower_case_table_names=0

然后,重新启动MariaDB,以使更改生效:

sudo systemctl restart mariadb

步骤5.配置Nginx。

现在,我们为LibreNMS使用的Nginx创建VirtualHost定义:

rm /etc/nginx/sites-enabled/default
nano /etc/nginx/sites-available/librenms.vhost

添加以下配置,server_name根据需要进行编辑:

server {listen80;server_name librenms.idroot.us;root/opt/librenms/html;indexindex.php;charset utf-8;gzip on;gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;proxy_read_timeout 300;proxy_connect_timeout 300;proxy_send_timeout 300;location / {try_files $uri $uri/ /index.php?$query_string;}location /api/v0 {try_files $uri $uri/ /api_v0.php?$query_string;}location ~ \\.php {include fastcgi.conf;fastcgi_split_path_info ^(.+\\.php)(/.+)$;fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;}location ~ /\\.ht {deny all;}}

保存并关闭,然后重新启动Nginx Web服务器,以便进行更改:

ln -s /etc/nginx/sites-available/librenms.vhost /etc/nginx/sites-enabled/librenms.vhost
sudo systemctl restart nginx

步骤6.配置snmpd。

现在,使用nano文本编辑器编辑新的配置snmpd:

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
chmod 600 /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf

编辑显示的文字RANDOMSTRINGGOESHERE并设置您自己的社区字符串:

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
service snmpd restart

步骤7.配置UFW防火墙。

将新端口添加到防火墙。将新的ssh,HTTP,HTTPS和snmpd 161 udp类型使用的端口添加到ufw防火墙中:

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 161/udp
sudo ufw enable

步骤8.访问LibreNMS Web界面。

成功安装后,默认情况下,LibreNMS将在HTTP端口80上可用。打开您喜欢的浏览器,然后浏览并完成所需的步骤以完成安装。http://librenms.idroot.us/

librenms-web-interfacelibrenms-web-interface

恭喜你!您已成功安装LibreNMS。感谢您使用本教程在Debian系统上安装LibreNMS的最新版本。有关其他帮助或有用信息,建议您访问LibreNMS官方网站。

相关内容

热门资讯

Windows 11 和 10... Windows 11/10 文件夹属性中缺少共享选项卡 – 已修复 1.检查共享选项卡是否可用 右键...
Radmin VPN Wind... Radmin VPN 是一款免费且用户友好的软件,旨在牢固地连接计算机以创建一个有凝聚力的虚拟专用网...
如何修复 Steam 内容文件... Steam 内容文件锁定是当您的 Steam 文件无法自行更新时出现的错误。解决此问题的最有效方法之...
在 Windows 11 中打... 什么是链路状态电源管理? 您可以在系统控制面板的电源选项中看到链接状态电源管理。它是 PCI Exp...
Hive OS LOLMine... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
iPhone 屏幕上有亮绿色斑... iPhone 是市场上最稳定的智能手机之一,这主要归功于专为它们设计的 iOS 操作系统。然而,他们...
事件 ID 7034:如何通过... 点击进入:ChatGPT工具插件导航大全 服务控制管理器 (SCM) 负责管理系统上运行的服务的活动...
balenaEtcher烧录后... balenaEtcher烧录后u盘或者内存卡无法识别不能使用的解决方法想要恢复原来的方法,使用win...
在 iCloud 上关闭“查找... 如果您是 Apple 的长期用户,您肯定会遇到过 Find My 应用程序,它本机安装在 iPhon...
统信UOS每次开机后不直接进入... 统信UOS每次开机后不直接进入系统而是进入到recovery模式 按方向上键选择UOS 20 SP1...