其實 librenms 官方 doc 已經寫得很詳細了
照做只有幾個點要注意而已
官方手冊
https://docs.librenms.org/#Installation/Installation-CentOS-7-Apache/
在 Install Required Packages
建議順便裝 3 個套件
wget nano python-ipaddress
該動作為每天凌晨執行 scan 動作
建議不要太常執行,因為掃一次的時間會蠻長的
接著設定 syslog
https://docs.librenms.org/#Extensions/Syslog/#syslog-server-installation
tcp(port(514) 會失敗 建議先不開
記得開防火牆,librenms 就能收到 log 了
firewall-cmd –permanent –add-port=514/udp
firewall-cmd –permanent –add-port=514/tcp
安裝工具 yum install -y nano wget unzip
指定 php 版本
yum install -y epel-release
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y yum-utils
yum-config-manager –disable remi-php54
yum-config-manager –enable remi-php72
新版 mariadb
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
新版 apache
cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q –qf “%{VERSION}” $(rpm -q –whatprovides redhat-release)`.repo
安裝套件
yum install -y git cronie fping jwhois ImageMagick mtr MySQL-python MySQL-python net-snmp net-snmp-utils nmap python-memcached rrdtool policycoreutils-python httpd mariadb mariadb-server
yum install -y php httpd mod_php php-cli php-common php-curl php-gd php-mbstring php-process php-snmp php-xml php-zip php-memcached php-mysqlnd
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms apache
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/ /opt/librenms/cache
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ /opt/librenms/cache
su – librenms
./scripts/composer_wrapper.php install –no-dev
exit
systemctl start mariadb
systemctl start httpd
systemctl enable mariadb
systemctl enable httpd
systemctl disable firewalld
mysql -u root -p
CREATE DATABASE librenmsDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER ‘librenmsUSER’@’localhost’ IDENTIFIED BY ‘librenmsPW’;
GRANT ALL PRIVILEGES ON librenmsDB.* TO ‘librenmsUSER’@’localhost’;
FLUSH PRIVILEGES;
exit
nano /etc/my.cnf.d/server.cnf
Within the [mysqld] section please add:
default-time-zone = ‘+8:00’
innodb_file_per_table=1
lower_case_table_names=0
systemctl restart mariadb
Configure Apache
Create the librenms.conf:
nano /etc/httpd/conf.d/librenms.conf
Add the following config, edit ServerName as required:
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com
AllowEncodedSlashes NoDecode
<directory “/opt/librenms/html/”>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
sed -e ‘s/memory_limit = 128M/memory_limit = 1024M/’ -i /etc/php.ini
sed -e ‘s/max_execution_time = 30/max_execution_time = 180/’ -i /etc/php.ini
sed -e ‘s/upload_max_filesize = 2M/upload_max_filesize = 1024M/’ -i /etc/php.ini
sed -e ‘s/post_max_size = 8M/post_max_size = 1024M/’ -i /etc/php.ini
sed -e ‘s/^;date.timezone =/date.timezone =”Asia/Taipei”/’ -i /etc/php.ini
systemctl restart httpd
nano http_fping.tt
module http_fping 1.0;
require {
type httpd_t;
class capability net_raw;
class rawip_socket { getopt create setopt write read };
}
#============= httpd_t ==============
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket { getopt create setopt write read };
checkmodule -M -m -o http_fping.mod http_fping.tt
semodule_package -o http_fping.pp -m http_fping.mod
semodule -i http_fping.pp
Copy the example snmpd.conf from the LibreNMS install.
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
vi /etc/snmp/snmpd.conf
Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.
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
Cron job
cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
NOTE: Keep in mind that cron, by default, only uses a very limited set of environment variables. You may need to configure proxy variables for the cron invocation. Alternatively adding the proxy settings in config.php is possible too. The config.php file will be created in the upcoming steps. Review the following URL after you finished librenms install steps: https://docs.librenms.org/Support/Configuration/#proxy-support
Copy logrotate config
LibreNMS keeps logs in /opt/librenms/logs. Over time these can become large and be rotated out. To rotate out the old logs you can use the provided logrotate config file:
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Web installer
Now head to the web installer and follow the on-screen instructions.
http://librenms.example.com/install.php
sed -e ‘s/memory_limit = 128M/memory_limit = 1024M/’ -i /etc/php.ini
sed -e ‘s/max_execution_time = 30/max_execution_time = 180/’ -i /etc/php.ini
sed -e ‘s/upload_max_filesize = 2M/upload_max_filesize = 1024M/’ -i /etc/php.ini
sed -e ‘s/post_max_size = 8M/post_max_size = 1024M/’ -i /etc/php.ini
sed -e ‘s/^;date.timezone =/date.timezone =”Asia/Taipei”/’ -i /etc/php.ini
systemctl restart httpd
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
timedatectl set-timezone Asia/Taipei