OCI Block Volume Replication Part 1 – Basics

Let’s talk about new OCI Cross-Region Block Volume Replication!

I wanted to test this feature out as it can provide much needed help when you need to build your Disaster Recovery environment on different Region. In earlier cases we’ve used rsync for this, one great advantage with this new feature is that it uses Oracle’s backplane and you don’t need to setup Remote Peering at all!

In this first post I’ll go through basics how it works and how you can get new replica disk mounted on destination region with CLI. In the next part I’ll look how one could automate this process.

At the time of writing this post (April, 2021) Oracle promises data to be replicated usually within an hour to destination replica. How it works in brief is that when you are creating block volume you can create it with Cross-Region synchronization, in the destination Region (and AD) it will create an active replica.

From this active replica you can create new block volume which will be ready to be used.

After creation I can go to destination Region and review replica and status. You can also see how much data has been transferred so far to the replica.

What I’ve done is, on the source volume which is mounted on my compute instance, I’ve just created 2GB worth of data via dd (file.txt). After a short while I see that 2GB of data has been transferred. What I like on the Console view is that you can also see last sync time.

Creating the volume in destination

Just to give you idea how it works with CLI, I decided to use that directly on my destination compute instance. I’ve given necessary privileges via instance principal. If you would only need to add block volume from replica, CLI could be one option to use with scripting.

[opc@instance-20210409-0805 ~]$ oci bv block-volume-replica get
Usage: oci bv [OPTIONS] COMMAND [ARGS]...

Error: No such command "block-volume-replica".

But what! I can’t use it, simple solution.. for new features remember to update your CLI. I had to download new version from git to get the latest version. If you ever need to do it, you can do it from here.

Once I have CLI working I’ve obtained block volume replica id from console which I can use to create new block volume:

[opc@instance-20210409-0805 ~]$ oci bv volume create --availability-domain VQEf:CA-MONTREAL-1-AD-1 --compartment-id ocid1.compartment.oc1..aaaaaaaardyyoymj2c2mkrbaydmwyvy45tasnzzj3fkflwkiobnwuzcgn3eq --display-name bv-replica-montreal --source-volume-replica-id ocid1.blockvolumereplica.oc1.ca-montreal-1.ab4xkljrn2hjclrhsj5m6iho2k7uqgk5atdvifzeaj26svevs3r6yn3lgveq --auth instance_principal
{
  "data": {
    "auto-tuned-vpus-per-gb": null,
    "availability-domain": "VQEf:CA-MONTREAL-1-AD-1",
    "block-volume-replicas": null,
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaardyyoymj2c2mkrbaydmwyvy45tasnzzj3fkflwkiobnwuzcgn3eq",
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "oracleidentitycloudservice/simo",
        "CreatedOn": "2021-04-09T11:52:16.748Z"
      },
      "tf-tag": {
        "defaultName": "simo"
      }
    },
    "display-name": "bv-replica-montreal",
    "freeform-tags": {},
    "id": "ocid1.volume.oc1.ca-montreal-1.ab4xkljrflkhk3k3trdsklrgwspbb476pbwl5ul46cjq6tl7wmfneghb2fca",
    "is-auto-tune-enabled": false,
    "is-hydrated": false,
    "kms-key-id": null,
    "lifecycle-state": "PROVISIONING",
    "size-in-gbs": 50,
    "size-in-mbs": 51200,
    "source-details": {
      "id": "ocid1.blockvolumereplica.oc1.ca-montreal-1.ab4xkljrn2hjclrhsj5m6iho2k7uqgk5atdvifzeaj26svevs3r6yn3lgveq",
      "type": "blockVolumeReplica"
    },
    "system-tags": {},
    "time-created": "2021-04-09T12:33:12.541000+00:00",
    "volume-group-id": null,
    "vpus-per-gb": 10
  },
  "etag": "8b950db3499cdfc2a15a7a4429e249ea"
}

What I need to do next, is to attach my newly created block volume to my DR compute instance.

[opc@instance-20210409-0805 ~]$ oci compute volume-attachment attach-paravirtualized-volume --instance-id ocid1.instance.oc1.ca-montreal-1.an4xkljr76xb3sycovozcdf7md5linkd2tramwk3ubbiz25oi2264cqoyxmq --volume-id ocid1.volume.oc1.ca-montreal-1.ab4xkljrflkhk3k3trdsklrgwspbb476pbwl5ul46cjq6tl7wmfneghb2fca --device /dev/oracleoci/oraclevdb --auth instance_principal
{
  "data": {
    "attachment-type": "paravirtualized",
    "availability-domain": "VQEf:CA-MONTREAL-1-AD-1",
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaardyyoymj2c2mkrbaydmwyvy45tasnzzj3fkflwkiobnwuzcgn3eq",
    "device": "/dev/oracleoci/oraclevdb",
    "display-name": "volumeattachment20210409123747",
    "id": "ocid1.volumeattachment.oc1.ca-montreal-1.an4xkljr76xb3sycepypal4ne6b3z77mhpf3lsk4ykdzm34qan7po6tjns7a",
    "instance-id": "ocid1.instance.oc1.ca-montreal-1.an4xkljr76xb3sycovozcdf7md5linkd2tramwk3ubbiz25oi2264cqoyxmq",
    "is-pv-encryption-in-transit-enabled": false,
    "is-read-only": false,
    "is-shareable": false,
    "lifecycle-state": "ATTACHING",
    "time-created": "2021-04-09T12:37:48.082000+00:00",
    "volume-id": "ocid1.volume.oc1.ca-montreal-1.ab4xkljrflkhk3k3trdsklrgwspbb476pbwl5ul46cjq6tl7wmfneghb2fca"
  },
  "etag": "f0fb75ae3964efa3b2da3701bb5ab8de4fb24909dfd3ba9149245395e25c23b3"
}

Remember to define device name, that way you can force the disk to be found always from same location on the server making it easier to script entire process.

Do I still need to setup my disk now? No, because it’s exact replica from source so it’s been setup already. I just need to mount it and see it looks valid.

opc@instance-20210409-0805 ~]$ sudo mount /dev/sdb1 /opt/replica/
[opc@instance-20210409-0805 ~]$ ls -la /opt/replica/
total 1048600
drwxr-xr-x. 3 root root       4096 Apr  9 12:03 .
drwxr-xr-x. 5 root root         63 Apr  9 12:13 ..
-rw-r--r--. 1 root root 1073741824 Apr  9 12:05 file.txt
drwx------. 2 root root      16384 Apr  9 11:54 lost+found

What happens to replication now if new data comes to your source volume? It continues the replication to replica, but the created volume obviously doesn’t get updates because it’s point-in-time copy of the volume.

If you need new updated data, you can repeat the process and create a new volume.

Summary

Creating replica is super easy and straightforward process. I went over basics in this first post so on the next post we can take a look on how to automate the process.

You could have your compute instance already running and want to get only block volume attached. Or you could want to spin up new compute instance with replicated boot and block volume. How can we do it?

Simo

Recent Posts

Autonomous Database Audit Logs to Logging Service Part 1

I recently came across requirement to get OCI Oracle Autonomous Database audit logs to OCI…

3 weeks ago

Connecting to Autonomous Database Running on Google Cloud

Last time I showed how to provision Autonomous Database Serverless (ADB-S) on Google Cloud. This…

2 months ago

Can you believe it? Provisioning Autonomous Database in GCP!

I bet few years back folks didn't expect that by 2024 we would be able…

3 months ago

IP Address Insights with CLI

My previous post on IP Address Insights I mentioned it wasn't yet available with CLI…

7 months ago

Thoughts on Oracle Database@Azure

This will NOT be a technical walkthrough on Oracle Database@Azure but rather my opinions and…

7 months ago

OCI Vulnerability Scanning Setup

Many times when you work for someone, they already have their own vulnerability scanning throughout…

7 months ago