一文學(xué)會(huì)LirbeNMS安裝~優(yōu)秀開(kāi)源的SNMP設(shè)備監(jiān)控軟件
寫(xiě)在前面
前面簡(jiǎn)單介紹了該款軟件,這篇主要講安裝的過(guò)程,大家在使用開(kāi)源軟件的時(shí)候不要抱有免費(fèi)的軟件,商業(yè)的體驗(yàn)的心態(tài),那是不可能的,該款軟件一樣存在很多問(wèn)題,只不過(guò)在網(wǎng)絡(luò)領(lǐng)域還是比其他開(kāi)源軟件要強(qiáng)大不少,至少在易用性、可擴(kuò)展性還是不錯(cuò)的。
正文
環(huán)境
- 系統(tǒng)版本:CentOS 7.8
- web:Nginx
- PHP版本:7.3(最低7.3)
- 數(shù)據(jù)庫(kù):Mariadb
安裝前準(zhǔn)備
- 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用戶(hù)
- 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)這個(gè)問(wè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依賴(lài)組件
- 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.修改時(shí)區(qū)
- vi /etc/php.ini
修改時(shí)區(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;
- }
- }
啟動(dòng)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
計(jì)劃任務(wù)
- cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
復(fù)制LibreNMS配置文件
- cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
訪(fǎng)問(wèn)前端
此時(shí)會(huì)發(fā)現(xiàn)訪(fǎng)問(wèn)還是Nginx的界面,這里需要調(diào)整一些參數(shù)
- vi /etc/nginx/nginx.conf
- systemctl restart nginx
將端口改為8080
前端配置
點(diǎn)擊圖標(biāo)進(jìn)行下一步
檢查通過(guò)
填寫(xiě)數(shù)據(jù)庫(kù)信息
通過(guò)之后點(diǎn)擊build
點(diǎn)擊紅框才能下一步
正常是空的dashboard
設(shè)置中文
簡(jiǎn)單使用
新增設(shè)備
最終效果
總結(jié)
該軟件部署較為復(fù)雜,如果僅僅想體驗(yàn)可以試試容器版本,目前官方提供apache和nginx兩種版本,容器版本使用起來(lái)設(shè)備如果不多還是可以的,當(dāng)然如果有一定基礎(chǔ)的可以自行安裝,但該軟件的特點(diǎn)主要使用簡(jiǎn)單,監(jiān)控項(xiàng)細(xì)致,但目前該軟件還是存在一定的問(wèn)題,例如華為WLAN部分access user顯示有一定問(wèn)題,預(yù)測(cè)是后臺(tái)的mib邏輯調(diào)用存在異常導(dǎo)致,另外負(fù)載也有相對(duì)應(yīng)的問(wèn)題,所以大家如果想用,不妨先測(cè)試,最終決定是否使用。