2021/05/31

今天打開librenms的時候發現無法進入

出現錯誤訊息






查了一下log 發現  5/30 03:00左右就出問題了

重開後正常

但跑了一下valid.php出現以下錯誤


./validate.php

====================================

Component | Version

--------- | -------

LibreNMS  | 21.5.1-16-g15da7fa

DB Schema | 2020_12_14_091314_create_port_group_port_table (205)

PHP       | 7.4.19

Python    | 3.6.8

MySQL     | 5.5.68-MariaDB

RRDTool   | 1.4.8

SNMP      | NET-SNMP 5.7.2

====================================


[OK]    Composer Version: 2.0.14

[OK]    Dependencies up-to-date.

[OK]    Database connection successful

[FAIL]  MariaDB version 10.2.2 is the minimum supported version as of March, 2021. Update MariaDB to a supported version 10.5 suggested).

[FAIL]  Your database is out of date!

        [FIX]:

        ./lnms migrate

[WARN]  Global lnms shortcut not installed. lnms command must be run with full path

        [FIX]:

        sudo ln -s /opt/librenms/lnms /usr/bin/lnms

[WARN]  Bash completion not installed. lnms command tab completion unavailable.

        [FIX]:

        sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/

[WARN]  Log rotation not enabled, could cause disk space issues

        [FIX]:

        sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

[WARN]  Your install is over 24 hours out of date, last update: Sat, 29 May 2021 14:08:28 +0000

        [FIX]:

        Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.

[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/config.php_20201107

         /opt/librenms/html/plugins/Weathermap/nkhc.png

         /opt/librenms/html/plugins/Weathermap/nkhc.html



除了mariadb升級外
其他先手動做完沒問題

想說     ./lnms migrate 應該會跟db有關
所以先升db 好了

先備db

    $ mysqldump -u root -p --all-database > mysql-backup.sql

備config

# cp /etc/my.cnf /etc/my.cnf.bak

加入mariadb的repo

# vi /etc/yum.repos.d/MariaDB.repo

加入以下內容:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

停止及移除目前的 MariaDB:


    # systemctl stop mariadb
    # yum remove mariadb mariadb-server

現在開始安裝 MariaDB 10.5,

    # yum install mariadb mariadb-server

啟動 MariaDB 及設定開機自動啟動:

    # systemctl enable  mariadb
    # systemctl start  mariadb


將原來的 MariaDB 資料升級:

    # mysql_upgrade -u root -p

升級過程沒出現什麼問題
再來跑一下

        ./lnms migrate

出現以下錯誤

Migrating: 2020_12_14_091314_create_port_groups_table

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 unsi
gned not null auto_increment primary key, name varchar(255) not null, desc varchar(255) null) default character set utf8mb4 collate ‘ut
f8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists


進DB先把 port_groups drop 掉

再跑一次

        ./lnms migrate

就正常了

最後再跑一次

./valid.php

沒有任何問題

後續觀察中


https://www.opencli.com/mysql/rhel-centos7-upgrade-mariadb-to-10-5 

https://community.librenms.org/t/validation-gives-failure-to-update-mariadb-will-eventually-cause-issues-lnms-migrate-gives-error/15391

沒有留言: