Changes between Initial Version and Version 1 of Cnbp2019/Agenda/MonitoringLab


Ignore:
Timestamp:
Feb 4, 2019, 8:10:22 AM (6 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Cnbp2019/Agenda/MonitoringLab

    v1 v1  
     1= Monitoring Lab Setup =
     2----
     3
     4Below are the requirements for running LibreNMS on Ubuntu 18.04:
     5
     6* Database Server – We will use MariaDB
     7* PHP 7.2
     8* Web Server – We will use Nginx
     9
     10== Install LEMP stack (MariaDB, Nginx, and PHP) ==
     11=== Installation of MariaDB ===
     12
     13LibreNMS is not fully compatible with MySQL strict mode, for now, please disable this after mysql is installed.
     14
     15` sudo vim /etc/mysql/mariadb.cnf `
     16
     17Within the ` [mysqld]` section please add:
     18{{{
     19innodb_file_per_table=1
     20sql-mode=""
     21lower_case_table_names=0
     22}}}
     23
     24Then restart mysql `sudo systemctl restart mysql`
     25
     26Now you need to create a database for LibreNMS.
     27
     28{{{
     29mysql –u root –p
     30MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
     31MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'Strongpassword';
     32MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
     33MariaDB [(none)]> FLUSH PRIVILEGES;
     34MariaDB [(none)]> exit
     35}}}
     36
     37=== Installation of PHP ===
     38
     39Ubuntu 18.04 has PHP 7.2 in its repositories. Install it by running the commands below on your terminal
     40
     41{{{
     42sudo apt-get -y install wget php php-pear php-cgi php-common curl php-curl \
     43php-mbstring php-gd php-mysql php-gettext php-bcmath \
     44php-imap php-json php-xml php-snmp php-fpm php-zip
     45}}}
     46
     47To confirm the php version installed, use the command `php –v`
     48
     49it should give you a similar output as below
     50
     51{{{
     52#php -v
     53
     54PHP 7.2.8 (cli) (built: Jul 17 2018 09:50:46) ( NTS )
     55Copyright (c) 1997-2018 The PHP Group
     56Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
     57}}}
     58
     59Configure and Start PHP-FPM
     60Ensure date.timezone is set in php.ini to your preferred time zone:
     61Edit both files:
     62sudo vim /etc/php/7.2/fpm/php.ini
     63sudo vim /etc/php/7.2/cli/php.ini
     64
     65Change date.timezone under [Date] section:
     66[Date]
     67; Defines the default timezone used by the date functions
     68; http://php.net/date.timezone
     69date.timezone = Asia/Colombo
     70Restart php fpm:
     71sudo systemctl restart php7.2-fpm.service
     72
     73For this setup, we will use Nginx as a web server for LibreNMS, install it by running:
     74sudo apt-get install nginx
     75
     76Step 2: Download and Install LibreNMS
     77We will download and install LibreNMS in this step. If you don’t have git, first install it:
     78$ sudo apt-get install git
     79
     80LibreNMS will run under its own user called librenms which we need to add:
     81sudo useradd -r -M -d /opt/librenms librenms
     82getent passwd librenms
     83
     84
     85output:
     86
     87librenms:x:997:996::/opt/librenms:/bin/sh
     88Add this user to web user group www-data
     89sudo usermod -a -G librenms www-data
     90
     91When done. proceed to install packages required by LibreNMS
     92
     93sudo apt-get update
     94sudo apt install rrdtool whois fping imagemagick graphviz  mtr-tiny \
     95nmap python-mysqldb snmp snmpd python-memcache mtr-tiny acl
     96
     97Clone LibreNMS source code from github:
     98git clone https://github.com/librenms/librenms.git librenms
     99
     100output:
     101Cloning into 'librenms'...
     102remote: Counting objects: 130428, done.
     103remote: Compressing objects: 100% (27/27), done.
     104remote: Total 130428 (delta 10), reused 10 (delta 4), pack-reused 130396
     105Receiving objects: 100% (130428/130428), 128.54 MiB | 19.52 MiB/s, done.
     106Resolving deltas: 100% (88754/88754), done.
     107Checking out files: 100% (8476/8476), done.
     108
     109Move the folder librenms to /opt
     110
     111sudo mv librenms/ /opt/
     112
     113Change permission of the directory:
     114sudo chown -R librenms:librenms /opt/librenms/
     115sudo chmod -R 775 /opt/librenms/
     116
     117Configure snmpd
     118sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
     119sudo vim /etc/snmp/snmpd.conf
     120
     121Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.
     122
     123curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
     124chmod +x distro
     125sudo mv distro  /usr/bin/distro
     126
     127Restart snmpd
     128
     129sudo systemctl restart snmpd
     130
     131Create LibreNMS Cron job
     132Run the command below to set cron job:
     133
     134sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
     135Copy logrotate config
     136LibreNMS 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:
     137
     138sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
     139
     140Fix LibreNMS Permissions
     141Finally, fix all permissions
     142sudo chown -R librenms:librenms /opt/librenms
     143sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
     144sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
     145
     146Configure Nginx:
     147Let’s create the VirtualHost definition for Nginx to be used by LibreNMS.
     148sudo vim /etc/nginx/conf.d/librenms.conf
     149
     150server {
     151 listen      80;
     152 server_name librenms.example.com;
     153 root        /opt/librenms/html;
     154 index       index.php;
     155
     156 charset utf-8;
     157 gzip on;
     158 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;
     159 location / {
     160  try_files $uri $uri/ /index.php?$query_string;
     161 }
     162 location /api/v0 {
     163  try_files $uri $uri/ /api_v0.php?$query_string;
     164 }
     165 location ~ \.php {
     166  include fastcgi.conf;
     167  fastcgi_split_path_info ^(.+\.php)(/.+)$;
     168  fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
     169 }
     170 location ~ /\.ht {
     171  deny all;
     172 }
     173}
     174Check syntax:
     175
     176sudo nginx –t
     177
     178output:
     179
     180nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
     181nginx: configuration file /etc/nginx/nginx.conf test is successful
     182
     183if all is okay, restart nginx:
     184
     185sudo systemctl restart nginx
     186
     187
     188Run composer install:
     189
     190cd /opt/librenms
     191./scripts/composer_wrapper.php install --no-dev
     192
     193Now open your web browser and start the installer:
     194
     195http://librenms.example.com/install.php