Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Activity Guide
S1102505GC10
Ng
uy

Integration
en
no Hu
n- y H
tra o
ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt

Learn more from Oracle University at education.oracle.com


us ec
e h.c
th o
is m
Gu .vn
ide ) h
. as
a

Oracle DB Cloud Migration and


Copyright © 2023, Oracle and/or its affiliates.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Disclaimer

This document contains proprietary information and is protected by copyright and other intellectual property laws.
The document may not be modified or altered in any way. Except where your use constitutes "fair use" under
copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license,
post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.

The information contained in this document is subject to change without notice and is not warranted to be error-free.
If you find any errors, please report them to us in writing.

Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of

a
the United States Government, the following notice is applicable:

. as
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any

ide ) h
programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle
computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are

Gu .vn
"commercial computer software" or "commercial computer software documentation" pursuant to the applicable
Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction,

is m
duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle

th o
programs (including any operating system, integrated software, any programs embedded, installed or activated on

e h.c
delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle
data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms

us ec
governing the U.S. Government's use of Oracle cloud services are defined by the applicable contract for such services.
to svt
No other rights are granted to the U.S. Government.
se @

Trademark Notice
en nh

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
lic ng.

respective owners.
ble oa

Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used
under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo
ra (h

are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open
fe g

Group.
ns an

Third-Party Content, Products, and Services Disclaimer


tra o
n- y H

This documentation may provide access to or information about content, products, and services from third parties.
Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with
no Hu

respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between
you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred
en

due to your access to or use of third-party content, products, or services, except as set forth in an applicable
agreement between you and Oracle.
uy
Ng

1001252023
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Table of Contents

Practice: Zero Downtime Migration................................................................................................ 5


Practice: Overview .......................................................................................................................... 6
Practice 1-1: Creating SSH Keys ...................................................................................................... 7
Practice 1-2: Setting Up Compute Instance .................................................................................... 8

a
Practice 1-3: Connecting to Database and Creating Your Migration User ..................................... 11

. as
Practice 1-4: Provisioning an Autonomous Database .................................................................... 14

ide ) h
Practice 1-5: Configuring Your Host Environment ......................................................................... 15

Gu .vn
Practice 1-6: Creating the Target Autonomous Database Credentials .......................................... 24

is m
Practice 1-7: Configuring the Zero Downtime Migration Template and Running the Zero

th o
Downtime Migration Job ................................................................................................................ 27

e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

Oracle DB Cloud Migration and Integration – Table of Contents iii


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

iv
Ng
uy
en
no Hu
n- y H
tra o
ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt
us ec

Copyright © 2023, Oracle and/or its affiliates.


e h.c
th o
is m
Gu .vn
ide ) h
. as
a

Oracle DB Cloud Migration and Integration – Table of Contents


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Ng
uy
en
no Hu
n- y H
tra o
ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt
us ec
Migration
e h.c
th o
is m
Gu .vn
ide ) h
. as
a
Practice: Zero Downtime
Practice: Overview
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
With Zero Downtime Migration, you can migrate Oracle databases from on-premises, Oracle
Cloud Infrastructure Classic, or from one Oracle Cloud Infrastructure region to another. You
can move your databases to co-managed or Autonomous Database services in the cloud, or
any Exadata Database Machine in the cloud or on-premises.

In this practice you will:

a
. as
• Configure source database for your migration

ide ) h
• Prepare the host environment

Gu .vn
• Set up connectivity with API & RSA keys

is m
• Create the autonomous database credential

th o
e h.c
• Complete the Zero Downtime Migration (ZDM) template

us ec
• Successfully run the migration to the target autonomous database
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

6 Practice: Zero Downtime Migration


Practice 1-1: Creating SSH Keys
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
In this practice, you will generate and access SSH public and private keys.
IMPORTANT: If the SSH key is not created correctly, you will not be able to connect to your
environment and will get errors. Please ensure you create your key properly.

Assumptions
All information related to your Oracle Cloud Infrastructure (OCI) account, also referred to as

a
. as
Oracle Cloud account, is assigned to you. Be sure to record the following:

ide ) h
• Domain/Tenant

Gu .vn
• Username

is m
• Password

th o
e h.c
• Compartment to be used

us ec
Tasks to svt
1. Sign in to your Cloud console.
se @

On the top-right corner of the console, click Developer Tools and select Cloud Shell.
en nh

2.
lic ng.

3. Once the cloud shell has started, enter the following command. Choose the key name you
can remember. This will be the key name you will use to connect to any compute
ble oa

instances you create. Press Enter twice for no passphrase.


ra (h

• mkdir .ssh
fe g
ns an

• cd .ssh
tra o


n- y H

ssh-keygen -b 2048 -t rsa -f <<sshkeyname>>


Note: The angle brackets <<>> should not appear in your command. For this practice
no Hu

the key name is cloudkey.


en

4. Examine the two files that you just created using the ls command.
uy

5. List the content of the public key, use the cat command. For this lab, we will use
Ng

• cat cloudkey.pub
6. Paste the content of the public key in a text editor for future usage.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 7


Practice 1-2: Setting Up Compute Instance
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
In this practice, you will set up a compute instance running a preconfigured Compute and the
corresponding Virtual Cloud Network (VCN).

Assumptions
You have downloaded the Resource Manager zip file you need to build your environment.
• livelabs-db19ccompute-0812.zip - Packaged terraform instance creation script for

a
creating the compute instance running the 19c Oracle Database

. as
ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

8 Practice: Zero Downtime Migration


Tasks
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

1. Download the Resource Manager zip file you need to build your environment from
livelabs-db19ccompute-0812.zip
2. Log in to your Oracle Cloud account.
3. Click the Navigation Menu in the upper-left corner, navigate to Developer Services, and
select Stacks. Make sure you are in the compartment allocated to you.
4. Click Create Stack.
5. Select My Configuration, choose the .zip file button, click the Browse link and select the

a
zip file (livelabs-db19ccompute-0812.zip) that you downloaded. Click Select.

. as
6. Give a meaningful name for the stack. In this lab the Stack name is SourceStack.

ide ) h
7. Click Next.

Gu .vn
8. Accept the region and select your compartment. Select an availability domain from the

is m
drop-down menu.

th o
e h.c
9. Paste the SSH key you created in the previous practice.

us ec
10. Scroll down and select the VMStandard.2.1.
to svt
11. Accept the network and click Next.
se @

12. Review the details and click Create.


en nh

13. Once the stack is created, in the Stack details page click Apply. In the Apply window,
lic ng.

again click the Apply button.


ble oa

14. Inspect the log, you will notice that eight resources were created including the compute
ra (h

instance. It takes around two minutes for the resources to be created.


fe g

15. Click the Navigation Menu in the upper-left corner, navigate to Compute, and
ns an

select Instances.
tra o
n- y H

16. Look for the instance you just created and jot down the Public IP address.
no Hu

17. Launch the cloud shell and log in to your instance.



en

ssh -i ~/.ssh/<sshkeyname> opc@<Your Compute Instance Public IP


Address>
uy

Note: The angle brackets <> should not appear in your code.
Ng

18. When prompted, answer yes to continue connecting.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 9


19. From your connected session of choice tail the last 10 lines of the dbsingle.log file. This
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

file configures the database.


• tail -10 /u01/ocidb/buildsingle1.log
Note: It takes around 20 to 30 minutes the database creation process to complete.
You will get a message similar to “2023-01-17
07:31:49:[buildsingle:Time :workshop] Completed successfully in
1475 seconds (0h:24m:35s)” Do not proceed to the next step until you see this
message.
20. Run the following command to verify the database with the SID ORCL is up and running.

a
• ps -ef | grep ORCL

. as
ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh

21. Verify the listener is running.


lic ng.

• ps -ef | grep tns


ble oa
ra (h
fe g
ns an

22. Switch to the oracle user.


tra o
n- y H

• sudo su – oracle
23. Set the environment variables to point to the Oracle binaries. When prompted for the SID
no Hu

(Oracle Database System Identifier), enter ORCL.


en

• . oraenv
uy
Ng

24. Log in using SQL*Plus as the oracle user.


• sqlplus system/Ora_DB4U@localhost:1521/orclpdb
25. Exit the sqlplus session and switch back to the opc user. Verify that you are now the opc
user using command whoami.

Copyright © 2023, Oracle and/or its affiliates.

10 Practice: Zero Downtime Migration


Practice 1-3: Connecting to Database and Creating Your Migration
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

User

Overview
In this practice, you will connect to your source database as system database administrator,
create two database users to complete the migration, bestow them with the necessary
privileges, and create a sample table to track through the migration.

The purpose of creating a database user and loading it with sample data is to simulate the

a
user and data we are looking to migrate in a practical application.

. as
ZDM will be running on the same server as the source database for the purpose of this

ide ) h
workshop and resource conservation.

Gu .vn
is m
Assumptions

th o
e h.c
You have successfully created the source compute instance running the Oracle 19c database.

us ec
to svt
Tasks
se @
en nh

1. Verify that you are user opc in your instance.


lic ng.

2. Switch from opc user to user oracle.


ble oa

• sudo su – oracle
ra (h

3. Set the environment variables to point to the Oracle binaries. When prompted for the SID
fe g

(Oracle Database System Identifier) respond to the prompt with ORCL.


ns an

• . oraenv
tra o
n- y H

4. Log in to SQL as system database administrator (dba).


no Hu

• sqlplus / as sysdba
5. Check the current streams pool size.
en

• show parameter stream;


uy

Set streams pool size to 1 GB.


Ng

6.
• alter system set streams_pool_size=1g scope=both;
7. Switch the session of your container database to ORCLPDB.
• alter session set container=ORCLPDB;
8. After connecting to your container database create the user orcl_user. If you would like
you can replace WELcome123ZZ with a password of your choice. Write down or save the
password because you will need it later.
• create user orcl_user identified by WELcome123ZZ;

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 11


9. Grant the user privileges it will need for the migration.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• grant create user to orcl_user;


• grant create session to orcl_user;
• grant resource to orcl_user;
• grant create table to orcl_user;
• grant unlimited tablespace to orcl_user;
• grant create any directory to orcl_user;
• grant dba to orcl_user;

a
10. Create the user movedata_user. We are using the password WELcome123ZZ again for

. as
ease and consistency. You can replace WELcome123ZZ with a password of your choice.

ide ) h
Write down or save the password because you will need it later.

Gu .vn
• create user movedata_user identified by WELcome123ZZ;

is m
11. Grant the user privileges it will need for the migration.

th o
e h.c
• grant create user to movedata_user;

us ec
• grant create session to movedata_user;
to svt
• grant resource to movedata_user;
se @

• grant create table to movedata_user;


en nh

• grant unlimited tablespace to movedata_user;


lic ng.

• grant create any directory to movedata_user;


ble oa

12. Connect to your database user. Enter password WELcome123ZZ at the prompt that you
ra (h

set for your user.


fe g
ns an

• connect movedata_user@ORCLPDB;
tra o

13. As movedata_user, run the following code to create a sample table:


n- y H

• CREATE TABLE test1 (person_id NUMBER, first_name VARCHAR2(50),


no Hu

last_name VARCHAR2(50));

en

INSERT INTO test1 (person_id, first_name, last_name) VALUES (1,


'Joe', 'Shmoe');
uy

• INSERT INTO test1 (person_id, first_name, last_name) VALUES (1,


Ng

'John', 'Shepard');
• INSERT INTO test1 (person_id, first_name, last_name) VALUES (1,
'Kate', 'Tallen');
• INSERT INTO test1 (person_id, first_name, last_name) VALUES (1,
'Edmond', 'Dantes');
14. Check for the table name test1.
• select table_name from user_tables;

Copyright © 2023, Oracle and/or its affiliates.

12 Practice: Zero Downtime Migration


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.




16. Exit SQL.

exit
exit

Ng
uy
17. Exit 'oracle' to 'opc'.

en
15. View the sample table.

Practice: Zero Downtime Migration


no Hu
n- y H
tra o
select * from test1;

ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt
us ec

Copyright © 2023, Oracle and/or its affiliates.


e h.c
th o
is m
Gu .vn
ide ) h
. as
a

13
Practice 1-4: Provisioning an Autonomous Database
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
In this practice, you will provision a new Oracle Autonomous Data Warehouse (ADW) which will
act as the target database for this workshop.

Assumptions
You have successfully completed all the previous practices.

a
Tasks

. as
Log in to the Oracle Cloud.

ide ) h
1.

Gu .vn
2. Click the Navigation Menu, navigate to Oracle Databases, and click Autonomous Data
Warehouse.

is m
th o
3. Click Create Autonomous Database.

e h.c
4. Select the compartment allocated to you.

us ec
5. Give it a meaningful name. For this workshop, we are naming it TargetDB.
to svt
6. Select Data Warehouse as the workload type.
se @

Choose the deployment type Shared Infrastructure.


en nh

7.
Set database version to 19c.
lic ng.

8.
9. Set OCPU count to 1 and deselect OCPU autoscaling.
ble oa

10. Set Storage to 1 TB and deselect Storage autoscaling.


ra (h

11. Set admin password. For this workshop it is WELcome123ZZ.


fe g
ns an

12. Choose network access type to Secure access from everywhere.


tra o
n- y H

13. For license select License included.


14. Click Create Autonomous Database.
no Hu

15. Once the database is successfully created and is running, you can proceed to the next
en

practice.
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

14 Practice: Zero Downtime Migration


Practice 1-5: Configuring Your Host Environment
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
In this practice on your host instance, you will:

• Install Oracle Cloud Infrastructure Command Line Interface (OCI CLI)


• Create a Zero Downtime Migration (ZDM) group and user
• Add directories for ZDM
• Install and Start ZDM

a
. as
• Generate API keys

ide ) h
• Create your OCI directories and configuration files under all three users: zdmuser,

Gu .vn
oracle, and opc

is m
• Create RSA keys

th o
e h.c
Assumptions

us ec
You have successfully completed all the previous practices.
to svt
se @

Tasks
en nh

Install OCI CLI


lic ng.

1. Log in to the Oracle Cloud.


ble oa

2. Open Cloud Shell and connect to compute instance.


ra (h

• ssh -i ~/.ssh/<sshkeyname> opc@<Your Compute Instance Public IP


fe g

Address>
ns an

Install OCI CLI. Respond y at the prompt.


tra o

3.
n- y H

• sudo yum install python36-oci-cli


no Hu

Set ZDM Group and User and Create Directories


en

Run code below to add the group zdm, create the user zdmuser, and add directories for
uy

1.
Ng

the ZDM.
• sudo groupadd zdm
• sudo useradd -g zdm zdmuser
• sudo mkdir /u01/app/zdmhome
• sudo mkdir /u01/app/zdmbase
• sudo mkdir /u01/app/zdmdownload
• sudo chown zdmuser:zdm /u01/app/zdmhome
• sudo chown zdmuser:zdm /u01/app/zdmbase
• sudo chown zdmuser:zdm /u01/app/zdmdownload
Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 15


Install Zero Downtime Migration
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

1. As opc, check that the following packages are installed:


• rpm -qa | grep expect
• rpm -qa | grep glib-devel
• rpm -qa | grep oraclelinux-developer-release-el7
If any of the packages are missing run the following command
replacing <package> with the missing package name:
sudo yum install <package>
Exit from the remote host.

a
2.

. as
3. Download the ZDM binaries to your local machine from here:

ide ) h
https://www.oracle.com/database/technologies/rac/zdm-downloads.html

Gu .vn
For this workshop, the zip file with the binaries is named V1019875-01.zip.

is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

16 Practice: Zero Downtime Migration


4. Go back to your Cloud Shell environment and click the Hamburguer menu on the top-left
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

corner of Cloud Shell and click the Upload option. An upload window will appear.

a
. as
ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en

5. Click select from your computer. Select the recently ZDM downloaded binaries and
uy

click Upload.
Ng

6. Make sure you are connected to your cloudshell and not to your host compute, workshop
in this case.
7. Once you are back in your Cloud Shell root, move the file to a /tmp folder under the opc
user. Replace < sshkeyname > and < Your Compute Instance Public IP Address > with
the key file name and IP address of your source compute instance.
• scp -i ~/.ssh/<sshkeyname> V1019875-01.zip opc@<Your Compute
Instance Public IP Address>:/tmp

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 17


8. Return to your compute instance command prompt as opc.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• ssh -i ~/.ssh/<sshkeyname> opc@<Your Compute Instance Public IP


Address>
9. Switch to zdmuser.
• sudo su – zdmuser
10. CD to the /tmp folder, copy the zdm binaries to the zdmdownload file and, unzip the files
and cd to the unziped directory.
• cd /tmp

a
• cp V1019875-01.zip /u01/app/zdmdownload

. as
• cd /u01/app/zdmdownload

ide ) h
• unzip V1019875-01.zip

Gu .vn
• cd zdm21.3

is m
11. Install ZDM.

th o
e h.c
• ./zdminstall.sh setup oraclehome=/u01/app/zdmhome

us ec
oraclebase=/u01/app/zdmbase
ziploc=/u01/app/zdmdownload/zdm21.3/zdm_home.zip -zdm
to svt
12. Start ZDM service.
se @


en nh

/u01/app/zdmhome/bin/zdmservice start
lic ng.

13. Check its status.


• /u01/app/zdmhome/bin/zdmservice status
ble oa
ra (h

Generating API Keys


fe g
ns an

1. Next we generate the API Keys. As zdmuser go to the zdmhome directory.


tra o
n- y H

• cd /u01/app/zdmhome
Create your .oci directory and generate your API keys. Copy the catted
no Hu

2.
oci_api_key_public.pem file to your clipboard. During the copy, include the "Begin
en

Public Key" and "End Public Key" lines.


uy

• mkdir .oci
Ng

• cd .oci
• openssl genrsa -out /u01/app/zdmhome/.oci/oci_api_key.pem 2048
• openssl rsa -pubout -in /u01/app/zdmhome/.oci/oci_api_key.pem -
out /u01/app/zdmhome/.oci/oci_api_key_public.pem
• cat oci_api_key_public.pem
3. On your OCI Dashboard navigate to and click your user profile at the top-right corner.
Select the top option, your username.
4. Under Resources select 'API Keys' and 'Add API Key'.
Copyright © 2023, Oracle and/or its affiliates.

18 Practice: Zero Downtime Migration


5. Paste your public OCI API key file you catted and copied to clipboard from above.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

6. Click Close.

Creating Your Configuration File and Copying Your Directory


1. Make sure you are connected as zdmuser.
• sudo su - zdmuser
2. Cd to /u01/app/zdmhome/.oci
• cd /u01/app/zdmhome/.oci

a
3. Create your config file.

. as
• vi config

ide ) h
The i command lets you insert text into the file.

Gu .vn
4.
Paste the config file preview contents that were copied to clipboard into the file.

is m
5.

th o
e h.c
6. Replace < path to your private keyfile > # TODO with:
/u01/app/zdmhome/.oci/oci_api_key.pem

us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H

Press the escape key to escape insert.


no Hu

7.

To save and quit vi editor type :wq!


en

8.
uy

9. Switch from zdmuser to opc.


Ng

• exit

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 19


10. Go to root directory and create the .oci directory and copy the required files from
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

zdmuser.
• cd ~
• mkdir .oci
• cp /u01/app/zdmhome/.oci/config /home/opc/.oci
• cp /u01/app/zdmhome/.oci/oci_api_key.pem /home/opc/.oci
• cp /u01/app/zdmhome/.oci/oci_api_key_public.pem /home/opc/.oci
11. Update the config file.

a
• cd .oci

. as
• vi config

ide ) h
12. Update the key_file path to ~/.oci/oci_api_key.pem and then save and quit the vi editor.

Gu .vn
• ~/.oci/oci_api_key.pem

is m
13. Lock the private key file.

th o
e h.c
• chmod go-rwx ~/.oci/oci_api_key.pem

us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

20 Practice: Zero Downtime Migration


14. Test OCI CLI as opc. Ignore any warnings. If the output is similar to the image below, the
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

test was successful.


• oci iam region list

a
. as
ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

15. Repeat the steps for oracle.


• sudo su - oracle
• cd ~
• mkdir .oci
• mkdir /u01/app/oracle/export
Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 21


• cd .oci
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• cp /u01/app/zdmhome/.oci/config /home/oracle/.oci
• cp /u01/app/zdmhome/.oci/oci_api_key.pem /home/oracle/.oci
• cp /u01/app/zdmhome/.oci/oci_api_key_public.pem
/home/oracle/.oci
• vi config
16. Update the key_file path to ~/.oci/oci_api_key.pem and save and quit the vi editor.
• ~/.oci/oci_api_key.pem

a
17. Lock the private key file.

. as
• chmod go-rwx ~/.oci/oci_api_key.pem

ide ) h
18. Test OCI CLI with 'oracle'.

Gu .vn
• oci iam region list

is m
19. Connect as zdmuser and lock the zdmuser private key file.

th o
e h.c
• exit

us ec
• sudo su - zdmuser
to svt
• cd /u01/app/zdmhome/.oci
se @

• chmod go-rwx /u01/app/zdmhome/.oci/oci_api_key.pem


en nh
lic ng.

Creating RSA Keys


ble oa

1. As zdmuser, go to the root directory and generate RSA keys. Press the Enter key three
ra (h

times for no password and to save to /home/zdmuser/.ssh/id_rsa.


fe g


ns an

sudo su – zdmuser
tra o

• cd ~
n- y H

• ssh-keygen
no Hu

2. Switch from zdmuser to opc.


en

• exit
uy

3. Create a copy of the public key file under opc.


Ng

• cd ~/.ssh
• sudo cat /home/zdmuser/.ssh/id_rsa.pub >>
/home/opc/.ssh/authorized_keys

Copyright © 2023, Oracle and/or its affiliates.

22 Practice: Zero Downtime Migration


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

5.
4.


Ng
uy
en

Practice: Zero Downtime Migration


Switch back to zdmuser:

no Hu sudo su - zdmuser
n- y H
cat authorized_keys

tra o
ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt
There should now be two keys under authorized_keys:

us ec

Copyright © 2023, Oracle and/or its affiliates.


e h.c
th o
is m
Gu .vn
ide ) h
. as
a

23
Practice 1-6: Creating the Target Autonomous Database Credentials
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Overview
In this practice, you will be:

• Creating an authentication token for your Oracle Cloud Infrastructure (OCI) user profile
• Creating an object storage bucket
• Logging in to your migration target autonomous database and creating the credential
file you will need to connect to your OCI user

a
. as
• Creating movedata_user in the autonomous database

ide ) h
Assumptions

Gu .vn
You have successfully completed all the previous practices.

is m
th o
e h.c
Tasks

us ec
Create Authentication Token to svt
Go to your OCI profile by selecting the icon at the top-right corner and clicking user.
se @
1.
en nh

2. Under Resources at the bottom-left corner, select Auth Tokens and click Generate
Token.
lic ng.

Set a description and click generate token and make sure to write down the token
ble oa

3.
displayed because you cannot get access to it again. If you lose the token, you will need to
ra (h

generate a new one.


fe g
ns an
tra o

Create an Object Storage Bucket


n- y H

1. You will need an object storage bucket for your data during the migration as an
no Hu

intermediary point before being transferred to your target autonomous database. In your
en

OCI Dashboard: select the hamburger menu, Storage > Buckets.


uy

2. Select 'Create Bucket'.


Ng

3. Fill in the details. We will be using the name ZDMBucket. Make sure Default Storage Tier
is 'Standard' and Encryption is 'Encrypt using Oracle managed keys'. Other than these
three fields, leave the rest blank and click 'Create'.
4. On the Details page, the two most important pieces of information for us are the bucket
name and namespace which we will need later.

Copyright © 2023, Oracle and/or its affiliates.

24 Practice: Zero Downtime Migration


Log In to SQL on the Autonomous Database and Run the Credential Script
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

1. In your OCI Dashboard: select the hamburger menu, Oracle Database > Autonomous
Database.
2. Select the target database.
3. In the database details page click Database actions.
4. Fill in ADMIN for the username and the password will be WELcome123ZZ unless you set it as
something different.

5. Select SQL.

a
. as
In the script below, replace <oci_user>, <oci_tenancy>, <api_private_key>,

ide ) h
and <fingerprint> with their respective information and paste it into SQL. When pasting

Gu .vn
the API private key, only paste the contents, don't include "Begin RSA Private Key" and
"End RSA Private Key"

is m
th o
e h.c
begin
DBMS_CLOUD.CREATE_CREDENTIAL (

us ec
'CredentialZDM',
'<oci_user>', to svt
'<oci_tenancy>',
se @

'<api_private_key>',
'<fingerprint>');
en nh

end;
lic ng.

/
ble oa

<oci_user>, <oci_tenancy>, and <fingerprint> are in the Configuration File Preview


ra (h

under API Keys in your OCI user profile from the previous practices.
fe g
ns an

<api_private_key> is your API private key from the Host Environment lab. To view it
tra o

again, in command prompt as zdmuser:


n- y H
no Hu

cd /u01/app/zdmhome/.oci
cat oci_api_key.pem
en
uy

6. Select 'Run Script'.


Ng

Create User in Autonomous Database


1. You will need to precreate movedata_user in the autonomous database. Start by
deleting the script you ran in the last step.
2. Test to make sure the user doesn't already exist by running the drop command. It is fine
if it fails:
• drop user movedata_user cascade;

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 25


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

3.

26

Ng
uy
en
no Hu
n- y H
tra o
ns an
fe g
ra (h
Create the user and grant it privileges:

ble oa
grant dwrole to movedata_user;

lic ng.
en nh
se @
to svt
us ec

Copyright © 2023, Oracle and/or its affiliates.


e h.c
th o
is m
Gu .vn
ide ) h
create user movedata_user identified by WELcome123ZZ;

. as
a

Practice: Zero Downtime Migration


Practice 1-7: Configuring the Zero Downtime Migration Template and
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

Running the Zero Downtime Migration Job

Overview

In this practice, you will be configuring the template file used to inform your migration and
then running the offline logical database migration.

Assumptions

a
You have successfully completed all the previous practices.

. as
ide ) h
Tasks

Gu .vn
Copy the Template File

is m
th o
Connect as zdmuser to the source compute.

e h.c
1.
• ssh -i ~/.ssh/<sshkeyname> opc@<Your Compute Instance Public IP

us ec
Address> to svt
• sudo su – zdmuser
se @

2. As zdmuser in your compute instance command prompt, run the following commands:
en nh


lic ng.

cd ~
• mkdir labs
ble oa

• cp /u01/app/zdmhome/rhp/zdm/template/zdm_logical_template.rsp
ra (h

~/labs
fe g
ns an

• cd labs
tra o

• cp zdm_logical_template.rsp zdm_logical_mv_to_adb.rsp
n- y H

3. Go into the migration file and delete all of the existing lines.
no Hu

• vi zdm_logical_mv_to_adb.rsp
en

In vi editor, the following command deletes all of the existing lines. You will need to
uy

type it in manually:
Ng

• :%d
Paste the below contents into the empty file:

MIGRATION_METHOD=OFFLINE_LOGICAL
DATA_TRANSFER_MEDIUM=OSS
TARGETDATABASE_OCID=<Update>
TARGETDATABASE_ADMINUSERNAME=ADMIN
SOURCEDATABASE_ADMINUSERNAME=orcl_user

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 27


SOURCEDATABASE_CONNECTIONDETAILS_HOST=localhost
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

SOURCEDATABASE_CONNECTIONDETAILS_PORT=1521
SOURCEDATABASE_CONNECTIONDETAILS_SERVICENAME=ORCLPDB
OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_TENANTID=<Update>
OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_USERID=<Update>
OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_FINGERPRINT=<Update>
OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_PRIVATEKEYFILE=/u01/app/zdmhome
/.oci/oci_api_key.pem
OCIAUTHENTICATIONDETAILS_REGIONID=<Update>

a
. as
ide ) h
TARGETDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

Gu .vn
SOURCEDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

is m
SOURCECONTAINERDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

th o
GOLDENGATESETTINGS_REPLICAT_MAPPARALLELISM=4

e h.c
GOLDENGATESETTINGS_REPLICAT_MINAPPLYPARALLELISM=4

us ec
GOLDENGATESETTINGS_REPLICAT_MAXAPPLYPARALLELISM=50
to svt
GOLDENGATESETTINGS_ACCEPTABLELAG=30
se @
en nh
lic ng.

DATAPUMPSETTINGS_JOBMODE=SCHEMA
ble oa

DATAPUMPSETTINGS_DELETEDUMPSINOSS=TRUE
ra (h

DATAPUMPSETTINGS_FIXINVALIDOBJECTS=TRUE
fe g

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_ENCRYPTION=ALL
ns an

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_TABLEEXISTSACTION=TRUNCATE
tra o
n- y H

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_IMPORTPARALLELISMDEGREE=1
DATAPUMPSETTINGS_DATAPUMPPARAMETERS_EXPORTPARALLELISMDEGREE=1
no Hu

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_EXCLUDETYPELIST=user
en

DATAPUMPSETTINGS_DATABUCKET_NAMESPACENAME=<Update>
uy

DATAPUMPSETTINGS_DATABUCKET_BUCKETNAME=<Update>
Ng

DATAPUMPSETTINGS_EXPORTDIRECTORYOBJECT_NAME=DB_EXP_DR
DATAPUMPSETTINGS_EXPORTDIRECTORYOBJECT_PATH=/u01/app/oracle/export
DATAPUMPSETTINGS_CREATEAUTHTOKEN=FALSE
DATAPUMPSETTINGS_OMITENCRYPTIONCLAUSE=TRUE
DATAPUMPSETTINGS_SECUREFILELOB=TRUE
DATAPUMPSETTINGS_SKIPDEFAULTTRANSFORM=FALSE
EXCLUDEOBJECTS-1=owner:ORCL_USER, objectName:.*
EXCLUDEOBJECTS-2=owner:PDBADMIN, objectName:.*

Copyright © 2023, Oracle and/or its affiliates.

28 Practice: Zero Downtime Migration


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

DUMPTRANSFERDETAILS_PARALLELCOUNT=3
DUMPTRANSFERDETAILS_RETRYCOUNT=3
DUMPTRANSFERDETAILS_RSYNCAVAILABLE=FALSE
DUMPTRANSFERDETAILS_SOURCE_USEOCICLI=FALSE
DUMPTRANSFERDETAILS_TARGET_USEOCICLI=FALSE

4. Update the following lines in the file. Replace <Update> with the information. Be careful
and make sure the entire text is pasted.
• TARGETDATABASE_OCID: On your Autonomous Database home page

a
. as
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_TENANTID: On your API key

ide ) h
configuration file preview

Gu .vn
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_USERID: On your API key
configuration file preview

is m
th o
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_FINGERPRINT: On your API key

e h.c
configuration file preview

us ec
• OCIAUTHENTICATIONDETAILS_REGIONID: On your API key configuration file
to svt
preview
se @

• DATAPUMPSETTINGS_DATABUCKET_NAMESPACENAME: On your object storage


en nh

bucket homepage
lic ng.

• DATAPUMPSETTINGS_DATABUCKET_BUCKETNAME: On your object storage


ble oa

bucket homepage
ra (h

5. After the lines are updated, save and quit vi editor.


fe g
ns an

Run the Migration Command


tra o
n- y H

1. In command prompt, as zdmuser, run the following command:


no Hu

• /u01/app/zdmhome/bin/zdmcli migrate database -rsp


en

/home/zdmuser/labs/zdm_logical_mv_to_adb.rsp -sourcenode
uy

localhost -srcauth zdmauth -srcarg1 user:opc -srcarg2


identity_file:/home/zdmuser/.ssh/id_rsa -srcarg3
Ng

sudo_location:/bin/sudo -sourcedb ORCL

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 29


2. Answer the Migration Prompts.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• orcl_user password: WELcome123ZZ


• ADMIN password: WELcome123ZZ
• Authentication Token: Type the token you saved earlier.
• Data Pump Encryption password: WELcome123ZZ

Check on Job Status

1. You can confirm the job completion by running the following command:

a
. as
• /u01/app/zdmhome/bin/zdmcli query job -jobid 1

ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

30 Practice: Zero Downtime Migration


Check If the Data Is Migrated to the Target Autonomous Database
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

1. In your autonomous database SQL command prompt, run the command:


• select * from movedata_user.test1;
If you see the table, you have successfully completed the migration.

a
. as
ide ) h
Gu .vn
is m
th o
e h.c
us ec
to svt
se @
en nh
lic ng.
ble oa
ra (h
fe g
ns an
tra o
n- y H
no Hu
en
uy
Ng

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 31


Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

32
Ng
uy
en
no Hu
n- y H
tra o
ns an
fe g
ra (h
ble oa
lic ng.
en nh
se @
to svt
us ec

Copyright © 2023, Oracle and/or its affiliates.


e h.c
th o
is m
Gu .vn
ide ) h
. as
a

Practice: Zero Downtime Migration

You might also like