Following steps are implemented on the mysqlshellinstance host
Make sure you save the namespace of your bucket (in a notepad, etc). You will need it for steps 1.5 and 3.2.
You can find your namespace bucket with following command:
root@mysqlshellinstance:/home# oci os ns get
{
"data": "YourNamespaceBucket"
}
root@mysqlshellinstance:/home#
[ 1 ] Dumping data from MySQL source into Object Storage (mdsbucket)
[ 1.1 ] Download sql script test1.sql under a location from where you will start the MySQL Client (in this example, we will implement the next steps under /home folder):
root@mysqlshellinstance:/# cd /home
root@mysqlshellinstance:/home# wget https://raw.githubusercontent.com/isaac-kami/MdsReplication/main/test1.sql
[ 1.2 ] Access MySQL client that is already configured on mysqlshellinstance from the same location you saved the test1.sql script:
root@mysqlshellinstance:/home# mysql -uroot -pabc123!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
[ ... snip ... ]
mysql>
[ 1.3 ] Execute the test1.sql with "source" command for creating the test database:
[ 1.4 ] Check if database and the populated tablespace are created:
mysql> select * from testexample.exampletable;
+--------+-----------+
| name | firstname |
+--------+-----------+
| Foster | Zack |
+--------+-----------+
1 row in set (0.00 sec)
mysql>
mysql> exit
Bye
root@mysqlshellinstance:/home#
[ 1.5 ] Access mysql-shell from localhost to dump data into mdsbucket with dumpInstance() utility:
root@mysqlshellinstance:/home# mysqlsh -uroot -pabc123!
MySQL Shell 8.0.23
Copyright (c) 2016, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
WARNING: Using a password on the command line interface can be insecure.
Creating a session to 'root@localhost'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 16 (X protocol)
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
No default schema selected; type \use <schema> to set one.
MySQL localhost:33060+ ssl JS >
...using dumpInstance() utility:
MySQL localhost:33060+ ssl JS > var namespacebucket = "here your namespace"
MySQL localhost:33060+ ssl JS > util.dumpInstance("mdsobject", {osBucketName: "mdsbucket", osNamespace: namespacebucket, threads: 4, ocimds: true, compatibility: ["strip_restricted_grants"]})
When data dump transfer is done, quit the MySQL-Shell:
MySQL localhost:33060+ ssl JS > \q
Bye!
root@mysqlshellinstance:/home#
[ 2 ] Save @.json file
[ 2.1 ] With OCI CLI, check if object @.json exists in mdsbucket:
oci os object list \
--bucket-name mdsbucket |\
grep "@.json"
Possible output
root@mysqlshellinstance:/home# oci os object list \
> --bucket-name mdsbucket |\
> grep "@.json"
"name": "mdsobject/@.json",
root@mysqlshellinstance:/home#
[ 2.2 ] If present, download @.json object with following OCI command:
oci os object get \
--bucket-name mdsbucket \
--file @.json \
--name mdsobject/@.json
[ 3 ] Loading data from Bucket into MySQL DB system
[ 3.1 ] From the same location where you saved the @.json file, you must access the MDS through the mysql-shell. This time, you will be using the utility loadDump().
MySQL 10.0.1.5:33060+ ssl SQL > show global variables like 'GTID_EX%';
+----------------------------------+-------------------------------------------------------------------------------------+
| Variable_name | Value |
+----------------------------------+-------------------------------------------------------------------------------------+
| gtid_executed | 67651f74-a04b-11eb-aa1f-020017064c9a:1-10,
e8a2b443-a04b-11eb-924d-02001702b29c:1-3 |
| gtid_executed_compression_period | 0 |
+----------------------------------+-------------------------------------------------------------------------------------+
2 rows in set (0.0021 sec)
MySQL 10.0.1.5:33060+ ssl SQL >
... and quit the MySQL-Shell:
MySQL 10.0.1.5:33060+ ssl SQL > \q
Bye!
root@mysqlshellinstance:/home#