My main LibreNMS stopped working suddenly over the weekend (not sure when exactly), but I checked it by the end of business day on Friday the 11th of June 2021, and it was all good.
Today, i’m getting “Whoops, looks like something went wrong. Check your librenms.log.”
Validation shows all good, and the only warning i’m getting is that my Database is not the latest supported version:
#######################################################################
$ ./validate.php
[OK] Composer Version: 2.1.3
[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
[INFO] Detected Python Wrapper
[OK] Connection to memcached is ok
[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.isis_adjacencies’ doesn’t exist at /opt/librenms/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:79)
Which raises a question.
Any help/advice please ?
Was there any updates over the weekend that might have triggered the issue ?
The last time I updated my master and pollers last week, they were on version 21.5.1-25-g1e05cdc57 (my remote pollers are still on this version as they are not set to update automatically).
However, my master server is now on version 21.5.1-32-g20c44b85c which is set to update automatically, and was most probably updated over the weekend.
SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsigned not null au
to_increment primary key, name varchar(255) not null, desc varchar(255) null) default character set utf8mb4 collate ‘utf8mb4_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
…however, I am not able to modify the port_groups table
Mine is running on Ubuntu 18.04, and got the same behavior. I don’t think it’s Ubuntu version, but rather the last version of LibreNMS 21.5.1-32-g20c44b85c
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, name varchar(255) not null, desc varchar(255) nu
ll) default character set utf8mb4 collate ‘utf8mb4_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
Once this is addressed, then I hope the rest will follow.
Your MySQL/MariaDB server version is too low and migrations failed. I have submitted a new error screen to better explain this.
There was an update that adds a query that checks a new table that doesn’t exist yet on your db server…
Resolution:
Install supported version of MySQL (5.7.7) or MariaDB (10.2.2)
Delete the partially migrated port_groups table ONLY IF IT IS WHERE YOU ARE STUCKlnms tinker --execute="DB::statement('DROP TABLE port_groups');"
Thanks for your reply.
Unfortunately I still face the same issue. Here what i’ve done so far:
Upgrade MariaDB to 10.5 following their official documentation. mariaDB is up and running:
# mysql --version
mysql Ver 15.1 Distrib 10.5.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
# systemctl status mariadb.service
● mariadb.service - MariaDB 10.5.10 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Wed 2021-06-16 09:37:15 UTC; 4min 44s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 7669 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Process: 7662 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 7484 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSRE
Process: 7476 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 7464 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 7579 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 50 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─7579 /usr/sbin/mariadbd
I have run the lnms tinker command as librenms user (no output was shown, nor an error message), then run ./lnms migrate:
$ ./lnms migrate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
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 unsigned not null auto_increment primary key
, `name` varchar(255) not null, `desc` varchar(255) null) default character set utf8mb4 collate 'utf8mb4_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
Running ./valiadte.php:
$ ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS | 21.5.1-34-g048938276
DB Schema | 2020_12_14_091314_create_port_group_port_table (205)
PHP | 7.4.20
Python | 3.6.9
MySQL | 10.5.10-MariaDB-1:10.5.10+maria~bionic
RRDTool | 1.7.0
SNMP | NET-SNMP 5.7.3
====================================
[OK] Composer Version: 2.1.3
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate
[INFO] Detected Python Wrapper
[OK] Connection to memcached is ok
Hi,
Like all of you, I use to have the same problem whit my LibreNMS. MariaDB was out of update and when I was trying to do ./lnms migrate I had this error “SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'port_groups ’ already exists” on Ubunto Server 18.4.
1- I update MariaDB to 10.5.10-MariaDB-1:10.5.10+maria~bionic
2- When I did ./lnms migrate… the same error
[OK] Composer Version: 2.1.3
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate
[FAIL] You need to run this script as ‘librenms’ or root
3- As Murrant commented. I delete the table
$ sudo mysql -u root
MariaDB [(none)]> SHOW DATABASES;
MariaDB [(none)]> use librenms;
MariaDB [librenms]> show tables;
MariaDB [librenms]> DROP TABLE port_groups;
[[email protected] ~]# mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)
[[email protected] ~]# mysqld --print-defaults
mysqld would have been started with the following arguments:
–datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --symbolic-links=0 --innodb_file_per_table=1 --sql-mode= --lower_case_table_names=0
Expected the following but ran it anyway:
[[email protected] ~]# su librenms
bash-4.2$ /opt/librenms/lnms migrate
Application In Production! *
Do you really wish to run this command? (yes/no) [no]:
yes
In Connection.php line 678:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = librenms and table_name =
migrations and table_type = ‘BASE TABLE’)
In Exception.php line 18:
SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 39:
SQLSTATE[HY000] [2002] Connection refused
Haven’t found anything on line to cure this. Sigh…