差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:librenms [2021/01/17 16:54] – 命令改用 cli jonathantech:librenms [2024/02/20 12:13] (目前版本) – [設定告警通知] jonathan
行 1: 行 1:
-====== CentOS7 安裝 LibreNMS ======+====== Ubuntu 20.04 / CentOS7 安裝 LibreNMS 程序 ====== 
 +<note tip> 
 +如果要以 Docker 方式進行安裝, 可參考 [[tech/k8s_librenms]] 
 +</note> 
 + 
 +  * Ubuntu 20.04 LTS
   * CentOS Linux release 7.5.1804 (Core)   * CentOS Linux release 7.5.1804 (Core)
  
-===== 安裝程序 ===== +{{tabinclude>tech:librenms:ubuntu20_04tech:librenms:centos7}}
-  - 安裝需要的套件 <cli> +
-yum install epel-release +
-rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm +
-yum install composer cronie fping git ImageMagick jwhois mariadb mariadb-server mtr python36 MySQL-python net-snmp net-snmp-utils nginx nmap php72w php72w-cli php72w-common php72w-curl php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-process php72w-snmp php72w-xml php72w-zip python-memcached rrdtool +
-</cli> +
-  - 建立 librenms 用戶<cli> +
-useradd librenms -d /opt/librenms -M -r +
-usermod -a -G librenms nginx +
-</cli> +
-sync;sync;sync;reboot +
-</code> +
-  - 下載 LibreNMS <cli> +
-cd /opt +
-composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master +
-</cli> +
-  - 出現異常與警告訊息, 重新開機後再執行<cli> +
-cd /opt/librenms +
-./scripts/composer_wrapper.php install --no-dev +
-</cli> +
-  - 建立 DB Server<cli> +
-systemctl start mariadb +
-mysql -u root +
-</cli>**password** 要依照自己需要設定<code sql> +
-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 +
-</code><cli> +
-vi /etc/my.cnf +
-</cli><file> +
-[mysqld] +
-datadir=/var/lib/mysql +
-+
-+
-# instructions in http://fedoraproject.org/wiki/Systemd +
-innodb_file_per_table=1 +
-sql-mode="" +
-lower_case_table_names=0 +
-+
-</file><cli> +
-systemctl enable mariadb +
-systemctl restart mariadb +
-</cli> +
-  - 建立 Web Server <cli> +
-vi /etc/php-fpm.d/www.conf +
-</cli><file> +
-+
-;user = apache +
-user = nginx +
-; RPM: Keep a group allowed to write in log dir. +
-group = apache +
- +
-; The address on which to accept FastCGI requests. +
-; Valid syntaxes are: +
-;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on +
-;                            a specific port; +
-;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +
-;                            a specific port; +
-;   'port'                 - to listen on a TCP socket to all addresses +
-;                            (IPv6 and IPv4-mapped) on a specific port; +
-;   '/path/to/unix/socket' - to listen on a unix socket. +
-; Note: This value is mandatory. +
-;listen = 127.0.0.1:9000 +
-listen = /var/run/php-fpm/php7.2-fpm.sock +
- +
-; Set listen(2) backlog. +
-; Default Value: 511 (-1 on FreeBSD and OpenBSD) +
-;listen.backlog = 511 +
- +
-; Set permissions for unix socket, if one is used. In Linux, read/write +
-; permissions must be set in order to allow connections from a web server. Many +
-; BSD-derived systems allow connections regardless of permissions. +
-; Default Values: user and group are set as the running user +
-;                 mode is set to 0660 +
-;listen.owner = nobody +
-;listen.group = nobody +
-;listen.mode = 0660 +
-listen.owner = nginx +
-listen.group = nginx +
-listen.mode = 0660 +
- +
-; When POSIX Access Control Lists are supported you can set them using +
-; these options, value is a comma separated list of user/group names. +
-+
-</file><cli> +
-systemctl enable php-fpm +
-systemctl restart php-fpm +
-</cli> +
-  - 設定 nginx <cli> +
-vi /etc/nginx/conf.d/librenms.conf +
-</cli><file> +
-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:/var/run/php-fpm/php7.2-fpm.sock; +
- } +
- location ~ /\.ht { +
-  deny all; +
- } +
-+
-</file><cli> +
-systemctl enable nginx +
-systemctl restart nginx +
-</cli> +
-  - 建立 SELinux 與 Allow fping<cli> +
-yum install policycoreutils-python +
- +
-semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?' +
-semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.*)?' +
-restorecon -RFvv /opt/librenms/logs/ +
-semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.*)?' +
-semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.*)?' +
-restorecon -RFvv /opt/librenms/rrd/ +
-semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/storage(/.*)?' +
-semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.*)?' +
-restorecon -RFvv /opt/librenms/storage/ +
-semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/bootstrap/cache(/.*)?' +
-semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/bootstrap/cache(/.*)?' +
-restorecon -RFvv /opt/librenms/bootstrap/cache/ +
-setsebool -P httpd_can_sendmail=1 +
-setsebool -P httpd_execmem 1 +
- +
-vi /tmp/http_fping.tt +
-</cli><file> +
-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 }; +
-</file><cli> +
-checkmodule -M -m -o http_fping.mod /tmp/http_fping.tt +
-semodule_package -o /tmp/http_fping.pp -m http_fping.mod +
-semodule -i /tmp/http_fping.pp +
-</cli> +
-  - 設定 firewall<cli> +
-firewall-cmd --zone public --add-service http +
-firewall-cmd --permanent --zone public --add-service http +
-firewall-cmd --zone public --add-service https +
-firewall-cmd --permanent --zone public --add-service https +
-<cli> +
-  - 設定 snmpd <cli> +
-cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf +
- +
-vi /etc/snmp/snmpd.conf +
-</cli>將 RANDOMSTRINGGOESHERE 改成你要的 community 字串<file> +
-# Change RANDOMSTRINGGOESHERE to your preferred SNMP community string +
-#com2sec readonly  default         RANDOMSTRINGGOESHERE +
-com2sec readonly  default         **community_string** +
-: +
-#syslocation RackRoom, Building, City, Country [GPSX,Y] +
-syslocation Taipei, Taiwan +
-#syscontact Your Name <[email protected]> +
-syscontact Jonathan Tsai <[email protected]> +
-: +
-</file><cli> +
-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 +
-</cli> +
-  - 定義 cron table <cli> +
-cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms +
-</cli> +
-  - 設定定時清 log <cli> +
-cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms +
-</cli> +
-  - 設定權限 <cli> +
-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/ +
-</cli> +
-  - 至網頁介面進行安裝 網址 Exp. http://192.168.11.200/install.php  +
-    - 如果這時候無法出現安裝畫面, 表示 nginx default 設定沒有移除 <cli> +
-vi /etc/nginx/nginx.conf +
-</cli><file> +
-+
-    include             /etc/nginx/mime.types; +
-    default_type        application/octet-stream; +
- +
-    # Load modular configuration files from the /etc/nginx/conf.d directory. +
-    # See http://nginx.org/en/docs/ngx_core_module.html#include +
-    # for more information. +
-    include /etc/nginx/conf.d/*.conf; +
- +
-#    server { +
-#        listen       80 default_server; +
-#        listen       [::]:80 default_server; +
-#        server_name  _; +
-#        root         /usr/share/nginx/html; +
-+
-#        # Load configuration files for the default server block. +
-#        include /etc/nginx/default.d/*.conf; +
-+
-#        location / { +
-#        } +
-+
-#        error_page 404 /404.html; +
-#            location = /40x.html { +
-#        } +
-+
-#        error_page 500 502 503 504 /50x.html; +
-#            location = /50x.html { +
-#        } +
-#    } +
- +
-# Settings for a TLS enabled server. +
-+
-#    server { +
-+
-</file><cli> +
-systemctl restart nginx +
-</cli> +
-    - 依照網頁出現的 6 個 Stage 執行 +
-    - Stage 5 將產生的設定參數資料手動寫入 /opt/librenms/config.php <cli> +
-vi /opt/librenms/config.php +
-</cli> +
-    - 調整參數檔案權限<cli> +
-chown librenms:librenms /opt/librenms/config.php +
-</cli>  +
-  - 再來應該就可以透過網頁依照上一步驟建立的帳號登入 +
  
 ===== 設定自動找尋區域網路內可納管設備 ===== ===== 設定自動找尋區域網路內可納管設備 =====
行 276: 行 39:
 Scanned 253 IPs: 0 known devices, added 10 devices, failed to add 5 devices, 1 ips excluded by config Scanned 253 IPs: 0 known devices, added 10 devices, failed to add 5 devices, 1 ips excluded by config
 Runtime: 104.31 seconds Runtime: 104.31 seconds
 +</cli>
 +  - 設定 default_poller_group = 1 <cli>
 +lnms config:set default_poller_group 1
 </cli> </cli>
   - 之後在區域網路內的新設備如果有啟用 snmp v1 / v2c communty 符合設定的值, 可以在五分鐘內被自動加入   - 之後在區域網路內的新設備如果有啟用 snmp v1 / v2c communty 符合設定的值, 可以在五分鐘內被自動加入
 +<WRAP center round tip 60%>
 +  * 前一陣子發現設定都正確, 使用 snmp-scan.py 確實可以自動加入, 但卻無法如預期由該機制將新設備自動加入, 找了一些文章後還是無法真正解決問題, 目前我的 workaround 方法是將 snmp-scan.py 直接加入 cron 來處理
 +</WRAP>
  
 ===== 設定告警通知 ===== ===== 設定告警通知 =====
   * 設定 E-Mail 通知   * 設定 E-Mail 通知
     * Global Settings -> Alerting Settings      * Global Settings -> Alerting Settings 
-      * General alert settings : Default contact <- 填上要接收通知的 E-Mail +      * General alert settings : Default contact <- 填上要接收通知的 E-Mail ++設定畫面參考| \\ {{:tech:2018121001.png?600}}++ 
-        * Exp. {{:tech:2018121001.png?600}} +      * Email options 依照實際寄送的 Mail Server 方式設定 ++設定畫面參考| \\ {{:tech:2018121002.png?800}}++
-      * Email options 依照實際寄送的 Mail Server 方式設定 +
-        * Exp. {{:tech:2018121002.png?800}}+
   * 設定告警通知規則    * 設定告警通知規則 
     * Alerts -> Alert Rules     * Alerts -> Alert Rules
-      * 當監控的設備無法連線就通知 +      * 當監控的設備無法連線就通知 ++設定畫面參考| \\ {{:tech:2018121003.png?600}} \\ {{:tech:2018121004.png?800}}++ 
-      * {{:tech:2018121003.png?600}} +      * 將預設網路流量超過 90% 告警排除 lo 介面++設定畫面參考| \\ {{:tech:image_100.png?600}}++ 
-      * {{:tech:2018121004.png?800}}+    * 針對特定設備特定掛載硬碟剩餘空間進行設定 Exp. 172.16.0.230 排除 /mnt/ext 使用超過 90% 的通知 
 +      * 進入 172.16.0.230 的 Alert Rules 設定頁面 ++設定畫面參考| \\ {{:tech:2022-08-01_15_25_47.png?800|}}++ 
 +      * 修改 硬碟空間已使用 90% 規則, 增加排除 /mnt/ext 規則 ++設定畫面參考| \\ {{:tech:2022-08-01_15_27_40.png?600|}}++ 
 +    * 針對特定群組主機設定實體記憶體使用超過 7G 就發出 Critical 通知 ++設定畫面參考| \\ {{:tech:螢幕擷取畫面_2024-02-20_120728.png?800|}}++
  
  
行 305: 行 75:
  
 ===== 安裝 Agent 監看應用程式 ===== ===== 安裝 Agent 監看應用程式 =====
-  * {{indexmenu>:tech:librenms#1|navbar nsort}} 
  
 +{{tabinclude>tech/librenms/agent, tech/librenms/apache_agent, tech/librenms/nagios_agent, tech/librenms/bind_agent, tech/librenms/check_mk, tech/librenms/checkmssql, tech/librenms/checkpve, tech/librenms/fail2ban_agent, tech/librenms/mysql_agent, tech/librenms/nginx_agent, tech/librenms/php-fpm_agent, tech/librenms/postfix_agent, tech/librenms/redis_agent, tech/librenms/smart_agent, tech/librenms/zfs_agent}}
  
 ===== 常見 LibreNMS 異常問題排除 ===== ===== 常見 LibreNMS 異常問題排除 =====
行 382: 行 152:
   * 參考 - https://docs.librenms.org/Support/Configuration/   * 參考 - https://docs.librenms.org/Support/Configuration/
  
-===== 升級 php 至 7.4 =====+===== CentOS 7 升級 php 至 7.4 =====
   * 2020/11/04 收到訊息會 2020/11 起, LibreNMS 必須使用 php 7.3 以上(建議 7.4)版本才會自動更新   * 2020/11/04 收到訊息會 2020/11 起, LibreNMS 必須使用 php 7.3 以上(建議 7.4)版本才會自動更新
   * 先移除原本 PHP 7.2 <cli>   * 先移除原本 PHP 7.2 <cli>
行 507: 行 277:
 </note> </note>
  
 +===== CentOS 7 升級 MariaDB 10  =====
 +  * 2021/06/13 發現 Librenms 無法運作, 才發現 2021/03 起只支援 MySQL version 5.7.7 以上的版本, 所以目前使用的 Percona XtraDB Cluster 內的 5.6.42 就被迫要升級改用 MariaDB 10.5 
 +  * 將舊資料匯出, 如果忘記資料庫連線資訊, 可以看一下 .env <cli>
 +su - librenms
 +head .env
 +</cli> Exp. db_host:192.168.11.21 , db_user:librenms , db_pass:**Password** , db_name:librenms<cli>
 +mysqldump -u librenms -p librenms -h 192.168.11.21> /tmp/librenms.sql 
 +</cli>
 +  * 執行[[tech/centos7_mariadb10]]
 +  * 在新資料庫建立 LibreNMS 的使用者與資料庫 <cli>
 +mysql -u root -p
 +create database librenms;
 +create user 'librenms'@'%' identified by '**Password**';
 +grant all on librenms.* to 'librenms'@'%';
 +flush privileges;
 +quit
 +</cli>
 +  * 將舊資料匯入新資料庫 Exp. 192.168.11.22<cli>
 +cat /tmp/librenms.sql | mysql -u librenms -p librenms -h 192.168.11.22
 +</cli>
 +  * 修改 .env 內 DB 的連線設定<cli>
 +su - librenms
 +vi .env
 +</cli>
  
 +===== ./lnms migrate 出現 SQLSTATE[42S01] 異常  =====
 +  * 出現錯誤訊息如下<cli>
 +In Connection.php line 678:
 +
 +  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'port_groups' already exists (SQL: create table `port_groups` (`id` int unsigned not null auto_increment primary key, `na
 +  me` varchar(255) not null, `desc` varchar(255) null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
 +</cli>
 +    * 解決方式 <cli>
 +mysql -u librenms -p librenms
 +drop table port_groups;
 +</cli>
 +  * 再次執行 ./lnms migrate 出現找不到 librenms.port_group_port 這 table <cli>
 +In Connection.php line 678:
 +
 +  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'librenms.port_group_port' doesn't exist (SQL: alter table `port_group_port` add constraint `port_group_port_port_group_id_for
 +  eign` foreign key (`port_group_id`) references `port_groups` (`id`) on delete CASCADE)
 +</cli>
 +    * 參考網址 - https://community.librenms.org/t/error-port-device/15386/33
 +    * 解決方式 : <cli>
 +mysql -u librenms -p librenms
 +CREATE TABLE port_group_port (
 +port_group_id int(10) unsigned NOT NULL,
 +port_id int(10) unsigned NOT NULL,
 +PRIMARY KEY (port_group_id,port_id),
 +KEY port_group_port_port_group_id_index (port_group_id),
 +KEY port_group_port_port_id_index (port_id),
 +CONSTRAINT port_group_port_port_group_id_foreign FOREIGN KEY (port_group_id) REFERENCES port_groups (id) ON DELETE CASCADE,
 +CONSTRAINT port_group_port_port_id_foreign FOREIGN KEY (port_id) REFERENCES ports (port_id) ON DELETE CASCADE
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 +</cli>
 +  * 再次執行 ./lnms migrate 就可以修正成功
 +  * 再執行 ./validate.php 看有其他那些問題, 依照說明的語法進行修正 Exp. <cli>
 +su - root
 +setcap cap_net_raw+ep /usr/sbin/fping6
 +sudo ln -s /opt/librenms/lnms /usr/bin/lnms
 +sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
 +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/
 +</cli>
 +
 +
 +===== 由 CentOS 7 移轉至 Ubuntu 20.04 =====
 +  * 參考 [[https://docs.librenms.org/Support/FAQ/#faq24|How do I migrate my LibreNMS install to another server?]] 方式處理
 +  - 依照正常程序安裝 [[tech/librenms/ubuntu20_04|LibreNMS 在 Ubuntu 20.04]] 上
 +  - 修改 CentOs 7 與 Ubuntu 20.04 新舊主機內的 /etc/cron.d/librenms 停止 cron 執行<cli>vi /etc/cron.d/librenms</cli><file>
 +:
 +#33   */ * * *   librenms    /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1
 +#*/5  *    * * *   librenms    /opt/librenms/discovery.php -h new >> /dev/null 2>&1
 +#*/5  *    * * *   librenms    /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16
 +#*    *    * * *   librenms    /opt/librenms/alerts.php >> /dev/null 2>&1
 +#*/5  *    * * *   librenms    /opt/librenms/poll-billing.php >> /dev/null 2>&1
 +#01      * * *   librenms    /opt/librenms/billing-calculate.php >> /dev/null 2>&1
 +#*/5  *    * * *   librenms    /opt/librenms/check-services.php >> /dev/null 2>&1
 +#*    *    * * *   librenms    cd /opt/librenms/ && php artisan schedule:run >> /dev/null 2>&1
 +:
 +#15      * * *   librenms    /opt/librenms/daily.sh >> /dev/null 2>&1
 +</file>
 +  - 在 CentOS 7 舊主機內將 MySQL 資料匯出 <cli>
 +mysqldump librenms -u root -p > librenms.sql
 +</cli>
 +  - 在 Ubuntu 20.04 新主機將 librenms.sql 匯入 <cli>
 +scp [email protected]:/root/librenms.sql .
 +mysql -u root -p librenms < librenms.sql
 +</cli>
 +  - 將 CentOS 7 舊主機內的 rrd 目錄內的檔案複製到 Ubuntu 20.04 新主機內, @CentOs 7<cli>
 +cd /opt/librenms/
 +tar cvf rrd.tar rrd
 +</cli>@Ubuntu 20.04<cli>
 +cd /opt/librenms/
 +scp [email protected]:/opt/librenms/rrd.tar .
 +tar xvf rrd.tar
 +</cli>
 +  - 將 CentOS 7 舊主機內的 .env 和 config.php 檔案複製到 Ubuntu 20.04 新主機內, @Ubunutu 20.04<cli>
 +cd /opt/librenms/
 +scp [email protected]:/opt/librenms/.env .
 +scp [email protected]:/opt/librenms/config.php .
 +chown -R librenms:librenms /opt/librenms
 +</cli>
 +  - 檢查 Ubuntu 20.04 新主機內的安裝狀態 <cli>
 +su - librenms
 +./validate.php
 +</cli>
 +  - 修改 Ubuntu 20.04 新主機內的 /etc/cron.d/librenms 啟動 cron 執行<cli>vi /etc/cron.d/librenms</cli><file>
 +:
 +33   */ * * *   librenms    /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1
 +*/5  *    * * *   librenms    /opt/librenms/discovery.php -h new >> /dev/null 2>&1
 +*/5  *    * * *   librenms    /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16
 +*    *    * * *   librenms    /opt/librenms/alerts.php >> /dev/null 2>&1
 +*/5  *    * * *   librenms    /opt/librenms/poll-billing.php >> /dev/null 2>&1
 +01      * * *   librenms    /opt/librenms/billing-calculate.php >> /dev/null 2>&1
 +*/5  *    * * *   librenms    /opt/librenms/check-services.php >> /dev/null 2>&1
 +*    *    * * *   librenms    cd /opt/librenms/ && php artisan schedule:run >> /dev/null 2>&1
 +:
 +15      * * *   librenms    /opt/librenms/daily.sh >> /dev/null 2>&1
 +</file>
 +
 +===== 升級 php 至 8.1 以上版本 =====
 +  * 今天看到這訊息
 +<note>
 +Error: PHP version too low 
 +PHP version 8.1 is the minimum supported version as of September, 2022. We recommend you update to PHP a supported version of PHP (8.1 suggested) to continue to receive updates. If you do not update PHP, LibreNMS will continue to function but stop receiving bug fixes and updates.
 +
 +2022-09-27 00:00:00 | Source: daily.sh
 +</note>
 +  * 檢查作業系統 -> Ububtu 20.04 / php 7.4 / nginx 1.18<cli>
 +root@ct-librenms:~# cat /etc/issue
 +Ubuntu 20.04.4 LTS \n \l
 +root@ct-librenms:~# php -v
 +PHP 7.4.3 (cli) (built: Jun 13 2022 13:43:30) ( NTS )
 +Copyright (c) The PHP Group
 +Zend Engine v3.4.0, Copyright (c) Zend Technologies
 +    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
 +root@ct-librenms:~# nginx -v
 +nginx version: nginx/1.18.0 (Ubuntu)
 +</cli>
 +  * 進行升級 ref - https://www.linuxcapable.com/how-to-install-php-8-1-on-ubuntu-20-04/ <cli>
 +apt update && apt upgrade -y
 +apt install software-properties-common && add-apt-repository ppa:ondrej/php -y
 +apt update && apt upgrade -y
 +apt install php8.1 php8.1-fpm php8.1-cli php8.1-gd php8.1-curl php8.1-dom php8.1-xml php8.1-mysql php8.1-mbstring -y
 +apt autoremove -y
 +systemctl status php8.1-fpm
 +systemctl restart nginx
 +</cli><cli>
 +root@ct-librenms:~# php --version
 +PHP 8.1.10 (cli) (built: Sep 18 2022 10:25:43) (NTS)
 +Copyright (c) The PHP Group
 +Zend Engine v4.1.10, Copyright (c) Zend Technologies
 +    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
 +</cli>
 +  * 更換 php-fpm 的版本設定
 +    * 查看目前啟動的 php-fpm 狀況<cli>
 +root@ct-librenms:~# ps -ef |grep php-fpm
 +root         133        0 09:05 ?        00:00:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
 +root         134        0 09:05 ?        00:00:00 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
 +www-data     161     134  0 09:05 ?        00:00:00 php-fpm: pool www
 +www-data     163     134  0 09:05 ?        00:00:00 php-fpm: pool www
 +:
 +</cli>
 +    * 關閉 7.4 版的 php-fpm<cli>
 +root@ct-librenms:~# systemctl stop php7.4-fpm.service 
 +root@ct-librenms:~# systemctl disable php7.4-fpm.service 
 +Synchronizing state of php7.4-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install.
 +Executing: /lib/systemd/systemd-sysv-install disable php7.4-fpm
 +Removed /etc/systemd/system/multi-user.target.wants/php7.4-fpm.service.
 +</cli>
 +    * 確認 8.4 版的 php-fpm socket 檔案<cli>
 +root@ct-librenms:/etc/nginx/conf.d# ls -lt /run/php/php
 +php-fpm.sock     php8.1-fpm.pid   php8.1-fpm.sock  
 +root@ct-librenms:/etc/nginx/conf.d# ls -lt /run/php/php-fpm.sock 
 +lrwxrwxrwx 1 root root 30 Sep 29 09:05 /run/php/php-fpm.sock -> /etc/alternatives/php-fpm.sock
 +root@ct-librenms:/etc/nginx/conf.d# ls -lt /run/php/php8.1-fpm.sock 
 +srw-rw---- 1 www-data www-data 0 Sep 29 09:05 /run/php/php8.1-fpm.sock
 +</cli> 所以只要設定是 /run/php/php-fpm.sock 就可以正確連上 8.4 版 php-fpm
 +  * 將 nginx 內的 librenms 網站設定改用新板 php-fpm <cli>
 +vi /etc/nginx/conf.d/librenms.conf
 +</cli><file>
 +:
 + }
 + location ~ [^/]\.php(/|$) {
 +  fastcgi_pass unix:/run/php/php-fpm.sock;
 +  fastcgi_split_path_info ^(.+\.php)(/.+)$;
 +:
 +</file>
 +  * 重啟 nginx <cli>
 +systemctl restart nginx.service 
 +</cli>
 +  * 執行 librenms 的設定檢查<cli>
 +su - librenms
 +./validate.php
 +</cli><cli>
 +librenms@ct-librenms:~$ ./validate.php 
 +====================================
 +Component | Version
 +--------- | -------
 +LibreNMS  | 22.9.0-5-g66790e7e8
 +DB Schema | 2022_09_03_091314_update_ports_adsl_table_with_defaults (246)
 +PHP       | 8.1.11
 +Python    | 3.8.10
 +Database  | MariaDB 10.3.34-MariaDB-0ubuntu0.20.04.1
 +RRDTool   | 1.7.2
 +SNMP      | 5.8
 +====================================
 +
 +[OK]    Composer Version: 2.4.2
 +[OK]    Dependencies up-to-date.
 +:
 +:
 +OK]    Database schema correct
 +[FAIL]  Time between this server and the mysql database is off
 + Mysql time 2022-10-04 18:40:56
 + PHP time 2022-10-04 10:40:56
 +[FAIL]  Missing PHP extension: mbstring
 +        [FIX]: 
 +        Please install mbstring
 +[FAIL]  You have no timezone set for php.
 +        [FIX]: 
 +        https://php.net/manual/en/datetime.configuration.php#ini.date.timezone
 +[OK]    Active pollers found
 +:
 +[OK]    rrdtool version ok
 +[WARN]  Your install is over 24 hours out of date, last update: Mon, 26 Sep 2022 13:52:15 +0000
 +        [FIX]: 
 +        Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.
 +[WARN]  Your local git contains modified files, this could prevent automatic updates.
 +        [FIX]: 
 +        You can fix this with ./scripts/github-remove
 +        Modified Files:
 +         bootstrap/cache/.gitignore
 +         logs/.gitignore
 +         storage/app/.gitignore
 +         storage/app/public/.gitignore
 +         storage/debugbar/.gitignore
 +         storage/framework/cache/.gitignore
 +         storage/framework/cache/data/.gitignore
 +         storage/framework/sessions/.gitignore
 +         storage/framework/testing/.gitignore
 +         storage/framework/views/.gitignore
 +         storage/logs/.gitignore
 +[FAIL]  We have found some files that are owned by a different user than 'librenms', this will stop you updating automatically and / or rrd files being updated causing graphs to fail.
 +        [FIX]: 
 +        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/
 +        Files:
 +         /opt/librenms/logs/.librenms.log.swp
 +</cli>
 +  * 依照上述的修正建議進行修正<cli>
 +su - root
 +vi /etc/php/8.1/fpm/php.ini
 +----
 +:
 +[Date]
 +; Defines the default timezone used by the date functions
 +; https://php.net/date.timezone
 +date.timezone = "Asia/Taipei"
 +:
 +----
 +vi /etc/php/8.1/cli/php.ini
 +----
 +:
 +[Date]
 +; Defines the default timezone used by the date functions
 +; https://php.net/date.timezone
 +date.timezone = "Asia/Taipei"
 +:
 +----
 +su - librenms
 +./daily.sh
 +./scripts/github-remove -d
 +su - root
 +chown -R librenms:librenms /opt/librenms
 +chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
 +usermod -a -G librenms www-data
 +su - librenms
 +</cli><cli>
 +librenms@ct-librenms:~$ ./validate.php 
 +===========================================
 +Component | Version
 +--------- | -------
 +LibreNMS  | 22.9.0-34-ge4fdbbd82 (2022-10-04T01:55:49+08:00)
 +DB Schema | 2022_09_03_091314_update_ports_adsl_table_with_defaults (246)
 +PHP       | 8.1.11
 +Python    | 3.8.10
 +Database  | MariaDB 10.3.34-MariaDB-0ubuntu0.20.04.1
 +RRDTool   | 1.7.2
 +SNMP      | 5.8
 +===========================================
 +
 +[OK]    Composer Version: 2.4.2
 +[OK]    Dependencies up-to-date.
 +[OK]    Database connection successful
 +[OK]    Database Schema is current
 +[OK]    SQL Server meets minimum requirements
 +[OK]    lower_case_table_names is enabled
 +[OK]    MySQL engine is optimal
 +[OK]    
 +[OK]    Database schema correct
 +[OK]    MySQl and PHP time match
 +[OK]    Active pollers found
 +[OK]    Dispatcher Service not detected
 +[OK]    Locks are functional
 +[OK]    Python poller wrapper is polling
 +[OK]    Redis is unavailable
 +[OK]    rrd_dir is writable
 +[OK]    rrdtool version ok
 +</cli>
 ===== 參考網址 ==== ===== 參考網址 ====
   * https://docs.librenms.org/#Installation/Installation-CentOS-7-Nginx/   * https://docs.librenms.org/#Installation/Installation-CentOS-7-Nginx/
行 514: 行 596:
   * https://docs.librenms.org/Extensions/Services/   * https://docs.librenms.org/Extensions/Services/
   * https://support.nagios.com/forum/viewtopic.php?f=7&t=36193&start=0#_ga=1.99004318.1602829684.1486395689   * https://support.nagios.com/forum/viewtopic.php?f=7&t=36193&start=0#_ga=1.99004318.1602829684.1486395689
 +  * https://docs.librenms.org/Installation/Install-LibreNMS/
 +  * https://docs.librenms.org/Support/FAQ/#faq24
  
-{{tag>nms librenms centos7}}+{{tag>nms librenms centos7 ubuntu}}
  • tech/librenms.1610873669.txt.gz
  • 上一次變更: 2021/01/17 16:54
  • jonathan