Kamran Agayev's Oracle Blog

Oracle Certified Master

Archive for the 'Oracle Cloud' Category

Configure and practice backup and recovery for Oracle Database in Cloud (DBaaS)

Posted by Kamran Agayev A. on 14th December 2016

In this post I will show you how to configure backup for Oracle Database in Cloud. First of all, make sure you use Oracle Storage Cloud Service and you set the replication policy. Open the following link, scroll down to Oracle Storage Cloud Service section and click “Set Replication Policy” link:

https://myservices.em2.oraclecloud.com/mycloud/faces/dashboard.jspx?showOld=true

 

image-1

 

 

 

 

 

 

 

 

 

 

Select the data center and click Set

 

 

image-2

 

 

 

 

 

 

 

 

 

 

 

Next, open Oracle Database Cloud Service and create a new service. The GUI has changed and we have only 3 steps to create a database in the cloud. Provide the service name, software version and edition, upload SSH public key and click Next

 

 

image-3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In order to enable the automatic backup of the database in the cloud, you have to create a cloud storage container. Before creating a cloud storage container, switch to Oracle Storage Cloud Service details and get the REST Endpoint:

 

image-18

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next, open https://storageconsole.em2.oraclecloud.com/ link, provide the Service REST Endpoint and login to Oracle Storage Cloud Service:

 

image-19

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Create a new storage container:

 

image-4

 

 

 

 

 

 

 

 

 

 

image-6

 

 

 

 

 

 

 

 

 

 

In the second screen of database service creation page, select “Both Cloud Storage and Local Storage” option as a Backup Destination, provide cloud storage container name, username and password and click Next.

 

 

image-5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Review the configuration and click Create button.

 

image-7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After creating the service successfully, open it and click on Administration section. From the Backup tab click on Backup Now button to create a backup of the database. You can use RMAN and schedule your own backups as well.

 

 

 

image-8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click Backup Now and check the log file for more information:

image-9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If you switch to the storage container, you will see bunch of files created

 

image-10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Open RMAN and run LIST BACKUPSET SUMMARY command to get list of backupsets:
image-11

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now let’s try to recover the database to the specific point in time using DBaaS wizard. For this, create a new table with some data, get the current SCN number and drop the table.

 

image-12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next, switch to DBaaS backup page, click Recover, provide the SCN number and click Recover

 

image-13

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The recover process will run in the background automatically. Check alert.log file of the database for more information:

 

image-14

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After the recover process is completed successfully login to the database and query the table

image-15

 

 

 

 

 

 

 

 

 

 

You can also take backup and recover the database from command line interface using bkup_api utility. Now let’s delete all backups, take a new backup and try the recovery.

Delete all available RMAN backups:

RMAN> delete backup;

 

Use bkup_api utility with bkup_start parameter to take a backup from CLI:

[root@srvtest spool]# /var/opt/oracle/bkup_api/bkup_api bkup_start

DBaaS Backup API V1.5 @2016 Multi-Oracle home

DBaaS Backup API V1.5 @2015 Multi-Oracle home

-> Action : bkup_start

-> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log

UUID d6bf0bde-c130-11e6-8534-c6b0e87f74cb for this backup

** process started with PID: 16524

** see log file for monitor progress

————————————-

[root@srvtest spool]#

 

 

Check the log file for more information:

[root@srvtest spool]# tail -f /var/opt/oracle/bkup_api/log/bkup_api.log

Tue, 13 Dec 2016 12:36:58 ** process started with PID: 16524

Tue, 13 Dec 2016 12:36:58 ** see log file for monitor progress

Tue, 13 Dec 2016 12:36:58 ————————————-

Tue, 13 Dec 2016 12:36:58 d6bf0bde-c130-11e6-8534-c6b0e87f74cb Checking if TESTDB resource is available

Tue, 13 Dec 2016 12:36:58 d6bf0bde-c130-11e6-8534-c6b0e87f74cb has a lock TESTDB

Tue, 13 Dec 2016 12:36:58 UUID d6bf0bde-c130-11e6-8534-c6b0e87f74cb written with PID 16524

Tue, 13 Dec 2016 12:36:58 d6bf0bde-c130-11e6-8534-c6b0e87f74cb The process is no longer running removing

lock

Tue, 13 Dec 2016 12:36:58 d6bf0bde-c130-11e6-8534-c6b0e87f74cb registering request into the database

Tue, 13 Dec 2016 12:37:00 d6bf0bde-c130-11e6-8534-c6b0e87f74cb current backups 0

Tue, 13 Dec 2016 12:37:00 d6bf0bde-c130-11e6-8534-c6b0e87f74cb command /home/oracle/bkup/TESTDB/obkup -dbname=TESTDB

 

 

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb@ backups after execution 4

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb rman tag TAG20161213T123750

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb rman tag TAG20161213T123729

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb rman tag TAG20161213T123758

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb rman tag TAG20161213T123834

Tue, 13 Dec 2016 12:38:51 d6bf0bde-c130-11e6-8534-c6b0e87f74cb Backup succeded TAG20161213T123834

 

 

Now having valid backups, let’s create a new table, drop it and recover it using dbaascli utility.

 

[oracle@srvtest opc]$ sqlplus / as sysdba

SQL> create table mytable2 as select * from dba_objects;

Table created.

 

SQL> select count(1) from mytable2;

  COUNT(1)

———-

     88911

 

SQL> select current_scn from v$database;

CURRENT_SCN

———–

    1333654

 

SQL> drop table mytable2 purge;

Table dropped.

 

SQL> exit

 

Now use dbaascli utility and provide the SCN number to perform SCN based incomplete recovery:

[root@srvtest opc]# dbaascli orec –args -scn 1333654

DBAAS CLI version 1.0.0

Executing command orec –args -scn 1333654

–args : -scn 1333654

 

OREC version: 16.0.0.0

 

Starting OREC

Logfile is /var/opt/oracle/log/TESTDB/orec/orec_2016-12-13_13:41:18.log

Config file is /var/opt/oracle/orec/orec.cfg

 

DB name: TESTDB

OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT

OREC:: Verifying scn validity…

PITR using SCN: 1333654

OREC:: Catalog mode:  Disabled

OREC:: Checking prerequirements before recovery process.

OREC:: DB Status : OPEN

OREC:: Changing instance to MOUNT stage.

OREC:: Shutting down the database… Completed.

OREC:: (RMAN) Startup MOUNT… Completed.

OREC:: Checking for PDBs directories.

OREC:: Checking for REDO logs.

OREC:: Restablishing DB instance to the original stage.

OREC:: Shutting down the database… Completed.

OREC:: Starting up database… Completed.

OREC:: Testing RMAN connection.

OREC:: Verifying backups dates ..

    :: OK

OREC:: Performing PITR using SCN number 1333654 …

INFO : DB instance is up and running after recovery procedure.

OREC:: Completed.

 

[root@srvtest opc]#

 

 

Now connect to the database and check if the table is recovered:

[oracle@srvtest opc]$ sqlplus / as sysdba

SQL> select count(1) from mytable2;

  COUNT(1)

———-

     88911

 

SQL>

 

The database backups are also stored in the flash recovery area image-16in the database host:

 

 

 

 

 

 

 

 

If you want to change the automatic backup schedule, edit /etc/crontab file with a root user. Below you can see the current schedule of the database backup:

image-17

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You can use a DBaaS backup wizard, DBaaS command line interface commands and RMAN to perform backup and recovery for Oracle Database in Cloud

Posted in Oracle Cloud | No Comments »

Create a clone database in Oracle Cloud

Posted by Kamran Agayev A. on 10th December 2016

In this step by step tutorial, we will create a clone database for the development or testing purposes. Using Oracle Database Cloud service you don’t need to configure and run DUPLICATE command of RMAN and create a clone of production database for developers team. All you need is to create a snapshot of your production database and clone it in a few minutes.

So first of all, let’s create a new database. Open cloud.oracle.com, login with your credentials and create a new database service. Please check my previous blog posts to create a new database service:

kamranagayev.com/2016/12/05/step-by-step-guide-to-create-an-oracle-database-in-the-cloud/

kamranagayev.com/2016/12/06/step-by-step-guide-create-a-primary-and-standby-database-in-the-cloud/ 

 

After successully creating a new database open it and select Aimage-8dministration section

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Before creating a snapshot of the database, login to the database and create a new table, insert one row and commit the transaction. We will check this table after cloning the snapshot

image-9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next, switch to the Snapshots tab, click “Create Storage Snapshot” button and provide the name of the snapshot. Don’t click Create button

image-10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When the snapshot of the database is taken, the database is placed into the backup mode. To test it, open SQL connection, click on Create button to create a snapshot and switch to the SQL session and run a command. The session will hang

image-11

 

 

 

 

 

 

image-12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When the snapshot is created, click on the menu icon on the right and choose Create Database Clone to create a clone database from the snapshot

image-13

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next, provide the service name and the database name for the clone database and create it

image-14

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After few minutes the clone database wilimage-15l be created

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now login to the clone database and check the table that was created before

image-16

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The first table was created before the snapshot and thus it’s there. But the second table was create after creating a snapshot and is not available.

As you see, it’s very easy to create a clone database using snapshots in Oracle Cloud. By having a trial account you are provided 500Gb of free space. Each database service consumes 150Gb space, so having 1 production db (150Gb), 1 snapshot (150Gb) and 1 clone database (150Gb) you can easily test the clone database creation with your trial account

 

Posted in Oracle Cloud | No Comments »

Step by step guide – create a primary and standby database in the Cloud!

Posted by Kamran Agayev A. on 6th December 2016

In this guide, I will show you how to create a primary and standby database in the cloud. Login to your cloud account, switch to the Oracle Database Cloud Service page and create a new service. Select “Oracle Database Cloud Service” as a subscription type and click Next.

image-1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Select a database release and click Next.

image-2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Select “Enterprise Edition – Extreme Performance” as a Software Edition and click Next

 

image-3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Provide the service name, SSH public key and select “Standby Database with Data Guard” option, select “High Availability” and click Next

image-4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Review the configuration settings and click Create to create a primary and a standby database

image-5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After a few minutes the primary and standby database will be created successfully

image-6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click on the service name (srvdg) to open the home page of both databases

 

image-7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now open two different Putty executables and connect to the both machines

 

image-8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Connect to the both databases and check the DB_UNIQUE_NAME parameter. PRODDB_01 is set to the primary database, PRODDB_02 for the standby database. Also check LOG_ARCHIVE_DEST_2 parameter on the primary database. As you see, archived log files are shipped to the standby database using PRODDB_02 service.

image-9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now let’s test the functionality of the standby database. First of all, open an alert.log file of the standby database, switch the log file on the primary database and check if the log file is applied

 

image-10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now perform a switchover

 

image-11

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Switch the log file and see if it is applied to the new standby database

image-12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It worked. Now switch back

 

image-13

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As you see, it’s very easy to create a database with its own standby database in the cloud!

Posted in Oracle Cloud | No Comments »