Database servers cannot be resized in-place on MedStack Control, although it is a feature we intend on supporting in the near future. In order to switch between database server sizes, you'll need to:
- Provision the target database server.
- Perform a migration from the source database to the target.
- Destroy the source database server.
Migrating a database
Prerequisite: Both the source and target database instances exist.
In reference to step 2 above, migrating a database is commonly done through one of two (2) methods.
- Via MedStack Control
- Via Endpoint with Allowed IP
Via MedStack Control – Recommended
Using the container shell feature, you can use an existing service with a CLI utility deployed in a cluster to send commands to the database server.
Steps:
Note: You can grab the SSL Certificate for the connection string here for PostgreSQL db or MySQL db.
- Shell into the container where database client CLI is installed. Ideally your application container would have a database client installed.
- Grab the connection strings for the Old database that you would like to migrate the data from.
- Use a mysqldump or pg_dump CLI tool to create a backup of the database.
mysqldump -h [host] -u [user name] –p [password] [options] [database_name] [tablename] > [dumpfilename.sql]
pg_dump -h [host] -U [username] -W -F c [database_name] > backup.tar
- Grab the connection strings for the New database server.
- Use mysql or pg_restore CLI tool to restore the backup on to the new Database
- Connect to the new database from the container using the CLI.
psql -d "host=[host] port=5432 dbname=[database_name] user=[username]"
- Verify the data has been restored successfully.
- Delete the backup from container.
- Monitor the new Database server for any missing data or for stability.
- Once you are comfortable with the new database server, delete the Old database server from MedStack.
Via Endpoint with Allowed IP
An endpoint in this example could represent a local dev machine, workstation, static server, etc. which has an IP address that's allowed to connect to the database server in the cluster.
Steps:
Note: You can grab the SSL Certificate for the connection string here for PostgreSQL db or MySQL db.- Add your public IP address to the Allowed IP list on both Old and New Database server.
- Grab the connection strings for the Old database that you would like to migrate the data from.
- Connect to the Old database from your local machine. (screenshot below shows a connection to a PostgreSQL database server running on MedStack using PgAdmin tool, however same can be done with MySQL database using MySQL Workbench)
- Backup the database to your local machine.
- Grab the connection strings for the New database server.
- Connect to the New database server from you local machine.
- Restore the database backup to the new Database server.
- Verify the data has been restored successfully.
- Delete the backup from your local machine.
- Monitor the new Database server for any missing data or for stability.
- Once you are comfortable with the new database server, delete the Old database server from MedStack.
Comments
0 comments
Please sign in to leave a comment.