This topic describes the preparations that you must make on the destination server before you restore a standalone Oracle database.
Overview
Install a backup gateway
Database Backup (DBS) uses Database Gateway (DG) to restore databases that have been backed up to on-premises databases or databases that are hosted on third-party clouds. You must install a backup gateway on the destination server. For more information, see Install a backup gateway.
DG allows you to connect an on-premises database to a cloud service. You do not need to expose ports to the Internet. DG is a database connection service for remote access to databases deployed on private networks. For more information, see What is Database Gateway?
If you want to restore a database to the original server that hosts the database, you can select the backup gateway that is used when the database is backed up.
Check the version of the source Oracle database
If you use DBS to restore an Oracle database, make sure that the version of Oracle on the destination server is the same as the minor version of the source Oracle database.
For example, Oracle 11.2.0.4 is incompatible with Oracle 11.2.0.1. If the source database adopts one of the preceding versions and the destination server adopts the other, errors may occur when you restore data. We recommend that you deploy the same version of Oracle on both the source database and the destination server.
You can run the following command to query the Oracle version of the source database:
su - oracle export ORACLE_SID=orcl; sqlplus / as sysdba select version from v$instance;
The following output indicates that the Oracle version is
19.0.0.0.0
==================== VERSION ----------------- 19.0.0.0.0 ====================
If the source database cannot reach the
mount
state, you can run the following command to query the Oracle version:su - oracle ORACLE_HOME/OPatch/opatch lsinv -oh $ORACLE_HOME |grep ^"Oracle Database"
Create an SID
An Oracle SID must be unique on a server. You must create an SID for the destination Oracle database.
Oracle databases that have the same name cannot run on the same server at the same time. You can run the following commands to stop the source database:
su - oracle
export ORACLE_SID=orcl;
sqlplus / as sysdba
shutdown abort; /* You can also run the shutdown immediate; command.*/
exit;
You can run the following command to check whether the source database is stopped:
ps -ef|grep pmon|grep orcl
If the output of the preceding command is returned, you can run the kill -9
command to stop the database.
Create a database restoration directory
Before you create a database restoration directory, you must obtain the size of the storage space that the source database occupies. To ensure that you have enough space for restoration, we recommend that you reserve at least 1.3 times the size of the source database or five to six times the size of the DBS full backup set for the database restoration directory. Data is compressed when DBS performs the backup operation.
You can run the following command to query the size of the source database as a user whose name is
oracle
:su - oracle export ORACLE_SID=orcl; sqlplus / as sysdba select sum(bytes) from ( select bytes from v$datafile union all select bytes from v$tempfile union all select bytes*members bytes from v$log);
The following output indicates that the size of the database is
4,904,189,952 bytes
.======================= SUM(BYTES) ---------- 4904189952 =======================
You can view the size of the full backup set in the DBS console. Log on to the DBS console. In the left-side navigation pane, click Backup Schedules. On the Backup Schedules page, find the backup schedule of the source database and click the name of the backup schedule. In the left-side navigation pane, choose . On the page that appears, you can view the size of the full backup set. For more information, see View a backup schedule.
Create a directory
mkdir -p /Oracle/data_bak
For example, you can run the preceding command to create a directory named
data_bak
in the Oracle folder.NoteIf the directory already exists, make sure that the directory is empty to prevent the original data in the directory from being overwritten when DBS restores data.
Grant permissions.
You can run the following command to query the user group to which the
$ORACLE_HOME/bin/Oracle
file belongs:ls -alh $ORACLE_HOME/bin/oracle
The following output indicates that the
$ORACLE_HOME/bin/Oracle
file belongs to theoracle:oinstall
user group:==================== -rwsr-s--x 1 oracle oinstall 421M Mar 15 03:04 /opt/oracle/product/19c/dbhome_1/bin/oracle ====================
You can run the following command to change the user group of the created directory:
chown -R oracle:oinstall /oracle/data_bak
Obtain the directory of the database client
ORACLE_HOME
specifies the directory in which an Oracle database is installed.
Run the
su - oracle
command in the CLI to log on to the Oracle database.Execute the
echo ORACLE_HOME
statement on the Oracle database to obtain the value ofORACLE_HOME
.The following output indicates that the value of
ORACLE_HOME
is/opt/oracle/product/19c/dbhome_1
:/opt/oracle/product/19c/dbhome_1