Amazon RDS MariaDB gives simple methods of importing knowledge into the DB and exporting knowledge from the DB. After we’re in a position to efficiently connect with the MariaDB database we are able to use CLI instruments to run the import and export instructions to get the info from different sources out and in of the RDS database.
Under are the eventualities to think about when deciding on the method to the import the info into the Amazon RDS- MariaDB database.
From an Present MariaDB database
An current MariaDB may be current on premise or in one other EC2 occasion. Diagrammatically what we do is proven under.
Making a backup from On-Premise DB
As a primary step we create a backup of the on-premise database utilizing the under command. MariaDB being a clone of MySQL, can use almost all the identical instructions as MySQL.
# mysqldump -u person -p[user_password] [database_name] > backupfile.sql
A file with title backupfile.sql is cerated which accommodates the desk construction together with the info for use.
Storing the backup file in S3.
Add the backup file created above to a pre-decided Amazon S3 bucket in the identical area the place the goal RDS MariaDB database is current.
Import knowledge from Amazon S3 to RDS- MariaDB database
You should use the next Amazon CLI command to import the info from S3 to MariaDB DB.
aws rds restore-db-instance-from-s3 --allocated-storage 125 --db-instance-identifier tddbidentifier --db-instance-class db.m4.small --engine mysql --master-user-name masterawsuser --master-user-password masteruserpassword --s3-bucket-name tpbucket --s3-ingestion-role-arn arn:aws:iam::account-number:function/rolename --s3-prefix bucketprefix --source-engine mysql --source-engine-version 5.6.27
From One other RDS- MariaDB Occasion
There could also be eventualities while you need knowledge from an current RDS MariaDB DB to be taken into one other RDS MariaDB. For instance, to cerate a Catastrophe restoration DB or create a DB just for enterprise reporting and so forth. In such state of affairs, we create learn replicas that are a replica of their supply DB after which promote that learn reproduction to a brand new DB occasion. They’re used to stop direct heavy learn from the unique supply DB after we need to copy the info.
create a read-replica
aws rds create-db-instance-read-replica --db-instance-identifier myreadreplica --source-db-instance-identifier mydbinstance
Promote a Learn reproduction to DB Occasion
Now as we’ve got the reproduction, we are able to market it to a standalone DB occasion. It will serve our finish want of importing knowledge from o RDS – MariaDB DB to a brand new one. The next command is used to finish the promotion of a learn reproduction to a db occasion.
aws rds create-db-instance-read-replica --db-instance-identifier readreplica_name --region target_region_name --db-subnet-group-name subnet_name --source-db-instance-identifier arn:aws:rds:region_name:11323467889012:db:mysql_instance1
From Any Database
With a purpose to import knowledge from some other database to Amazon RDS – MariaDB, we’ve got to make use of the amazon Knowledge Migration Service additionally known as Amazon DMS. It makes use of Schema conversion device to translate the prevailing knowledge base to a the MYSQL platform. The under diagram explains the general course of. Additionally it really works on the same precept of replication as described within the earlier part.
Exporting Knowledge from MariaDB
Exporting of knowledge from Amazon RDS Mysql DB is a straight forwards course of the place it really works on the identical replication precept we’ve got seen above. Under are the steps to hold out the export course of.
- Begin the occasion of MariaDB operating exterior to Amazon RDS.
- Designate the MariaDB DB occasion to be the replication supply.
- Use mysqldump to switch the database from the Amazon RDS occasion to the occasion exterior to Amazon RDS.
Under is the code for mysqldump command to switch the info
mysqldump -h RDS occasion endpoint -u person -p password --port=3306 --single-transaction --routines --triggers --databases database database2 --compress --compact | mysql -h MariaDB host -u grasp person -p password --port 3306