Getting started with Oracle Cloud Infrastructure (OCI) Object Storage

Introduction

In my post How to access Object Storage from your on-premises database I showed how we configure an Oracle 19c (19.9+) database to use the DBMS_CLOUD package to access objects stored within Object Stores.

In this post I will share how I created the Oracle Cloud Infrastructure (OCI) Object Store bucket and objects I used with my Oracle 19c database.

Create Bucket

From the OCI Dashboard select Object Storage or via the hamburger menu navigate to Storage -> Object Storage -> Buckets.

Select your required Compartment, and click Create Bucket

Compartment Buckets

Provide Bucket Name, and confirm Storage Tier, Object Versioning and Encryption etc…

Create Bucket

Note: Bucket names must be unique, if you have used the name even in another Compartment you will see.

By default the bucket is Private, however if required you can change the Visibility by clicking on the 3 vertical dots on the righthand side and updating it to Public.

Upload Objects

OCI provides the ability to upload objects directly from the OCI Bucket UI, so let’s use that for this example.

Click on your bucket name and scroll down to the bottom of the screen to see Objects.

Upload Objects

Select files and click Upload, once complete hit Close.

Upload Objects

We should now be able to see our uploaded Objects from the UI.

Create User Token

Before you can access the private bucket from your 19c database you need to provide a way of authenticating access.

To do this from the OCI dashboard, Click on your Profile icon (top right), navigate to User Settings -> Auth Token and click Generate Token providing a descriptive name.

Generate Token

Once created you will need select Copy as this will be the password you will use to access the bucket.

Generated Token

If you want to know how to use the token with your on-premises 19c database you need to create a CREDENTIAL using the DBMS_CLOUD package.e.g.

BEGIN
  DBMS_CLOUD.drop_credential(credential_name => 'OCI_TOKEN');
END;
/

BEGIN
  DBMS_CLOUD.CREATE_CREDENTIAL(
    credential_name => 'OCI_TOKEN',
    username => '<OCI Profile Name>',
    password => '<Auth Generated Token>'
  );
END;
/

You can find all the steps to how to set-up your Oracle 19c database here

List Bucket

If you have installed the Oracle Cloud Infrastructure (OCI) client you should now be able to use the oci os bucket list command to return details.

$ oci os bucket list --compartment-id <compatment id>
{
  "data": [
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaa...",
      "created-by": "ocid1.saml2idp.oc1..aaaaaaa.",
      "defined-tags": null,
      "etag": "e5d7b472-dd02-44a5-be6b-e1a0277868ee",
      "freeform-tags": null,
      "name": "bigdata",
      "namespace": "lrqs3o3gg8ym",
      "time-created": "2021-04-15T14:09:22.753000+00:00"
    }
  ]
}

Here is the link to the OCI CLI Command Reference documentation for bucket

List Object

We can also use the OCI CLI client to list objects using the oci os object list –bucket-name command e.g

$ oci os object list --bucket-name bigdata 
{
  "data": [
    {
      "etag": null,
      "md5": "uxwTzdAhMD3HOLFrZ6b9iQ==",
      "name": "movie.avro",
      "size": 331459,
      "time-created": "2021-04-15T14:47:20.254000+00:00",
      "time-modified": null
    },
    {
      "etag": null,
      "md5": "r12LQVkc7WDlnT7MnxAmrQ==",
      "name": "sales_extended.parquet",
      "size": 9263650,
      "time-created": "2021-04-15T14:47:21.626000+00:00",
      "time-modified": null
    }
  ],
  "prefixes": []
}

And this time, here is the link to the OCI CLI Command Reference documentation for object

Create Bucket

Alternatively, if you prefer you can create your OCI Object Store bucket using the OCI CLI client oci os bucket create –name command e.g.

$ oci os bucket create --name MyBucket --compartment-id <compatment id>
{
  "data": {
    "approximate-count": null,
    "approximate-size": null,
    "compartment-id": "ocid1.compartment.oc1..aaaaaaa...",
    "created-by": "ocid1.user.oc1..aaaaaaaaa.....",
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "ronekins..",
        "CreatedOn": "2021-04-15T16:38:31.220Z"
      }
    },
    "etag": "e991454d-06a4-4388-a20f-750509a3350e",
    "freeform-tags": {},
    "id": "ocid1.bucket.oc1.uk-london-1.aaaaaaaa...",
    "is-read-only": false,
    "kms-key-id": null,
    "metadata": {},
    "name": "MyBucket",
    "namespace": "lrqs3o3gg8ym",
    "object-events-enabled": false,
    "object-lifecycle-policy-etag": null,
    "public-access-type": "NoPublicAccess",
    "replication-enabled": false,
    "storage-tier": "Standard",
    "time-created": "2021-04-15T16:38:31.234000+00:00",
    "versioning": "Disabled"
  },
  "etag": "e991454d-06a4-4388-a20f-750509a3350e"
}

And if I go back to my OCI WebUI I can see my OCI CLI created bucket.

MyBucket

Summary

In this post I have shared how we can create an OCI Auth Token, Object Storage Buckets and upload Objects using the OCI WebUI.

I also introduced the OCI CLI client and demonstrated how we can use this to list Object Store Buckets and Objects, in a future block I will share a few more OCI CLI commands to help with Object Store management.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: