Open jlanzobr opened 3 years ago
Hi, have the same issue with starting mysql service. My case is:
docker run -d --name="Zoneminder136" \ --net="bridge" \ --privileged="false" \ --restart="always" \ --shm-size="6G" \ -p 8443:443/tcp \ -p 9000:9000/tcp \ -e TZ="Europe/Moscow" \ -e PUID="99" \ -e PGID="100" \ -e MULTI_PORT_START="0" \ -e MULTI_PORT_END="0" \ -e NO_START_ZM="1" \ -v "/mnt/Zoneminder":"/config":rw \ -v "/mnt/Zoneminder/data":"/var/cache/zoneminder":rw \ -v "/hdd/d/zoneminder":"/hdd/d/zoneminder":rw \ dlandon/zoneminder.machine.learning
After many time, after server was restarted mysql not starting. In error logs of mysql I see next errors:
2021-09-02 8:01:14 0 [ERROR] InnoDB: Page [page id: space=0, page number=300] log sequence number 28442188 is in the future! Current system log sequence number 9926165. 2021-09-02 8:01:14 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.
Ok, so I've experienced this issue also of late. In my case the docker container would start, update and run OK restored from a backup containing 4 events archived (my snapshot).
After a certain number of events (whether spread over multiple days, or not), mariaDB would fail to connect to the DB on restart (regardless of why I restarted the container), forcing me to purge my container, restore from backup and start again.
In my case data retention was important (e.g. filter to purge events older than a certain number of days) because one would want to rely on being able to access any and all relevant events (and footage) when required.
After much searching I had found that the issue does lie with the mariadb itself and not any of the other software stack configured in this docker. A possible option forward to fix the issue would be to either: a) have the docker apt-get a specific mariadb release and (not ideal because one misses out on updates, not to mention having to wrangle version dependencies between other packages too), or b) have the docker apt-get mysql instead.
Instead, a workaround I have configured and tested (5 days so far, appears to be OK) was to throw a daily cron job to run: "docker exec -t -i Zoneminder mysqlcheck --all-databases --auto-repair --optimize --skip-write-binlog"
I configured this to run on my host to keep as much hands off altering the container as possible (other than my /mnt data).
Might be worth a try, I haven't actually run this command on a corrupt DB (because it wont run because mariadb fails to connect to the db in the first instance). Your mileage may vary.
Cheers, and many thanks for keeping this docker going @dlandon, feel free to reach out if you need a contrib to assist.
i had a similar issue just now. Restoring the db from backup after manually running the /etc/my_init.d/40_firstrun.sh
gets the db running again but my db is empty.
Here's what i did to be able to grab a dump and restore.
Im using docker-compose so added an entrypoint to my docker-compose.yml to sleep for a enough time to allow me to get a shell and do the work. my docker-compose.yml looks like this:
zoneminder:
image: dlandon/zoneminder.machine.learning
container_name: zoneminder
privileged: true
shm_size: '2gb'
hostname: zoneminder
networks:
- subnet-172-29
ports:
- 9443:443
- 9000:9000
volumes:
- /var/lib/docker/docker-md0/zoneminder/config:/config:rw
- /var/lib/docker/docker-md0/zoneminder/data:/var/cache/zoneminder:rw
environment:
- 'TZ=America/Toronto'
- 'PUID=991'
- 'PGID=996'
restart: always
entrypoint: sleep 6000000000000000000000000
then in one terminal i get a shell (docker exec -ti zoneminder /bin/bash
) and start mariadb using mysqld_safe
in a second terminal i get a shell (again docker exec -ti zoneminder /bin/bash
) and executed mysqldump zm > /tmp/zm-dump.sql
then stopped the db with mysqladmin stop
now remove the old mysql datadir mv /config/mysql /config/mysql-original && mkdir /config/mysql && chown mysql:mysql /config/mysql
then i reinstalled mysql so that i would get all the default tables in the datadir (probably a better way to do this?) apt update && apt install mariadb-server --reinstall
now manually run the /etc/my_init.d/40_firstrun.sh
script. It will start mysql with a blank db (zm will fail to start b/c it cant connect to the db yet).
create the db and user/pass with the commands:
mysql -u root -e "create database zm;"
mysql -u root -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
now restore the db mysql zm < /tmp/zm-dump.sql
restart the container, everything comes up except all my configurations are lost.
After much searching I had found that the issue does lie with the mariadb itself
@sam-mancarella Do you have a reference handy?
[user@localhost docker]$ docker exec -it zoneminder /bin/bash
root@aa16a0f9da47:/# service mysql start
root@aa16a0f9da47:/# mysql ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 104
root@aa16a0f9da47:/# service zoneminder start Starting ZoneMinder: DBD::mysql::st execute failed: Lost connection to MySQL server during query at /usr/share/perl5/ZoneMinder/Config.pm line 98. Can't execute: Lost connection to MySQL server during query at /usr/share/perl5/ZoneMinder/Config.pm line 150. BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 150. Compilation failed in require at /usr/share/perl5/ZoneMinder.pm line 33. BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder.pm line 33. Compilation failed in require at /usr/bin/zmpkg.pl line 34. BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 34. ZoneMinder failed to start