So I am running nextcloud on Debian as a NAS and yesterday it crashed.
So I fixed the corrupt nodes, but after that MariaDB errored something like files exceeded limit, so after researching I set:
LimitNOFILE=100000
LimitMEMLOCK=100000
inside /etc/systemd/system/mysqld.service
.
But after that trying to run systemctl restart mariadb.service
, gives:
mariadb.service - MariaDB 10.3.27 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-01-05 21:48:57 CET; 33min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 5416 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 5417 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 5419 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-e
Process: 5466 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Main PID: 5466 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"
And in /var/log/mysql/error.log
:
2021-01-05 21:48:56 0 [Note] InnoDB: Using Linux native AIO
2021-01-05 21:48:56 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-01-05 21:48:56 0 [Note] InnoDB: Uses event mutexes
2021-01-05 21:48:56 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-01-05 21:48:56 0 [Note] InnoDB: Number of pools: 1
2021-01-05 21:48:56 0 [Note] InnoDB: Using SSE2 crc32 instructions
2021-01-05 21:48:56 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-01-05 21:48:56 0 [Note] InnoDB: Completed initialization of buffer pool
2021-01-05 21:48:56 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See $
2021-01-05 21:48:56 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=18460758099
2021-01-05 21:48:56 0 [Note] InnoDB: Header page consists of zero bytes in datafile: ./nextclouddb/oc_filecache.ibd, Space ID:0, F$
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:1024. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 1024. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:2048. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 2048. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:4096. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 4096. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:8192. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 8192. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:16384. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 16384. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:32768. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 32768. Possible space_id count:0
2021-01-05 21:48:56 0 [Note] InnoDB: Page size:65536. Pages to analyze:64
2021-01-05 21:48:56 0 [Note] InnoDB: Page size: 65536. Possible space_id count:0
2021-01-05 21:48:56 0 [ERROR] InnoDB: Datafile './nextclouddb/oc_filecache.ibd' is corrupted. Cannot determine the space ID from t$
2021-01-05 21:48:56 0 [ERROR] InnoDB: Tablespace 144 was not found at ./nextclouddb/oc_filecache.ibd.
2021-01-05 21:48:56 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tables$
2021-01-05 21:48:56 0 [ERROR] InnoDB: Plugin initialization aborted with error Tablespace not found
2021-01-05 21:48:56 0 [Note] InnoDB: Starting shutdown...
2021-01-05 21:48:57 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-01-05 21:48:57 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-01-05 21:48:57 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-01-05 21:48:57 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2021-01-05 21:48:57 0 [ERROR] Aborting
The important line is:
[ERROR] InnoDB: Datafile './nextclouddb/oc_filecache.ibd' is corrupted. . Cannot determine the space ID from the first 64 pages.
When trying to run occ:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:72
Stack trace:
#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1449): OC\DB\Connection->connect()
#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(892): Doctrine\DBAL\Connection->getWrappedConnection()
When trying to run mysql:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I tried researching corrupt oc filecache, but most posts suggest using occ to fix it, but occ does not work for me either.
And I can’t make a backup of the database since I can’t run mysql.
Can anyone help me with this error please?
Addition info:
Most of my files are inside smb shares and are mounted as external storage in nextcloud.
I have around 300gb of used storage in those smb shares.
I had a crontab that remove the cache and swap cache, with:
echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a