# Quickstart: Use Oracle Toolkit for Google Cloud with Compute Engine

Learn how to get started with Oracle Toolkit for Google Cloud.

This quickstart shows you how to use Oracle Toolkit to create and run an Oracle
database on a Compute Engine virtual machine (VM).

The instructions in this quickstart use Google Cloud CLI.

> [!NOTE]
> **Note:** This quickstart is an abridged version of the more comprehensive [Oracle Toolkit for Google Cloud - Compute Engine VM User Guide](https://google.github.io/oracle-toolkit/compute-vm-user-guide.html).

## Before you begin

1. [Create an
   auto mode Virtual Private Cloud (VPC) network](https://docs.cloud.google.com/vpc/docs/create-modify-vpc-networks#create-auto-network).
2. [Create a Cloud Storage bucket](https://docs.cloud.google.com/storage/docs/creating-buckets.md.txt) to host the Oracle software image.
3. [Create a Compute Engine default service account](https://docs.cloud.google.com/compute/docs/access/service-accounts.md.txt#default_service_account).
4. Grant the following Identity and Access Management (IAM) role on the Cloud Storage bucket:
   - [`roles/storage.objectViewer`](https://docs.cloud.google.com/storage/docs/access-control/iam-roles.md.txt#storage.objectViewer)

   To learn how to grant IAM roles and permissions, see
   [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

<br />

## Create a Compute Engine VM

Create a Compute Engine VM to host the Oracle database.

Run the following command:

```
gcloud compute instances create VM_NAME \
    --zone=ZONE \
    --machine-type=MACHINE_TYPE \
    --image-project=oracle-linux-cloud \
    --image-family=oracle-linux-8 \
    --metadata enable-oslogin=TRUE \
    --boot-disk-size=20GB \
    --create-disk size=DISK_SIZEGB,device-name=oracle-u01 \
    --create-disk size=DISK_SIZEGB,device-name=oracle-asm-data-1 \
    --create-disk size=DISK_SIZEGB,device-name=oracle-asm-reco-1
```

Replace the following:

- <var translate="no">VM_NAME</var>: a name for the VM.
- <var translate="no">ZONE</var>: the zone in which to create the VM.
- <var translate="no">MACHINE_TYPE</var>: the machine type of the VM. See [Machine families resource and comparison guide](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt).
- <var translate="no">DISK_SIZE</var>: the size, in gigabytes, of the disk. Acceptable sizes
  range, in 1 GB increments, from 10 GB to 65,536 GB inclusive.

  The command creates three disks, namely `oracle-u01`, `oracle-asm-data-1`, and
  `oracle-asm-reco-1`.

## Download the Oracle Toolkit for Google Cloud

To download the Oracle Toolkit, run the following commands:

```
python3 -m venv oracle-toolkit-venv
source oracle-toolkit-venv/bin/activate
pip3 install --upgrade pip
pip3 install ansible-core==2.16.0 jmespath
```

```
curl -L -o oracle-toolkit-master.zip https://github.com/google/oracle-toolkit/archive/refs/heads/master.zip && 
  unzip ./oracle-toolkit-master.zip && 
  rm ./oracle-toolkit-master.zip && 
  mv oracle-toolkit-master oracle-toolkit
  cd oracle-toolkit
```

## Download the Oracle software

[Download and stage the Oracle software](https://github.com/google/oracle-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software) that you need
in the Cloud Storage bucket. The Oracle Toolkit doesn't contain any
Oracle software. You are responsible for procuring the required Oracle software
in accordance with the applicable licenses governing such software.

To download and stage the Oracle software, do the following:

1. Obtain a list of required Oracle software download files. To verify the files
   for your required Oracle version, add the `--ora-version` argument.

   ```
   bash ./check-swlib.sh --ora-swlib-bucket gs://BUCKET_NAME --ora-version 19
   ```

   Replace the following:
   - <var translate="no">BUCKET_NAME</var>: the name of your Cloud Storage bucket which hosts the Oracle software image.
2. Download the missing files to your local machine:

   - Download patches (files starting with 'p') from [My Oracle Support](https://support.oracle.com).
   - Download base releases from [Oracle Software Delivery Cloud](https://edelivery.oracle.com) or [Oracle Technology Network](https://www.oracle.com/database/technologies/oracle-database-software-downloads.html).

   > [!NOTE]
   > **Note:** Both **My Oracle Support** and **Oracle Software Delivery Cloud** require Oracle support entitlements.

3. Transfer the files to the Cloud Storage bucket. Also, in the bucket
   itself, disable the parallel composite uploads to let MD5 signatures be
   recorded for file integrity verification.

   ```
   gcloud storage cp *.zip gs://BUCKET_NAME --property=storage/parallel_composite_upload_enabled=False
   ```
4. Verify that the required Oracle software is available in the bucket.

   ```
   bash ./check-swlib.sh --ora-swlib-bucket BUCKET_NAME
   ```

## Install the Oracle software and create an Oracle database

To install the Oracle software and create a database, do the following:

1. Capture the OS login user profile.

   ```
   OS_LOGIN_USER=$(gcloud os-login describe-profile)
   ```
2. Capture the IP address of your VM.

   ```
   INSTANCE_IP_ADDR=$(gcloud compute instances describe VM_NAME --zone=ZONE --format="value(networkInterfaces[0].networkIP)")
   ```

   Replace the following:
   - <var translate="no">VM_NAME</var>: the name of the Compute Engine VM which you created earlier in this guide.
   - <var translate="no">ZONE</var>: the zone of the VM.
3. Run the following command to install the software and create the database
   through a single command:

   ```
   bash ./install-oracle.sh \
    --instance-ip-addr $INSTANCE_IP_ADDR \
    --instance-ssh-user $OS_LOGIN_USER \
    --instance-ssh-key "$HOME/.ssh/google_compute_engine" \
    --ora-version 19 \
    --ora-swlib-bucket gs://BUCKET_NAME \
    --ora-swlib-path /u01/oracle_install \
    --ora-data-mounts-json '[{"purpose":"software","blk_device":"/dev/disk/by-id/google-oracle-u01","name":"u01","fstype":"xfs","mount_point":"/u01","mount_opts":"nofail"}]' \
    --ora-asm-disks-json '[{"diskgroup":"DATA","disks":[{"blk_device":"/dev/disk/by-id/google-oracle-asm-data-1","name":"DATA1"}]},{"diskgroup":"RECO","disks":[{"blk_device":"/dev/disk/by-id/google-oracle-asm-reco-1","name":"RECO1"}]}]' \
    --ora-db-name DATABASE_NAME
   ```

   Replace the following:
   - <var translate="no">BUCKET_NAME</var>: the name of your Cloud Storage bucket which hosts the Oracle software image.
   - <var translate="no">DATABASE_NAME</var>: a name for your database. It must not be more than 8 characters, and must begin with an alphabetic character.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, delete the Google Cloud project with the
resources.

1. Delete the Compute Engine VM:

   ```
   gcloud compute instances delete VM_NAME --zone=ZONE
   ```

   Replace the following:
   - <var translate="no">VM_NAME</var>: the name of the Compute Engine VM which you created earlier in this guide.
   - <var translate="no">ZONE</var>: the zone of the VM.
2. Delete the Cloud Storage bucket:

   Use the `gcloud storage rm` command with the `--recursive` flag to
   delete the bucket and anything inside of it:

   ```
   gcloud storage rm gs://BUCKET_NAME --recursive
   ```

   Replace the following:
   - <var translate="no">BUCKET_NAME</var>: the name of your Cloud Storage bucket.

   If successful, the command returns a message similar to:

   ```
   Removing gs://BUCKET_NAME/...
   ```

## What's next

- [User guide for Oracle Toolkit for Google Cloud - Compute Engine VM](https://google.github.io/oracle-toolkit/compute-vm-user-guide.html)
- [User guide for Oracle Toolkit for Google Cloud](https://google.github.io/oracle-toolkit/user-guide.html)
- [Oracle Toolkit for Google Cloud - disaster recovery configurations](https://google.github.io/oracle-toolkit/disaster-recovery-configurations.html)
- [Terraform infrastructure provisioning for Oracle Toolkit for Google Cloud deployments](https://google.github.io/oracle-toolkit/terraform.html)