Oracle Cloud Database Migration and Integration - Hands-On Lab

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

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

Al
eja

Activity Guide
S1102505GC10
n dr
o
M

Integration
un
oz
(a
m
un
lic ozc
en 19
se 87
to @
us gm
e ai
th l.c
is o

Learn more from Oracle University at education.oracle.com


Gu m)
ide ha
. sa
no
n -tr
an
sfe
ra

Oracle DB Cloud Migration and


bl e
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-

bl e
free. If you find any errors, please report them to us in writing.

ra
Restricted Rights Notice

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

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

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

n
programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle

no
computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are
"commercial computer software" or "commercial computer software documentation" pursuant to the applicable

. sa
Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction,
duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle

ide ha
programs (including any operating system, integrated software, any programs embedded, installed or activated on
delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other

Gu m)
Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The
terms governing the U.S. Government's use of Oracle cloud services are defined by the applicable contract for such
is o
services. No other rights are granted to the U.S. Government.
th l.c
e ai

Trademark Notice
us gm

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

respective owners.
se 87

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
en 19

logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The
lic ozc

Open Group.

Third-Party Content, Products, and Services Disclaimer


un
m

This documentation may provide access to or information about content, products, and services from third parties.
(a

Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with
respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between
oz

you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred
due to your access to or use of third-party content, products, or services, except as set forth in an applicable
un

agreement between you and Oracle.


M
o

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

Table of Contents

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

bl e
Practice: Overview .......................................................................................................................... 6
Practice 1-1: Creating SSH Keys ...................................................................................................... 7

ra
sfe
Practice 1-2: Setting Up Compute Instance .................................................................................... 8
Practice 1-3: Connecting to Database and Creating Your Migration User ..................................... 11

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

n -tr
Practice 1-5: Configuring Your Host Environment ......................................................................... 15

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

. sa
Practice 1-7: Configuring the Zero Downtime Migration Template and Running the Zero

ide ha
Downtime Migration Job ................................................................................................................ 27

Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
n dr
eja
Al

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
Al
eja
ndr
o
M
un
oz
(a
m
un
lic ozc
en 19
se 87
to @
us gm
e ai
th l.c
is o
Gu m)

Copyright © 2023, Oracle and/or its affiliates.


ide ha
. sa
no
n -tr
an
sfe
ra
bl e

Oracle DB Cloud Migration and Integration – Table of Contents


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

Al
eja
ndr
o
M
un
oz
(a
m
un
lic ozc
en 19
se 87
to @
us gm
e ai
th l.c
is o
Gu m)
Migration
ide ha
. sa
no
n -tr
an
sfe
ra
Practice: Zero Downtime

bl e
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

bl e
any Exadata Database Machine in the cloud or on-premises.

ra
sfe
In this practice you will:

an
-tr
• Configure source database for your migration

n
• Prepare the host environment

no
• Set up connectivity with API & RSA keys

. sa
• Create the autonomous database credential

ide ha
• Complete the Zero Downtime Migration (ZDM) template

Gu m)
• Successfully run the migration to the target autonomous database
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
ndr
eja
Al

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.

bl e
ra
Assumptions

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

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

-tr
• Domain/Tenant

n
no
• Username

. sa
• Password

ide ha
• Compartment to be used

Gu m)
Tasks is o
th l.c
1. Sign in to your Cloud console.
e ai

2.
us gm

On the top-right corner of the console, click Developer Tools and select Cloud Shell.
3. Once the cloud shell has started, enter the following command. Choose the key name you
to @

can remember. This will be the key name you will use to connect to any compute
se 87

instances you create. Press Enter twice for no passphrase.


en 19

• mkdir .ssh
lic ozc

• cd .ssh
un

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


m

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

the key name is cloudkey.


oz

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

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

• cat cloudkey.pub
dr
n

6. Paste the content of the public key in a text editor for future usage.
eja
Al

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).

bl e
Assumptions

ra
You have downloaded the Resource Manager zip file you need to build your environment.

sfe
• livelabs-db19ccompute-0812.zip - Packaged terraform instance creation script for

an
creating the compute instance running the 19c Oracle Database

-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
ndr
eja
Al

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.

bl e
4. Click Create Stack.

ra
sfe
5. Select My Configuration, choose the .zip file button, click the Browse link and select the
zip file (livelabs-db19ccompute-0812.zip) that you downloaded. Click Select.

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

-tr
n
7. Click Next.

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

. sa
drop-down menu.

ide ha
9. Paste the SSH key you created in the previous practice.

Gu m)
10. Scroll down and select the VMStandard.2.1.
is o
11. Accept the network and click Next.
th l.c
e ai

12. Review the details and click Create.


us gm

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

again click the Apply button.


se 87

14. Inspect the log, you will notice that eight resources were created including the compute
en 19

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


lic ozc

15. Click the Navigation Menu in the upper-left corner, navigate to Compute, and
select Instances.
un
m

16. Look for the instance you just created and jot down the Public IP address.
(a

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


oz

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


un

Address>
M

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

18. When prompted, answer yes to continue connecting.


dr
n
eja
Al

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

bl e
1475 seconds (0h:24m:35s)” Do not proceed to the next step until you see this

ra
message.

sfe
20. Run the following command to verify the database with the SID ORCL is up and running.

an
• ps -ef | grep ORCL

-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm

21. Verify the listener is running.


to @

• ps -ef | grep tns


se 87
en 19
lic ozc

22. Switch to the oracle user.


un

• sudo su – oracle
m
(a

23. Set the environment variables to point to the Oracle binaries. When prompted for the SID
oz

(Oracle Database System Identifier), enter ORCL.


un

• . oraenv
M
o
dr
n
eja

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


Al

• 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

bl e
privileges, and create a sample table to track through the migration.

ra
sfe
The purpose of creating a database user and loading it with sample data is to simulate the
user and data we are looking to migrate in a practical application.

an
-tr
ZDM will be running on the same server as the source database for the purpose of this

n
workshop and resource conservation.

no
. sa
Assumptions

ide ha
You have successfully created the source compute instance running the Oracle 19c database.

Gu m)
Tasks is o
th l.c
1. Verify that you are user opc in your instance.
e ai

Switch from opc user to user oracle.


us gm

2.
• sudo su – oracle
to @
se 87

3. Set the environment variables to point to the Oracle binaries. When prompted for the SID
en 19

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


lic ozc

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

• sqlplus / as sysdba
m
(a

5. Check the current streams pool size.


oz

• show parameter stream;


un

6. Set streams pool size to 1 GB.


M

• alter system set streams_pool_size=1g scope=both;


o
dr

7. Switch the session of your container database to ORCLPDB.


n
eja

• alter session set container=ORCLPDB;


8. After connecting to your container database create the user orcl_user. If you would like
Al

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;

bl e

• grant create any directory to orcl_user;

ra
sfe
• grant dba to orcl_user;
10. Create the user movedata_user. We are using the password WELcome123ZZ again for

an
-tr
ease and consistency. You can replace WELcome123ZZ with a password of your choice.

n
Write down or save the password because you will need it later.

no
• create user movedata_user identified by WELcome123ZZ;

. sa
11. Grant the user privileges it will need for the migration.

ide ha
• grant create user to movedata_user;

Gu m)
• grant create session to movedata_user;
is o
• grant resource to movedata_user;
th l.c
e ai

• grant create table to movedata_user;


us gm

• grant unlimited tablespace to movedata_user;


to @

• grant create any directory to movedata_user;


se 87

12. Connect to your database user. Enter password WELcome123ZZ at the prompt that you
en 19

set for your user.


lic ozc

• connect movedata_user@ORCLPDB;
un

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


m

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


(a

last_name VARCHAR2(50));
oz

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


un

'Joe', 'Shmoe');
M

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


o

'John', 'Shepard');
dr
n

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


eja

'Kate', 'Tallen');
Al

• 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.



Al
16. Exit SQL.

exit
eja exit
ndr
o
M
17. Exit 'oracle' to 'opc'.

un
15. View the sample table.

oz

Practice: Zero Downtime Migration


(a
m
select * from test1;

un
lic ozc
en 19
se 87
to @
us gm
e ai
th l.c
is o
Gu m)

Copyright © 2023, Oracle and/or its affiliates.


ide ha
. sa
no
n -tr
an
sfe
ra
bl e

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.

bl e
Assumptions

ra
You have successfully completed all the previous practices.

sfe
an
Tasks

-tr
1. Log in to the Oracle Cloud.

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

. sa
3. Click Create Autonomous Database.

ide ha
4. Select the compartment allocated to you.

Gu m)
5. Give it a meaningful name. For this workshop, we are naming it TargetDB.
is o
th l.c
6. Select Data Warehouse as the workload type.
e ai

7. Choose the deployment type Shared Infrastructure.


us gm

8. Set database version to 19c.


to @

9. Set OCPU count to 1 and deselect OCPU autoscaling.


se 87

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


en 19

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


lic ozc

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


un

13. For license select License included.


m
(a

14. Click Create Autonomous Database.


oz

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

practice.
M
o
ndr
eja
Al

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)

bl e
• Create a Zero Downtime Migration (ZDM) group and user

ra
• Add directories for ZDM

sfe
• Install and Start ZDM

an
• Generate API keys

-tr
Create your OCI directories and configuration files under all three users: zdmuser,

n

no
oracle, and opc

. sa
• Create RSA keys

ide ha
Assumptions

Gu m)
You have successfully completed all the previous practices.
is o
th l.c
Tasks
e ai
us gm

Install OCI CLI


to @

1. Log in to the Oracle Cloud.


se 87

2. Open Cloud Shell and connect to compute instance.


en 19

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


lic ozc

Address>
un

3. Install OCI CLI. Respond y at the prompt.


m

• sudo yum install python36-oci-cli


(a
oz

Set ZDM Group and User and Create Directories


un

1. Run code below to add the group zdm, create the user zdmuser, and add directories for
M

the ZDM.
o
dr

• sudo groupadd zdm


n

• sudo useradd -g zdm zdmuser


eja

• sudo mkdir /u01/app/zdmhome


Al

• 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

bl e
replacing <package> with the missing package name:

ra
sudo yum install <package>

sfe
2. Exit from the remote host.

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

-tr
https://www.oracle.com/database/technologies/rac/zdm-downloads.html

n
no
For this workshop, the zip file with the binaries is named V1019875-01.zip.

. sa
4. Go back to your Cloud Shell environment and click the Hamburguer menu on the top-left
corner of Cloud Shell and click the Upload option. An upload window will appear.

ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
dr
n
eja
Al

Copyright © 2023, Oracle and/or its affiliates.

16 Practice: Zero Downtime Migration


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

bl e
ra
sfe
an
-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m

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

click Upload.
oz
un

6. Make sure you are connected to your cloudshell and not to your host compute, workshop
M

in this case.
Once you are back in your Cloud Shell root, move the file to a /tmp folder under the opc
o

7.
dr

user. Replace < sshkeyname > and < Your Compute Instance Public IP Address > with
n
eja

the key file name and IP address of your source compute instance.
Al

• scp -i ~/.ssh/<sshkeyname> V1019875-01.zip opc@<Your Compute


Instance Public IP Address>:/tmp
8. Return to your compute instance command prompt as opc.
• ssh -i ~/.ssh/<sshkeyname> opc@<Your Compute Instance Public IP
Address>

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 17


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

• 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
• cp V1019875-01.zip /u01/app/zdmdownload

bl e
• cd /u01/app/zdmdownload

ra
sfe
• unzip V1019875-01.zip

an
• cd zdm21.3

-tr
11. Install ZDM.

n
• ./zdminstall.sh setup oraclehome=/u01/app/zdmhome

no
oraclebase=/u01/app/zdmbase

. sa
ziploc=/u01/app/zdmdownload/zdm21.3/zdm_home.zip -zdm

ide ha
12. Start ZDM service.

Gu m)
• /u01/app/zdmhome/bin/zdmservice start
13. Check its status.
is o
th l.c
• /u01/app/zdmhome/bin/zdmservice status
e ai
us gm

Generating API Keys


to @

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


se 87

1.
en 19

• cd /u01/app/zdmhome
lic ozc

2. Create your .oci directory and generate your API keys. Copy the catted
oci_api_key_public.pem file to your clipboard. During the copy, include the "Begin
un

Public Key" and "End Public Key" lines.


m
(a

• mkdir .oci
oz

• cd .oci
un

• openssl genrsa -out /u01/app/zdmhome/.oci/oci_api_key.pem 2048


M

• openssl rsa -pubout -in /u01/app/zdmhome/.oci/oci_api_key.pem -


o

out /u01/app/zdmhome/.oci/oci_api_key_public.pem
dr
n

• cat oci_api_key_public.pem
eja

3. On your OCI Dashboard navigate to and click your user profile at the top-right corner.
Al

Select the top option, your username.


4. Under Resources select 'API Keys' and 'Add API Key'.
5. Paste your public OCI API key file you catted and copied to clipboard from above.
6. Click Close.

Copyright © 2023, Oracle and/or its affiliates.

18 Practice: Zero Downtime Migration


Creating Your Configuration File and Copying Your Directory
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

1. Make sure you are connected as zdmuser.


• sudo su - zdmuser
2. Cd to /u01/app/zdmhome/.oci
• cd /u01/app/zdmhome/.oci

bl e
3. Create your config file.
vi config

ra

sfe
4. The i command lets you insert text into the file.

an
5. Paste the config file preview contents that were copied to clipboard into the file.

-tr
n
6. Replace < path to your private keyfile > # TODO with:

no
/u01/app/zdmhome/.oci/oci_api_key.pem

. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19

7. Press the escape key to escape insert.


lic ozc
un

8. To save and quit vi editor type :wq!


m

Switch from zdmuser to opc.


(a

9.
oz

• exit
un

10. Go to root directory and create the .oci directory and copy the required files from
M

zdmuser.
o

• cd ~
dr
n

• mkdir .oci
eja

• cp /u01/app/zdmhome/.oci/config /home/opc/.oci
Al

• 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

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 19


11. Update the config file.
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• cd .oci
• vi config
12. Update the key_file path to ~/.oci/oci_api_key.pem and then save and quit the vi editor.
• ~/.oci/oci_api_key.pem

bl e
13. Lock the private key file.
• chmod go-rwx ~/.oci/oci_api_key.pem

ra
sfe
14. Test OCI CLI as opc. Ignore any warnings. If the output is similar to the image below, the

an
test was successful.

-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
dr
n
eja
Al

Copyright © 2023, Oracle and/or its affiliates.

20 Practice: Zero Downtime Migration


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

bl e
ra
sfe
an
-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
dr

15. Repeat the steps for oracle.


n
eja

• sudo su - oracle
Al

• cd ~
• mkdir .oci
• mkdir /u01/app/oracle/export
• cd .oci

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 21


• cp /u01/app/zdmhome/.oci/config /home/oracle/.oci
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• 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.

bl e
• ~/.oci/oci_api_key.pem

ra
17. Lock the private key file.

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

an
18. Test OCI CLI with 'oracle'.

-tr
n
• oci iam region list

no
19. Connect as zdmuser and lock the zdmuser private key file.

. sa
• exit

ide ha
• sudo su - zdmuser

Gu m)
• cd /u01/app/zdmhome/.oci
is o
• chmod go-rwx /u01/app/zdmhome/.oci/oci_api_key.pem
th l.c
e ai
us gm

Creating RSA Keys


to @

1. As zdmuser, go to the root directory and generate RSA keys. Press the Enter key three
se 87

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


en 19

• sudo su – zdmuser
lic ozc

• cd ~
un

• ssh-keygen
m

2. Switch from zdmuser to opc.


(a

• exit
oz

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


un

• cd ~/.ssh
M
o

• sudo cat /home/zdmuser/.ssh/id_rsa.pub >>


dr

/home/opc/.ssh/authorized_keys
n
eja
Al

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.


Al
eja
ndr
o
M
un
oz

Practice: Zero Downtime Migration


Switch back to zdmuser:

(a sudo su - zdmuser
m
cat authorized_keys

un
lic ozc
en 19
se 87
to @
us gm
e ai
th l.c
is o
There should now be two keys under authorized_keys:

Gu m)

Copyright © 2023, Oracle and/or its affiliates.


ide ha
. sa
no
n -tr
an
sfe
ra
bl e

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

bl e
• Creating an object storage bucket

ra
• Logging in to your migration target autonomous database and creating the credential

sfe
file you will need to connect to your OCI user

an
• Creating movedata_user in the autonomous database

-tr
n
Assumptions

no
You have successfully completed all the previous practices.

. sa
ide ha
Tasks

Gu m)
Create Authentication Token is o
th l.c
1. Go to your OCI profile by selecting the icon at the top-right corner and clicking user.
e ai
us gm

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

3. Set a description and click generate token and make sure to write down the token
se 87

displayed because you cannot get access to it again. If you lose the token, you will need to
en 19

generate a new one.


lic ozc
un

Create an Object Storage Bucket


m
(a

1. You will need an object storage bucket for your data during the migration as an
intermediary point before being transferred to your target autonomous database. In your
oz

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


un
M

2. Select 'Create Bucket'.


o

3. Fill in the details. We will be using the name ZDMBucket. Make sure Default Storage Tier
dr

is 'Standard' and Encryption is 'Encrypt using Oracle managed keys'. Other than these
n
eja

three fields, leave the rest blank and click 'Create'.


Al

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.
Fill in ADMIN for the username and the password will be WELcome123ZZ unless you set it as

bl e
4.
something different.

ra
sfe
5. Select SQL.

an
-tr
In the script below, replace <oci_user>, <oci_tenancy>, <api_private_key>,

n
and <fingerprint> with their respective information and paste it into SQL. When pasting

no
the API private key, only paste the contents, don't include "Begin RSA Private Key" and

. sa
"End RSA Private Key"

ide ha
begin
DBMS_CLOUD.CREATE_CREDENTIAL (

Gu m)
'CredentialZDM',
'<oci_user>', is o
th l.c
'<oci_tenancy>',
'<api_private_key>',
e ai

'<fingerprint>');
us gm

end;
/
to @
se 87

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


en 19

under API Keys in your OCI user profile from the previous practices.
lic ozc

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

again, in command prompt as zdmuser:


m
(a

cd /u01/app/zdmhome/.oci
oz

cat oci_api_key.pem
un

6. Select 'Run Script'.


M
o
dr

Create User in Autonomous Database


n
eja

1. You will need to precreate movedata_user in the autonomous database. Start by


Al

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


3. Create the user and grant it privileges:
Unauthorized reproduction or distribution prohibited. Copyright© 2023, Oracle University and/or its affiliates.

• create user movedata_user identified by WELcome123ZZ;


• grant dwrole to movedata_user;

bl e
ra
sfe
an
-tr
n
no
. sa
ide ha
Gu m)
is o
th l.c
e ai
us gm
to @
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
dr
n
eja
Al

Copyright © 2023, Oracle and/or its affiliates.

26 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

bl e
then running the offline logical database migration.

ra
Assumptions

sfe
an
You have successfully completed all the previous practices.

-tr
Tasks

n
no
Copy the Template File

. sa
Connect as zdmuser to the source compute.

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

Gu m)
Address> is o
th l.c
• sudo su – zdmuser
e ai

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

• cd ~
to @

• mkdir labs
se 87

• cp /u01/app/zdmhome/rhp/zdm/template/zdm_logical_template.rsp
en 19

~/labs
lic ozc

• cd labs
un

• cp zdm_logical_template.rsp zdm_logical_mv_to_adb.rsp
m

3. Go into the migration file and delete all of the existing lines.
(a

• vi zdm_logical_mv_to_adb.rsp
oz

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

type it in manually:
M

• :%d
o
dr

Paste the below contents into the empty file:


n
eja

MIGRATION_METHOD=OFFLINE_LOGICAL
Al

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>

bl e
OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_PRIVATEKEYFILE=/u01/app/zdmhome
/.oci/oci_api_key.pem

ra
sfe
OCIAUTHENTICATIONDETAILS_REGIONID=<Update>

an
-tr
n
TARGETDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

no
SOURCEDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

. sa
SOURCECONTAINERDATABASE_CONNECTIONDETAILS_BASTIONDETAILS_PORT=22

ide ha
GOLDENGATESETTINGS_REPLICAT_MAPPARALLELISM=4
GOLDENGATESETTINGS_REPLICAT_MINAPPLYPARALLELISM=4

Gu m)
GOLDENGATESETTINGS_REPLICAT_MAXAPPLYPARALLELISM=50
is o
th l.c
GOLDENGATESETTINGS_ACCEPTABLELAG=30
e ai
us gm
to @

DATAPUMPSETTINGS_JOBMODE=SCHEMA
se 87

DATAPUMPSETTINGS_DELETEDUMPSINOSS=TRUE
en 19

DATAPUMPSETTINGS_FIXINVALIDOBJECTS=TRUE
lic ozc

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_ENCRYPTION=ALL
DATAPUMPSETTINGS_DATAPUMPPARAMETERS_TABLEEXISTSACTION=TRUNCATE
un

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_IMPORTPARALLELISMDEGREE=1
m
(a

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_EXPORTPARALLELISMDEGREE=1
oz

DATAPUMPSETTINGS_DATAPUMPPARAMETERS_EXCLUDETYPELIST=user
un

DATAPUMPSETTINGS_DATABUCKET_NAMESPACENAME=<Update>
M

DATAPUMPSETTINGS_DATABUCKET_BUCKETNAME=<Update>
o

DATAPUMPSETTINGS_EXPORTDIRECTORYOBJECT_NAME=DB_EXP_DR
dr

DATAPUMPSETTINGS_EXPORTDIRECTORYOBJECT_PATH=/u01/app/oracle/export
n
eja

DATAPUMPSETTINGS_CREATEAUTHTOKEN=FALSE
Al

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


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

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

bl e
and make sure the entire text is pasted.

ra
• TARGETDATABASE_OCID: On your Autonomous Database home page

sfe
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_TENANTID: On your API key

an
configuration file preview

-tr
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_USERID: On your API key

n
no
configuration file preview
• OCIAUTHENTICATIONDETAILS_USERPRINCIPAL_FINGERPRINT: On your API key

. sa
configuration file preview

ide ha
• OCIAUTHENTICATIONDETAILS_REGIONID: On your API key configuration file

Gu m)
preview
is o
• DATAPUMPSETTINGS_DATABUCKET_NAMESPACENAME: On your object storage
th l.c
bucket homepage
e ai
us gm

• DATAPUMPSETTINGS_DATABUCKET_BUCKETNAME: On your object storage


to @

bucket homepage
se 87

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


en 19

Run the Migration Command


lic ozc

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


un
m

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


(a

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

localhost -srcauth zdmauth -srcarg1 user:opc -srcarg2


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

sudo_location:/bin/sudo -sourcedb ORCL


M
o

2. Answer the Migration Prompts.


dr
n

• orcl_user password: WELcome123ZZ


eja

• ADMIN password: WELcome123ZZ


Al

• Authentication Token: Type the token you saved earlier.


• Data Pump Encryption password: WELcome123ZZ

Copyright © 2023, Oracle and/or its affiliates.

Practice: Zero Downtime Migration 29


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

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

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

bl e
ra
sfe
an
-tr
n
no
. sa
ide ha
Gu m)
is o
Check If the Data Is Migrated to the Target Autonomous Database
th l.c
1.
e ai

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


us gm

• select * from movedata_user.test1;


to @

If you see the table, you have successfully completed the migration.
se 87
en 19
lic ozc
un
m
(a
oz
un
M
o
dr
n
eja
Al

Copyright © 2023, Oracle and/or its affiliates.

30 Practice: Zero Downtime Migration

You might also like