一文學會LirbeNMS安裝~優(yōu)秀開源的SNMP設(shè)備監(jiān)控軟件
寫在前面
前面簡單介紹了該款軟件,這篇主要講安裝的過程,大家在使用開源軟件的時候不要抱有免費的軟件,商業(yè)的體驗的心態(tài),那是不可能的,該款軟件一樣存在很多問題,只不過在網(wǎng)絡(luò)領(lǐng)域還是比其他開源軟件要強大不少,至少在易用性、可擴展性還是不錯的。
正文
環(huán)境
- 系統(tǒng)版本:CentOS 7.8
- web:Nginx
- PHP版本:7.3(最低7.3)
- 數(shù)據(jù)庫:Mariadb
安裝前準備
- yum install epel-release yum-utils -y
- yum localinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
- yum-config-manager --enable remi-php74
- yum install composer cronie fping git ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-gd php-mbstring php-process php-snmp php-xml php-zip php-memcached php-mysqlnd python-memcached rrdtool python3 python3-pip -y
創(chuàng)建LibreNMS用戶
- useradd librenms -d /opt/librenms -M -r
- usermod -a -G librenms nginx
下載LibreNMS文件
- cd /opt
- git clone https://github.com/librenms/librenms.git
如果大家出現(xiàn)這個問題,將上文地址由https改為git,但是非常慢
設(shè)置權(quán)限
- 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/
- chgrp apache /var/lib/php/session/
安裝PHP依賴組件
- su - librenms
- ./scripts/composer_wrapper.php install --no-dev
- exit
安裝、配置DB
- yum -y install mariadb-server
- systemctl start mariadb && systemctl enable mariadb
- mysql -uroot -p
- CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'xiaoyu123';
- GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
- FLUSH PRIVILEGES;
- quit
- ####修改mariadb配置文件####
- vi /etc/my.cnf
- innodb_file_per_table=1
- lower_case_table_names=0
- ####wr保存退出####
- systemctl restart mariadb
添加配置
PHP-FPM配置
1.修改時區(qū)
- vi /etc/php.ini
修改時區(qū)
2.修改php-fpm配置文件
- vi /etc/php-fpm.d/www.conf
- ####改為如下####
- ;user = apache
- user = nginx
- group = apache
- ;listen = 127.0.0.1:9000
- listen = /run/php-fpm/php-fpm.sock
- listen.owner = nginx
- listen.group = nginx
- listen.mode = 0660
3.重啟php-fpm服務(wù)
- systemctl enable php-fpm
- systemctl restart php-fpm
配置Nginx
- vi /etc/nginx/conf.d/librenms.conf
- ####添加如下內(nèi)容####
- server {
- listen 80;
- server_name librenms.example.com;
- root /opt/librenms/html;
- index index.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;
- 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:/run/php-fpm/php-fpm.sock;
- }
- location ~ /\.ht {
- deny all;
- }
- }
啟動Nginx
- systemctl enable nginx
- systemctl restart nginx
SNMP配置
- cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
- y
- curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
- chmod +x /usr/bin/distro
- systemctl enable snmpd &&systemctl restart snmpd
計劃任務(wù)
- cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
復制LibreNMS配置文件
- cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
訪問前端
此時會發(fā)現(xiàn)訪問還是Nginx的界面,這里需要調(diào)整一些參數(shù)
- vi /etc/nginx/nginx.conf
- systemctl restart nginx
將端口改為8080
前端配置
點擊圖標進行下一步
檢查通過
填寫數(shù)據(jù)庫信息
通過之后點擊build
點擊紅框才能下一步
正常是空的dashboard
設(shè)置中文
簡單使用
新增設(shè)備
最終效果
總結(jié)
該軟件部署較為復雜,如果僅僅想體驗可以試試容器版本,目前官方提供apache和nginx兩種版本,容器版本使用起來設(shè)備如果不多還是可以的,當然如果有一定基礎(chǔ)的可以自行安裝,但該軟件的特點主要使用簡單,監(jiān)控項細致,但目前該軟件還是存在一定的問題,例如華為WLAN部分access user顯示有一定問題,預測是后臺的mib邏輯調(diào)用存在異常導致,另外負載也有相對應(yīng)的問題,所以大家如果想用,不妨先測試,最終決定是否使用。