warden
warden copied to clipboard
Added ability to easily switch from mariadb to mysql8
Prior to this update one would need to edit your warden-env.yml file to be able to achieve the same.
Waiting for this PR to get merged...
Feedback from @navarr in https://github.com/swiftotter/den/issues/9#issuecomment-1181676154:
This is a good addition, although I worry about the way it exists in its current form - it's a bit of a bc break ignoring the existing MARIADB_VERSION env variable. Any old environment den env up'ed with this would see their database potentially forcibly upgraded with no downgrade path.
That's slightly less of a problem since it's a development environment instead of a production system, but still a bit of a hassle we should avoid when porting it over.
Feedback from @navarr in swiftotter#9 (comment):
This is a good addition, although I worry about the way it exists in its current form - it's a bit of a bc break ignoring the existing MARIADB_VERSION env variable. Any old environment den env up'ed with this would see their database potentially forcibly upgraded with no downgrade path. That's slightly less of a problem since it's a development environment instead of a production system, but still a bit of a hassle we should avoid when porting it over.
This should work:
# New variable present, in env; use new preset.
>: MARIADB_VERSION=10.5; MYSQL_DISTRIBUTION_VERSION=8.1; echo ${MYSQL_DISTRIBUTION_VERSION:=${MARIADB_VERSION:-10.4}}
8.1
# New variable not present, fall back to configured MARIADB_VERSION in env
>: MARIADB_VERSION=10.5; MYSQL_DISTRIBUTION_VERSION=; echo ${MYSQL_DISTRIBUTION_VERSION:=${MARIADB_VERSION:-10.4}}
10.5
# neither new preset or old exist in .env fallback to default
> MARIADB_VERSION=; MYSQL_DISTRIBUTION_VERSION=; echo ${MYSQL_DISTRIBUTION_VERSION:=${MARIADB_VERSION:-10.4}}
10.4
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@rootindex , @ihor-sviziev , when I use the new approach, which host
do I need to set in the Magento configuration? Before, it was db
. What is it now?
@norgeindian the same as before, host name didn't change
@ihor-sviziev , thanks for the fast reply.
But unfortunately, I still get an error message.
I ran warden env config
to see, what's actually happening here.
With the old setting (MARIADB_VERSION=10.3
in .env
file), I get the following:
db:
command:
- mysqld
- --max_allowed_packet=1024M
environment:
MYSQL_DATABASE: magento
MYSQL_HISTFILE: /sql_history/.sql_history
MYSQL_PASSWORD: magento
MYSQL_ROOT_PASSWORD: magento
MYSQL_USER: magento
hostname: magento1-mariadb
image: docker.io/wardenenv/mariadb:10.3
networks:
default: null
volumes:
- type: volume
source: sqlhistory
target: /sql_history
volume: {}
- type: volume
source: dbdata
target: /var/lib/mysql
volume: {}
As soon as I change the .env
file to
MYSQL_DISTRIBUTION=mysql
MYSQL_DISTRIBUTION_VERSION=8.0
and run the same command again, I get:
db:
command:
- mysqld
- --max_allowed_packet=1024M
environment:
MYSQL_DATABASE: magento
MYSQL_HISTFILE: /sql_history/.sql_history
MYSQL_PASSWORD: magento
MYSQL_ROOT_PASSWORD: magento
MYSQL_USER: magento
hostname: magento1-mariadb
image: docker.io/wardenenv/mysql:8.0
networks:
default: null
volumes:
- type: volume
source: sqlhistory
target: /sql_history
volume: {}
- type: volume
source: dbdata
target: /var/lib/mysql
volume: {}
So it seems, as if the mysql image is properly taken. But nevertheless, as soon as I try to start the n98-magerun db:console, I get the following error message:
ERROR 2005 (HY000): Unknown MySQL server host 'db' (-2)
Did I maybe forget to change something in the .env
file or do I need to do more than running warden env up --force-recreate
?
Sorry for bugging you with that, but it would be awesome, if I could get this to run.
Check the warden env logs db
, probably the pod was killed.
@lbajsarowicz , thanks, good hint. This way I found out, that some old files from the mariadb image had been the problem.
So I ran warden env down -v
to actually remove it and the error was gone.
Nevertheless, the mysql instance still does not start properly.
Using your command, I get the following:
magento-db-1 | 2023-09-08 07:03:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.34-1.el8 started.
magento-db-1 | 2023-09-08 07:03:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
magento-db-1 | 2023-09-08 07:03:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.34-1.el8 started.
magento-db-1 | 2023-09-08 07:03:48+00:00 [Note] [Entrypoint]: Initializing database files
magento-db-1 | 2023-09-08T07:03:48.845704Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
magento-db-1 | 2023-09-08T07:03:48.850744Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.34) initializing of server in progress as process 80
magento-db-1 | 2023-09-08T07:03:48.904153Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
magento-db-1 | 2023-09-08T07:03:50.559949Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
magento-db-1 | 2023-09-08T07:03:54.245528Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
magento-db-1 | 2023-09-08 07:04:00+00:00 [Note] [Entrypoint]: Database files initialized
magento-db-1 | 2023-09-08 07:04:00+00:00 [Note] [Entrypoint]: Starting temporary server
magento-db-1 | 2023-09-08T07:04:01.155434Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
magento-db-1 | 2023-09-08T07:04:01.157794Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.34) starting as process 124
magento-db-1 | 2023-09-08T07:04:01.207243Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
magento-db-1 | 2023-09-08T07:04:01.582913Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
magento-db-1 | 2023-09-08T07:04:02.043191Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
magento-db-1 | 2023-09-08T07:04:02.043240Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
magento-db-1 | 2023-09-08T07:04:02.048057Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
magento-db-1 | 2023-09-08T07:04:02.074733Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.34' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
magento-db-1 | 2023-09-08T07:04:02.074829Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
magento-db-1 | 2023-09-08 07:04:02+00:00 [Note] [Entrypoint]: Temporary server started.
magento-db-1 | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
magento-db-1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
magento-db-1 | 2023-09-08 07:04:05+00:00 [Note] [Entrypoint]: Creating database magento
magento-db-1 | 2023-09-08 07:04:05+00:00 [Note] [Entrypoint]: Creating user magento
magento-db-1 | 2023-09-08 07:04:05+00:00 [Note] [Entrypoint]: Giving user magento access to schema magento
magento-db-1 |
magento-db-1 | 2023-09-08 07:04:05+00:00 [Note] [Entrypoint]: Stopping temporary server
magento-db-1 | 2023-09-08T07:04:05.873221Z 13 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.34).
magento-db-1 | 2023-09-08T07:04:08.428625Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.34) MySQL Community Server - GPL.
magento-db-1 | 2023-09-08 07:04:08+00:00 [Note] [Entrypoint]: Temporary server stopped
magento-db-1 |
magento-db-1 | 2023-09-08 07:04:08+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
magento-db-1 |
magento-db-1 | 2023-09-08T07:04:09.174221Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
magento-db-1 | 2023-09-08T07:04:09.176462Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.34) starting as process 1
magento-db-1 | 2023-09-08T07:04:09.186270Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
magento-db-1 | 2023-09-08T07:04:09.560050Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
magento-db-1 | 2023-09-08T07:04:10.026852Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
magento-db-1 | 2023-09-08T07:04:10.026891Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
magento-db-1 | 2023-09-08T07:04:10.038483Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
magento-db-1 | 2023-09-08T07:04:10.070909Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '0.0.0.0' port: 33060, socket: /var/run/mysqld/mysqlx.sock
magento-db-1 | 2023-09-08T07:04:10.071008Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
Do you have an idea, where Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.34).
is coming from?
@norgeindian it actually fine for mysql/mariadb container - during the first start (w/o MySQL data), it creates a needed username/password/database and then automatically restarts MySQL, which you see in your log. After the automatic MySQL restart it should just work fine. This first-time initialization might just take a bit longer than usual, due to need to restart.
Note: At the end of the log you have /usr/sbin/mysqld: ready for connections.
which means it should work
@ihor-sviziev , @lbajsarowicz thanks a lot for your help. I actually had to reimport the DB and then it worked fine.