Upgrade from Ubuntu 18.04 to 20.04 Broke LibreNMS - DB issue

I upgraded to 20.04 and during the setup answered N to all the prompts to overwrite config files with new version such as Maria DB and after the upgrade I can pull up the webpage for librenms, but it is apparently unable to connect to the DB. The error I get is below. I looked through similar topics from 16.04 to 18.04, but it doesn’t seem to be relevant because I get an error when I attempt the solution. Does anyone know how to solve this?

:/var/log$ sudo apt install curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.2-cli php7.2-curl php7.2-fpm php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-snmp php7.2-xml php7.2-zip python-memcache python-mysqldb rrdtool snmp snmpd whois
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package php7.2-snmp is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘php7.2-snmp’ has no installation candidate

ERROR:

Error connecting to database

SQLSTATE[HY000] [2002] No such file or directory

Check your log for more details. (librenms.log)

If you need additional help, you can find how to get help at https://docs.librenms.org/Support.

Why are you trying to install php7.2? I thought ubuntu 20.04 has the packages for php7.4? I know php7.2 will be dropped from librenms soon (or so validate.php tells me).

I was following a similar thread where they had a DB issue from 16.04 - 18.04 since I couldn’t find my exact scenario. I’m not familiar with how the app is built or its dependencies. I was just trying to find a way to get it working again.

Any ideas?

Let me revise this question. Is there anyway I can take a backup, reinstall and restore? Or is it possible the DB completely got wiped out with a Ubuntu upgrade? This is just for a home network instance, but I’d hate to have to start from scratch again if avoidable.

My backup of the VM is too old to restore and will affect multiple other things. I’m aware I should have had a more recent backup before install, but I performed the upgrade only because Ubuntu kept crashing as a troubleshooting step.

Sorry for the very late reply (work this past month kept me too busy). I performed the exact upgrade you did and got the same results. I did manage to get it to work but the process was pretty ugly. After the system upgrade, I followed the librenms install docs for 20.04, re-modifying the (new) config files (php7.4-fpm, php7.4-cli, nginx config, etc). Once that was done, I had to manually run daily.sh to get the current codebase (now that I had php7.4). I have another librenms server to upgrade; I think I’ll backup the rrd files and the sql database and just do a clean install this time.

I forgot to add that simply upgrading the OS doesn’t install th newer packages (such as php7.4). You really need to re run the librenms install (which is why I think doing the upgrade as a clean install is the better, less stressful way to do this).

I successfully upgraded our lab Libre instance from Ubuntu 18.04 to 20.04 and it worked well for me. I did not run into any DB issues. However I did have to re-run through much of the Libre Ubuntu 20.04 install procedure to make it work after upgrading. I also ran into PHP version issues since I had manually added php7.4 before we upgraded to Ubuntu 20, and had to basically remove all PHP versions and then re-install Ubuntu 20 php7.4 from scratch.
Backup/snapshot your Libre instance before upgrading in case things go south and you need to roll back :slight_smile:
Here is my root ssh command history of the post-upgrade work that I did (with non-pertinent commands removed). Obviously this is not going to be exactly the same for everyone, but hopefully it gives an idea of what I had to to do make my upgrade successful.

 1762  do-release-upgrade
 1763  lsb_release -a
 1764  php -v
 1767  apt list --installed | grep php
 1768  apt remove php7.0-common
 1773  apt remove php7.2-common
 1775  apt remove php7.3-common
 1777  apt remove php7.4-common
 1778  sudo apt autoremove
 1779  apt list --installed | grep php
 1782  apt update
 1783  apt upgrade
 1785  apt install php-fpm
 1787  apt list --installed | grep php
 1788  cd /opt/librenms/
 1791  apt install php7.4-cli php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-snmp php7.4-xml php7.4-zip
 1792  su - librenms
 1794  ./validate.php
 1796  ./scripts/github-remove -d
 1797  ./validate.php
 1805  shutdown -r now
 1806  vi /etc/php/7.4/cli/php.ini
 1807  vi /etc/php/7.4/fpm/php.ini
 1808  cd /opt/librenms/
 1810  ./validate.php
 1811  sudo chown -R librenms:librenms /opt/librenms
 1812  sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
 1813  sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
 1814  ./validate.php
 1816  cd /etc/php/7.4/fpm/pool.d/
 1818  cp /etc/php/7.4/fpm/pool.d/www.conf /etc/php/7.4/fpm/pool.d/librenms.conf
 1820  vi librenms.conf
 1829  rm www.conf
 1835  cd /etc/nginx/conf.d/
 1837  vi librenms.conf
 1840  systemctl restart nginx
 1841  systemctl restart php7.4-fpm
 1847  vi /etc/php/7.4/fpm/pool.d/librenms.conf
 1848  systemctl restart php7.4-fpm
 1849  systemctl restart nginx
 1854  cd /opt/librenms/logs/
 1860  less access_log
 1861  less error_log
 1872  vi /etc/php/7.4/fpm/pool.d/librenms.conf
 1874  systemctl restart nginx
 1878  systemctl status oxidized
 1879  add-apt-repository universe
 1880  apt-get install ruby ruby-dev libsqlite3-dev libssl-dev pkg-config cmake libssh2-1-dev libicu-dev zlib1g-dev g++
 1881  gem install oxidized
 1882  gem install oxidized-script oxidized-web
 1883  cd /var/lib/gems/2.7.0/gems/oxidized-script-0.6.0/lib/oxidized/script
 1897  chmod 775 cli.rb
 1903  systemctl restart oxidized
 1904  systemctl status oxidized
 1905  apt install php-ldap
 1908  ./scripts/auth_test.php -d -v -u user1

Output of validate.php after the upgrade work:

$ ./validate.php

Component Version
LibreNMS 1.69
DB Schema 2020_10_21_124101_allow_nullable_ospf_columns (188)
PHP 7.4.3
Python 3.8.5
MySQL 10.3.25-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2
SNMP NET-SNMP 5.8
OpenSSL

====================================
[OK] Composer Version: 1.10.17
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct