Nextcloud problem under Nethserver

You had nethserver-nextcloud-1.16.6-1.ns7.noarch (Nextcloud 20.0.8) and updated to 1.19.0-1.ns7.noarch (Nextcloud 22.2.0) so jumped over (skipped) one major release (Nexcloud 21.x) which could be, for instance nethserver-nextcloud-1.17.1-1.ns7.noarch (Nextcloud 21.0.3) according to the package changelog.

As pointed by Andy, usually the data remains (/var/lib/nethserver/nextcloud/), and also the database (in another path) which holds other settings/data than documents. The dbuser is commonly nextcloud, the dbpassword shall be found at /var/lib/nethserver/secrets. If all of the above is present, you could rename the bad config.php file (and restore it from a backup if you can) and then do a downgrade to nethserver-nextcloud-1.17.1-1.ns7.noarch, unless I’m missing something else.

2 Likes

Hello Marc and Andy,

it’s me again… I could not work on my problem last week, so it still exists…

If I understand Marc / the wiki correctly, I should get a correct config.php, which was not easy… I modified it manually. At the moment there is an “Internal Server Error” when I open the Nextcloud page in a web browser.

The config.php looks like this:

<?php
$CONFIG = array (
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'yyyyyyyyyyyyyyyyyyyyyyyy',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'xxxxxxx.dyndns.info',
  ),
  'datadirectory' => '/var/lib/nethserver/nextcloud/',
  'dbtype' => 'mysql',
  'version' => '20.0.8.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'zzzzzzzzzzzzzzzzzzz',
  'installed' => true,
  'instanceid' => 'oc44kna9hr42',

A backup of the nextcloud directories in /usr/share and /var/lib/nethserver is running… and now I should perform a downgrade? I’m not sure about the version number…

And second question if that does not work: Andy said to deinstall nextcloud in the Software Center… but it is not there. In the main screen I saw 26 applications but now Nextcloud… then I clicked on “Reload”, the cache was cleared… and now I have zero applications???

Everything is quite strange…

Thank you and best regards,

Frank

Sorry for the missing line breaks…

About formatting you can find some tips here:

The config file is missing at least the closing parenthesis ); for the main $CONFIG array variable. Maybe that’s why you get the error page.

Have not tested but I think a config.php file is not forcibly required but highly recommended to keep the same config and even more if using file encryption on Nextcloud.

Hello Marc, sorry, I did not post the full config.php, as the rest was not modified.

Shall I try the downgrade? I’m not sure…

I can not find the software in the cockpit interface… and therefore cannot uninstall ist.

Or should I use the yum command as in

OK, I’m trying to remember where we left of the other time…
If the config file is complete it is possible that it prevents the new version of nextcloud to connect to the database due to changes in underlying mariadb version on how nextcloud connects to it.

First, we can try to check if with the update the database was moved/imported to a new instance.

# listing related database services
systemctl | grep mariadb
systemctl | grep mysqld

# checking status of new mariadb version used by nextcloud
systemctl status -l rh-mariadb105-mariadb@nextcloud.service

# list of databases on new mariadb instance
/opt/rh/rh-mariadb105/root/bin/mysqlshow --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock"

# list of databases on old mariadb instance
mysqlshow

# list of database users on new mariadb instance
/opt/rh/rh-mariadb105/root/bin/mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e 'SELECT user FROM mysql.user'

# list of database users on old mariadb instance
mysql -e 'SELECT user FROM mysql.user'
1 Like

Hello Marc,

thanks a lot… here is the output of the commands.

Best regards,

Frank


systemctl | grep mariadb:

rh-mariadb105-mariadb@nextcloud.service                                                   loaded active running   MariaDB 10.5 database server
system-rh\x2dmariadb105\x2dmariadb.slice                                                  loaded active active    system-rh\x2dmariadb105\x2dmariadb.slice

systemctl | grep mysqld

mysqld.service             loaded active running   MariaDB database server
systemctl status -l rh-mariadb105-mariadb@nextcloud.service
● rh-mariadb105-mariadb@nextcloud.service - MariaDB 10.5 database server
   Loaded: loaded (/etc/systemd/system/rh-mariadb105-mariadb@.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/rh-mariadb105-mariadb@nextcloud.service.d
           └─nethserver.conf
   Active: active (running) since Tue 2021-11-16 22:04:26 CET; 57min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 2502 ExecStartPost=/usr/bin/scl enable $RH_MARIADB105_SCLS_ENABLED -- /opt/rh/rh-mariadb105/root/usr/libexec/mysql-check-upgrade --defaults-group-suffix=.%I (code=exited, status=0/SUCCESS)
  Process: 2237 ExecStartPre=/usr/bin/scl enable $RH_MARIADB105_SCLS_ENABLED -- /opt/rh/rh-mariadb105/root/usr/libexec/mysql-prepare-db-dir --defaults-group-suffix=.%I %n (code=exited, status=0/SUCCESS)
  Process: 1958 ExecStartPre=/usr/bin/scl enable $RH_MARIADB105_SCLS_ENABLED -- /opt/rh/rh-mariadb105/root/usr/libexec/mysql-check-socket --defaults-group-suffix=.%I (code=exited, status=0/SUCCESS)
  Process: 1117 ExecStartPre=/usr/bin/scl enable $RH_MARIADB105_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mariadb105 (code=exited, status=0/SUCCESS)
 Main PID: 2290 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/system-rh\x2dmariadb105\x2dmariadb.slice/rh-mariadb105-mariadb@nextcloud.service
           └─2290 /opt/rh/rh-mariadb105/root/usr/libexec/mysqld --defaults-group-suffix=.nextcloud --basedir=/opt/rh/rh-mariadb105/root/usr

Nov 16 22:04:14 aichtalinfo.aichtal.info systemd[1]: Starting MariaDB 10.5 database server...
Nov 16 22:04:20 aichtalinfo.aichtal.info scl[2237]: Database MariaDB is probably initialized in /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud already, nothing is done.
Nov 16 22:04:20 aichtalinfo.aichtal.info scl[2237]: If this is not the case, make sure the /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud is empty before running mysql-prepare-db-dir.
Nov 16 22:04:22 aichtalinfo.aichtal.info mysqld-scl-helper[2290]: 2021-11-16 22:04:22 0 [Note] /opt/rh/rh-mariadb105/root/usr/libexec/mysqld (mysqld 10.5.9-MariaDB) starting as process 2290 ...
Nov 16 22:04:26 aichtalinfo.aichtal.info systemd[1]: Started MariaDB 10.5 database server.
/opt/rh/rh-mariadb105/root/bin/mysqlshow --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock"
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| nextcloud          |
| performance_schema |
+--------------------+
mysqlshow 
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| roundcubemail      |
| sogo               |
+--------------------+
/opt/rh/rh-mariadb105/root/bin/mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e 'SELECT user FROM mysql.user'
+-------------+
| User        |
+-------------+
| mariadb.sys |
| mysql       |
| nextcloud   |
| root        |
+-------------+
mysql -e 'SELECT user FROM mysql.user'
+---------------+
| user          |
+---------------+
| root          |
| root          |
| nextcloud     |
| root          |
| roundcubemail |
| sogo          |
+---------------+

It shows the database and user were imported to mariadb 10.5
I suggest to run:

signal-event nethserver-nextcloud-update

…to see if it is able to update the config.php file with the correct database connection (if not we do it manually), after that you might see the nextcloud landing page but with an error (we can continue from there).

Ok, thanks…

nothing seems to happen, when I run the command… although…

-rw-r----- 1 apache apache  1053 Nov 16 15:01 config.php

I have several versions of this file… all owned by the root user… now the apache user and group is there… but the time stamp is from the afternoon… don’t know. I changed permissions to 644, just as the sample file… but still the “Internal Server Error”.

Permissions above marked on red are ok.
Let’s do the changes manually, so config.php has these entries in place of the same old ones:

  'dbhost' => 'localhost:/run/rh-mariadb105-mariadb/nextcloud-mysql.sock',
  'mysql.utf8mb4' => true,

If I’m not mistaken that’s all we need to change.
After those changes you can run:

occ upgrade

Hmmm, ok, the first lines show the following entries… looks like a permission or password problem… ?

The output of occ upgrade is:

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user 'nextcloud'@'localhost' (using password: YES) in /usr/share/nextcloud/lib/private/DB/Connection.php:87
Stack trace:
#0 /usr/share/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Connection->connect()
#1 /usr/share/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\DBAL\Connection->getWrappedConnection()
.... 
#40 {main}[root@aichtalinfo config]#

Try restarting the related services

I obviously took the secret of the file mysql … now I tried with the file nextcloud… and can connect to mysql.

The result of occ upgrade now is:

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Turned on maintenance mode
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Resetting log level

We are almost there. Go with the experimental option described in the wiki and you are good to go, I hope.

And accessing https://xxx.dyndns.info/nextcloud shows the screen again, asking to update to Nextcloud 22.2.0.

could that be a problem of the version, that I currently have in the config.php?

 'version' => '20.0.8.1',

Yes, it is related but first it must go through some previous upgrade steps, before changing the version.

yum downgrade showed at the end:

Transaction check error:
  package nethserver-nextcloud-1.19.0-1.ns7.noarch (which is newer than nethserver-nextcloud-1.17.1-1.ns7.noarch) is already installed