by Joel Pérez and Skant Gupta
This article shows how to use the "transportable tablespace" mode of the Data Pump feature of Oracle Database to copy an entire database from your on-premises host to an Oracle Database Cloud Service database deployment.
Note: You can use this method only if the on-premises platform is little endian and the database character sets of your on-premises database and Oracle Database Cloud Service database are compatible.
The transportable tablespace method is generally much faster than a conventional export/import of the same data because the data files containing all of the actual data are simply copied to the destination location. You use Data Pump to transfer only the metadata of the tablespace objects to the new database.
To migrate an on-premises instance of Oracle Database to a database deployment on Oracle Database Cloud Service using the Data Pump transportable tablespace method, you perform these tasks:
expdpto perform the transportable tablespace export.
impdpand connect to the database.
The following sections show a step-by-step example of the tasks required to migrate tablespaces in an on-premises instance of Oracle Database 11g Release 2 to an Oracle Database Cloud Service database using the Data Pump transportable tablespace method. However, a similar process can be used to migrate tablespaces in an on-premises instance of Oracle Database 12c Release 1 or 12c Release 2.
This example performs a migration of the TBSP_DATA and TBSP_INDEX tablespaces.
In this example, the on-premises database is on a Linux host.
[oracle@cloud ~]$ mkdir -p /u01/app/dpump
[oracle@cloud ~]$ sqlplus SYSTEM
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jun 1 01:49:18 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> CREATE DIRECTORY prem_to_cloud AS '/u01/app/dpump';
Directory created.
SQL> SELECT tablespace_name, file_name FROM dba_data_files where tablespace_name = 'TBSP_DATA';
TABLESPACE_NAME ------------------------------
FILE_NAME --------------------------------------------------------------
TBSP_DATA /u01/app/oracle/oradata/ORA11G/tbspdata01.dbf
SQL> SELECT tablespace_name, file_name FROM dba_data_files where tablespace_name = 'TBSP_INDEX';
TABLESPACE_NAME ------------------------------
FILE_NAME --------------------------------------------------------------
TBSP_DATA /u01/app/oracle/oradata/ORA11G/tbspindex01.dbf
SQL> ALTER TABLESPACE tbsp_data READ ONLY;
Tablespace altered.
SQL> ALTER TABLESPACE tbsp_index READ ONLY;
Tablespace altered.
[oracle@cloud ~]$ expdp system TRANSPORT_TABLESPACES=tbsp_data,tbps_index TRANSPORT_FULL_CHECK=YES DIRECTORY=prem_to_cloud
Export: Release 11.2.0.4.0 - Production on Sat Jun 3 23:30:03 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01": system/******** TRANSPORT_TABLESPACES=tbsp_data,tbps_index TRANSPORT_FULL_CHECK=YES DIRECTORY=prem_to_cloud
Cloud-Mig11g
Figure 1. Creating a new service (Cloud-Mig11g)
MIGORCL.
rsa-key-20170111.pub
.3. Finally, review the configuration and click Create to create your cloud database.
Figure 3. Creating the cloud database instance
After a few minutes, the cloud database instance has been created successfully.
Figure 4. The cloud database has been created
Figure 5. Main page of the cloud database
Figure 6. Selecting the Access Rules item
b. For the ora_p2_dblistener rule, select Enable from the Actions menu.
Figure 7. Enabling the ora_p2_dblistener rule
Figure 8. Connecting to machine using PuTTY
/u01directory. Choose the appropriate location based on the size of the file that will be transferred.
[oracle@Cloud-Mig11g ~]$ mkdir -p /u01/app/on_premise
[oracle@Cloud-Mig11g ~]$
b. Before using the
scputility to copy files, make sure the SSH private key that provides access to the Oracle Database Cloud Service compute node is available on your on-premises host.
c. On the on-premises database host, use the
scputility to transfer the dump file and all datafiles of the transportable set to the Oracle Database Cloud Service compute node.
[oracle@cloud ~]$ scp -i rsa-key-20170111.ssh /u01/app/dpump/expdat.dmp oracle@129.144.152.230:/u01/app/on_premise
Enter passphrase for key 'rsa-key-20170111.ssh':
expdat.dmp 100% 97MB 121.3KB/s 13:42
[oracle@cloud ~]$ scp -i rsa-key-20170111.ssh /u01/app/oracle/oradata/ORA11G/tbspdata01.dbf oracle@129.144.152.230:/u02/app/oracle/oradata/PROD
Enter passphrase for key 'rsa-key-20170111.ssh':
tbspdata01.dbf 100% 141MB 183.7KB/s 16:00
[oracle@cloud ~]$ scp -i rsa-key-20170111.ssh /u01/app/oracle/oradata/ORA11G/tbspindex01.dbf oracle@129.144.152.230:/u02/app/oracle/oradata/PROD
Enter passphrase for key 'rsa-key-20170111.ssh':
tbspindex01.dbf 100% 14MB 183.7KB/s 2:00
[oracle@cloud ~]$
3. Set the on-premises tablespaces back to read-write mode:
a. Invoke SQL*Plus and log in as the SYSTEM user.
b. Set the TBPS_DATA and TBSP_INDEX tablespaces back to read-write mode.
SQL> ALTER TABLESPACE tbsp_data READ WRITE;
Tablespace altered.
SQL> ALTER TABLESPACE tbsp_index READ WRITE;
Tablespace altered.
c. Exit from SQL*Plus.
4. On the Oracle Database Cloud Service compute node, prepare the database for the tablespace import:
a. On the Oracle Database Cloud Service compute node, invoke SQL*Plus and log in to the database as the SYSTEM user.
b. Create a directory object in the Oracle Database Cloud Service database.
SQL> CREATE DIRECTORY on_cloud AS '/u01/app/on_premise';
Directory created.
c. If the owners of the objects that will be imported do not exist in the database, create them before performing the import. The transportable tablespace mode of import does not create the users.
SQL> CREATE USER test PROFILE default IDENTIFIED BY test TEMPORARY TABLESPACE temp ACCOUNT UNLOCK;
User Created.
5. On the Database Cloud Service compute node, invoke Data Pump Import utility and connect to the database. Import the data into the database using the
TRANSPORT_DATAFILES
option.
[oracle@Cloud-Mig11g PROD]$ impdp system DIRECTORY=on_cloud \
> TRANSPORT_DATAFILES='/u02/app/oracle/oradata/PROD/tbspdata01.dbf' \
>'/u02/app/oracle/oradata/ORCL/tbspindex01.dbf'
Import: Release 11.2.0.4.0 - Production on Sat Jun 3 19:16:50 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Source time zone version is 14 and target time zone version is 28.
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** DIRECTORY=on_cloud TRANSPORT_DATAFILES=/u02/app/oracle/oradata/PROD/ tbspdata 01.dbf,/u02/app/oracle/oradata/ORCL/tbspindex01.dbf
6. Set the tablespaces on the Oracle Database Cloud Service database to read-write mode:
a. Invoke SQL*Plus and log in as the SYSTEM user.
b. Set the TBSP_DATA and TBSP_INDEX tablespaces to read-write mode.
SQL> ALTER TABLESPACE tbsp_data READ WRITE;
Tablespace altered.
SQL> ALTER TABLESPACE tbsp_index READ WRITE;
Tablespace altered.
c. Exit from SQL*Plus.
expdat.dmp
dump file. With this step, the entire process has been completed.We hope this article will be useful and we invite you to continue reading our next publications focused on Oracle Cloud.
Joel Pérez is an expert DBA and Oracle ACE Director and an Oracle Certified Master in Oracle Maximum Availability Architecture, Oracle Database cloud administration, and Oracle Database 11g and12c. He has over 17 years of real-world experience with Oracle technology and specializes in the design and implementation of solutions for the cloud, high availability (HA), disaster recovery, upgrades, replication, and most areas related to Oracle Database. Currently, he works as chief technologist and architect for cloud technologies, Oracle Maximum Availability Architecture, and HA at Yunhe Enmo (Beijing) Technology Co., Ltd. in Beijing, China.
Skant Gupta is an Oracle Certified Cloud Professional in Oracle Database 12c, an Oracle Certified Expert in Oracle Real Application Clusters (Oracle RAC) in Oracle Database 11g, and an Oracle Certified Professional in Oracle Database 10g, 11g, and 12c. He works at Vodafone Technology in the UK and formerly worked as a senior DBA at Etisalat in Dubai. He has six years of experience with various Oracle technologies, focusing mainly on cloud, database, and high availability solutions, Oracle WebLogic Suite, and Oracle GoldenGate. He has presented at several Oracle user groups worldwide, most recently in the US, the United Arab Emirates, and India.