From f33977fb39832517ae53498ba18b58ffd398e49b Mon Sep 17 00:00:00 2001 From: zubairshakoorarbisoft Date: Tue, 22 Aug 2023 19:55:16 +0500 Subject: [PATCH] feat: upgrade mysql to 8.0 --- Makefile | 14 +++++++++----- configuration_files/ecommerce.yml | 2 +- configuration_files/xqueue.yml | 2 +- docker-compose.yml | 26 +++++++++++++++++++------- docs/devstack_faq.rst | 10 +++++----- load-db.sh | 2 +- update-dbs-init-sql-scripts.sh | 2 +- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 2f5cbd3afc..82e180c3a3 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ # make dev.attach.credentials # make dev.pull.registrar+cms # make dev.up.lms -# make dev.up.without-deps.lms+forum+discovery+mysql57+elasticsearch710+memcached -# make dev.restart-container.mysql57+lms +# make dev.up.without-deps.lms+forum+discovery+mysql80+elasticsearch710+memcached +# make dev.restart-container.mysql80+lms # There are also "prefix-form" targets, which are simply an alternate way to spell # the 'dev.' targets. @@ -264,7 +264,7 @@ dev.migrate.%: ## Run migrations on a service. dev.drop-db: _expects-database.dev.drop-db dev.drop-db.%: ## Irreversably drop the contents of a MySQL database in each mysql container. - docker compose exec -T mysql57 bash -c "mysql --execute=\"DROP DATABASE $*;\"" + docker compose exec -T mysql80 bash -c "mysql --execute=\"DROP DATABASE $*;\"" ######################################################################################## @@ -457,7 +457,11 @@ dev.shell.%: ## Run a shell on the specified service's container. docker compose exec $* /bin/bash dev.dbshell: - docker compose exec mysql57 bash -c "mysql" + docker compose exec mysql80 bash -c "mysql" + +DB_NAMES_LIST = credentials discovery ecommerce notes registrar xqueue edxapp edxapp_csmh dashboard analytics-api reports reports_v1 +_db_copy8_targets = $(addprefix dev.dbcopy8.,$(DB_NAMES_LIST)) +dev.dbcopyall8: | $(_db_copy8_targets) ## Copy data from old mysql 5.7 containers into new mysql8 dbs dev.dbcopy8.%: ## Copy data from old mysql 5.7 container into a new 8 db docker compose exec mysql57 bash -c "mysqldump $*" > .dev/$*.sql @@ -465,7 +469,7 @@ dev.dbcopy8.%: ## Copy data from old mysql 5.7 container into a new 8 db rm .dev/$*.sql dev.dbshell.%: ## Run a SQL shell on the given database. - docker compose exec mysql57 bash -c "mysql $*" + docker compose exec mysql80 bash -c "mysql $*" # List of Makefile targets to run static asset generation, in the form dev.static.$(service) # Services will only have their asset generation added here diff --git a/configuration_files/ecommerce.yml b/configuration_files/ecommerce.yml index 1ec3646cb7..e36bac008c 100644 --- a/configuration_files/ecommerce.yml +++ b/configuration_files/ecommerce.yml @@ -25,7 +25,7 @@ DATABASES: ATOMIC_REQUESTS: true CONN_MAX_AGE: 60 ENGINE: django.db.backends.mysql - HOST: edx.devstack.mysql57 + HOST: edx.devstack.mysql80 NAME: ecommerce OPTIONS: connect_timeout: 10 diff --git a/configuration_files/xqueue.yml b/configuration_files/xqueue.yml index 9a7df3b41e..0a648a8b11 100644 --- a/configuration_files/xqueue.yml +++ b/configuration_files/xqueue.yml @@ -5,7 +5,7 @@ DATABASES: ATOMIC_REQUESTS: true CONN_MAX_AGE: 0 ENGINE: django.db.backends.mysql - HOST: edx.devstack.mysql57 + HOST: edx.devstack.mysql80 NAME: xqueue OPTIONS: {} PASSWORD: password diff --git a/docker-compose.yml b/docker-compose.yml index 6a6b3db9aa..378d4ec746 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -298,13 +298,14 @@ services: depends_on: - lms - memcached + - mysql80 - mysql57 # Allows attachment to the credentials service using 'docker attach '. stdin_open: true tty: true environment: CACHE_LOCATION: edx.devstack.memcached:11211 - DB_HOST: edx.devstack.mysql57 + DB_HOST: edx.devstack.mysql80 SOCIAL_AUTH_EDX_OIDC_URL_ROOT: http://edx.devstack.lms:18000/oauth2 ENABLE_DJANGO_TOOLBAR: 1 DJANGO_WATCHMAN_TIMEOUT: 30 @@ -323,6 +324,7 @@ services: depends_on: - elasticsearch710 - memcached + - mysql80 - mysql57 - opensearch12 - redis @@ -332,7 +334,7 @@ services: environment: # This next DB_MIGRATION_HOST line can be removed once edx/configuration has been updated with this value for # a while and most people have had a chance to do a "make pull" to get the latest images. - DB_MIGRATION_HOST: edx.devstack.mysql57 + DB_MIGRATION_HOST: edx.devstack.mysql80 TEST_ELASTICSEARCH_URL: "edx.devstack.elasticsearch710" ENABLE_DJANGO_TOOLBAR: 1 DJANGO_WATCHMAN_TIMEOUT: 30 @@ -355,6 +357,7 @@ services: - discovery - lms - memcached + - mysql80 - mysql57 # Allows attachment to the ecommerce service using 'docker attach '. stdin_open: true @@ -382,6 +385,7 @@ services: - devpi - elasticsearch710 - lms + - mysql80 - mysql57 image: openedx/edx-notes-api-dev:${OPENEDX_RELEASE:-latest} networks: @@ -392,7 +396,7 @@ services: - "18120:18120" environment: DB_ENGINE: "django.db.backends.mysql" - DB_HOST: "edx.devstack.mysql57" + DB_HOST: "edx.devstack.mysql80" DB_NAME: "notes" DB_PASSWORD: "password" DB_PORT: "3306" @@ -433,6 +437,7 @@ services: - localstack - memcached - mongo + - mysql80 - mysql57 # Allows attachment to the LMS service using 'docker attach '. stdin_open: true @@ -469,6 +474,7 @@ services: hostname: insights.devstack.edx depends_on: - analyticsapi + - mysql80 - mysql57 - lms - memcached @@ -476,7 +482,7 @@ services: stdin_open: true tty: true environment: - DB_HOST: edx.devstack.mysql57 + DB_HOST: edx.devstack.mysql80 DB_NAME: dashboard DB_PORT: 3306 DB_USER: analytics001 @@ -528,13 +534,14 @@ services: container_name: edx.devstack.analyticsapi hostname: analyticsapi depends_on: + - mysql80 - mysql57 - elasticsearch710 command: bash -c 'source /edx/app/analytics_api/analytics_api_env && while true; do python /edx/app/analytics_api/analytics_api/manage.py runserver 0.0.0.0:19001 --settings analyticsdataserver.settings.devstack; sleep 2; done' stdin_open: true tty: true environment: - DB_HOST: edx.devstack.mysql57 + DB_HOST: edx.devstack.mysql80 DB_PORT: 3306 DB_USER: analytics001 DB_PASSWORD: password @@ -553,6 +560,7 @@ services: depends_on: - discovery - lms + - mysql80 - mysql57 - memcached - redis @@ -561,7 +569,7 @@ services: stdin_open: true tty: true environment: - DB_HOST: edx.devstack.mysql57 + DB_HOST: edx.devstack.mysql80 DB_NAME: registrar DB_PORT: 3306 DB_USER: registrar001 @@ -595,12 +603,13 @@ services: hostname: registrar-worker.devstack.edx depends_on: - lms + - mysql80 - mysql57 - redis stdin_open: true tty: true environment: - DB_HOST: edx.devstack.mysql57 + DB_HOST: edx.devstack.mysql80 DB_NAME: registrar DB_PORT: 3306 DB_USER: registrar001 @@ -633,6 +642,7 @@ services: - lms - memcached - mongo + - mysql80 - mysql57 # Allows attachment to the CMS service using 'docker attach '. stdin_open: true @@ -672,6 +682,7 @@ services: - ${DEVSTACK_WORKSPACE}/xqueue:/edx/app/xqueue/xqueue - ${PWD}/configuration_files/xqueue.yml:/edx/etc/xqueue.yml depends_on: + - mysql80 - mysql57 environment: XQUEUE_CFG: "/edx/etc/xqueue.yml" @@ -691,6 +702,7 @@ services: - ${DEVSTACK_WORKSPACE}/xqueue:/edx/app/xqueue/xqueue - ${PWD}/configuration_files/xqueue.yml:/edx/etc/xqueue.yml depends_on: + - mysql80 - mysql57 networks: default: diff --git a/docs/devstack_faq.rst b/docs/devstack_faq.rst index 1665718c8b..0e0161dd94 100644 --- a/docs/devstack_faq.rst +++ b/docs/devstack_faq.rst @@ -134,7 +134,7 @@ How do I connect to the databases from an outside editor? --------------------------------------------------------- To connect to the databases from an outside editor (such as MySQLWorkbench), -first uncomment these lines from ``docker-compose.yml``'s ``mysql57`` section +first uncomment these lines from ``docker-compose.yml``'s ``mysql80`` section .. code:: yaml @@ -145,8 +145,8 @@ Then bring your mysql container down and back up by running: .. code:: sh - docker compose stop mysql57 - docker compose up -d mysql57 + docker compose stop mysql80 + docker compose up -d mysql80 Then connect using the values below. Note that the username and password will vary depending on the database. For all of the options, see ``provision.sql``. @@ -158,7 +158,7 @@ vary depending on the database. For all of the options, see ``provision.sql``. If you have trouble connecting, ensure the port was mapped successfully by running ``make dev.ps`` and looking for a line like this: -``edx.devstack.mysql57 docker-entrypoint.sh mysql ... Up 0.0.0.0:3506→3306/tcp``. +``edx.devstack.mysql80 docker-entrypoint.sh mysql ... Up 0.0.0.0:3506→3306/tcp``. How do I build the service images myself? ----------------------------------------- @@ -209,7 +209,7 @@ To access the MySQL shell for a particular database, run: .. code:: sh - make dev.shell.mysql57 + make dev.shell.mysql80 mysql use ; diff --git a/load-db.sh b/load-db.sh index 99be594989..3863639ef1 100755 --- a/load-db.sh +++ b/load-db.sh @@ -16,6 +16,6 @@ then fi echo "Loading the $1 database..." -mysql_container=$(make --silent --no-print-directory dev.print-container.mysql57) +mysql_container=$(make --silent --no-print-directory dev.print-container.mysql80) docker exec -i "$mysql_container" mysql -uroot $1 < $1.sql echo "Finished loading the $1 database!" diff --git a/update-dbs-init-sql-scripts.sh b/update-dbs-init-sql-scripts.sh index 6d16df0dfc..6591ba24bd 100755 --- a/update-dbs-init-sql-scripts.sh +++ b/update-dbs-init-sql-scripts.sh @@ -24,7 +24,7 @@ make dev.pull.lms+ecommerce make dev.provision.services.lms+ecommerce # dump schema and data from mysql databases in the mysql docker container and copy them to current directory in docker host -MYSQL_DOCKER_CONTAINER="$(make --silent --no-print-directory dev.print-container.mysql57)" +MYSQL_DOCKER_CONTAINER="$(make --silent --no-print-directory dev.print-container.mysql80)" for DB_NAME in "${DBS[@]}"; do DB_CREATION_SQL_SCRIPT="${DB_NAME}.sql" if [[ " ${EDXAPP_DBS[@]} " =~ " ${DB_NAME} " ]]; then