サーバ構成
OS : CentOS7.5 WEB : Apache 2.4系 DB : MariaDB 10.1系 PHP : 5.6系
PHP 5.6をインストールするためにremiのリポジトリをインストール
yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
MariaDB 10.1をインストールするためにリポジトリを作成
vi /etc/yum.repos.d/mariadb.repo # MariaDB 10.1 CentOS repository list - created 2018-07-27 14:17 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
phpをインストール
yum install --enablerepo=remi,remi-php56 php php-mbstring php-gd php-mysqlnd php-mcrypt php-pdo php-xml php-process php-snmp php-zip
phpをインストールするとApacheもインストールされるのでLet's Encryptが使えるように必要なパッケージをインストール
yum install --enablerepo=remi,remi-php56 mod_ssl certbot
MariaDBをインストール
yum install --enablerepo=remi,remi-php56 MariaDB MariaDB-server
その他、LibreNMSのDOCSに書いてある必要なパッケージをインストール
yum install --enablerepo=remi,remi-php56 composer cronie fping git ImageMagick jwhois mtr net-snmp net-snmp-utils nmap python-memcached rrdtool
※PHPとMariaDBのバージョンは現時点では最低限のバージョンです。もっと新しいバージョンを利用してもOK
公式サイトには書いてないが必要なパッケージをインストール
yum install MySQL-python
LibreNMS用のユーザを作成
useradd librenms -d /opt/librenms -M -r usermod -a -G librenms apache
LibreNMSのパッケージをダウンロード
cd /opt composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master
MariaDBを起動してrootユーザでログイン
systemctl start mariadb mysql -u root
ユーザとデータベースを作成する
CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; FLUSH PRIVILEGES; exit
Mariadbの設定を変更
vi /etc/my.cnf.d/server.cnf [mysqld]の直下に以下のコードを追加。保存して編集を終了 innodb_file_per_table=1 sql-mode="" lower_case_table_names=0 サービスを再起動 systemctl restart mariadb 自動起動設定 systemctl enable mariadb ステータス確認 systemctl status mariadb
MariaDBの初期化
mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none):【ENTER クリック】 OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n]【ENTER】 New password:【新しいパスワードを入力】 Re-enter new password:【新しいパスワードを入力】 後は全て【Enter】でOK
PHPのタイムゾーンを設定。保存して編集を終了
vi /etc/php.ini ;date.timezone = ↓ date.timezone = Asia/Tokyo
Apacheの設定。保存して編集を終了
vi /etc/httpd/conf.d/librenms.conf <VirtualHost *:80> DocumentRoot /opt/librenms/html/ ServerName librenms.example.com AllowEncodedSlashes NoDecode <Directory "/opt/librenms/html/"> Require all granted AllowOverride All Options FollowSymLinks MultiViews </Directory> </VirtualHost>
Apacheを起動。自動起動設定をする
systemctl start httpd systemctl enable httpd
selinuxはとりあえずdisableにするので細かい設定はしないw
firewall-cmdを設定
firewall-cmd --add-service=http --add-service=https --permanent firewall-cmd --reload
snmp設定
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.backup cp -p /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf vi /etc/snmp/snmpd.conf # Change RANDOMSTRINGGOESHERE to your preferred SNMP community string com2sec readonly default view com2sec notConfigUser xxx.xxx.xxx.xxx/32 view #group MyROGroup v2c readonly group notConfigGroup v2c notConfigUser view all included .1 80 #access MyROGroup "" any noauth exact all none none access notConfigGroup "" any noauth exact all none none syslocation Rack, Room, Building, City, Country [GPSX,Y] syscontact ADMIN <admin@example.com> #Distro Detection extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro #Hardware Detection (uncomment to enable) #extend .1.3.6.1.4.1.2021.7890.2 hardware '/bin/cat /sys/devices/virtual/dmi/id/product_name' #extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor' #extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial' trapsink xxx.xxx.xxx.xxx
snmpdを起動。自動起動設定
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の設定
cp -p /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
logrotate設定
cp -p /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
パーミッション変更
chown -R librenms:librenms /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/
ここまで来たらブラウザでアクセスして設定をする
http://librenms.example.com/install.php