Skip to content

Commit dfaaa64

Browse files
committed
add google cloud support
1 parent 05a43bc commit dfaaa64

16 files changed

+428
-292
lines changed

multicloud/azure-cli/create-data-lake-storage.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ echo "Upload files to that directory"
6262
az storage fs directory upload \
6363
--account-name $STORAGE_ACCOUNT_NAME \
6464
--file-system $STORAGE_CONTAINER_NAME \
65-
--source "../sql/support-site/*" \
65+
--source "../../sql/support-site/*" \
6666
--destination-path support-site \
6767
--recursive \
6868
--auth-mode login
@@ -78,7 +78,7 @@ echo "Upload files to that directory"
7878
az storage fs directory upload \
7979
--account-name $STORAGE_ACCOUNT_NAME \
8080
--file-system $STORAGE_CONTAINER_NAME \
81-
--source "../sql/data/*" \
81+
--source "../../sql/data/*" \
8282
--destination-path data \
8383
--recursive \
8484
--auth-mode login

multicloud/gcloud-cli/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Oracle Database@Google Cloud: Create an Autonomous Database
2+
There are different ways that you can deploy a new Oracle Autonomous Database:
3+
* [Using the Google Cloud Portal](https://youtu.be/QOCvRr5CfeQ)
4+
* [Using Terraform scripts](https://github.com/oci-landing-zones/terraform-oci-multicloud-azure/tree/main)
5+
* Using the Azure CLI
6+
7+
The steps below show how to create an Autonomous Database using the Azure CLI.
8+
9+
## Prerequisites:
10+
* [Install the Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
11+
* [Subscribe to Oracle Database@Azure](https://www.youtube.com/watch?v=MEB8kB_TI2I)
12+
* Ensure you have the appropriate user groups and privileges. See [details for onboarding Autonomous Database](https://learn.microsoft.com/en-us/azure/oracle/oracle-db/onboard-oracle-database)
13+
14+
## Deploy your Autonomous Database and your infrastructure
15+
Use the following scripts to deploy your infrastructure and Autonomous Database:
16+
17+
![deployment](../images/azure-deployment.png)
18+
19+
**Note:** Azure OpenAI is used by the samples - but the scripts do not deploy the resource.
20+
f
21+
You can run the scripts independently or run `create-all-resources.sh`. Simply update the [`config`](#configuration-file) prior to running the scripts:
22+
23+
|Script|Description|
24+
|----|---|
25+
|[create-resource-group.sh](create-resource-group.sh)|Create a resource group|
26+
|[create-network.sh](create-network.sh)|Create virtual cloud network. <br><br>ADB must be deployed to a delegated subnet. In addition, ADB access is thru a private endpoint. This means it must be accessed from either the same VCN or another privileged network.|
27+
|[create-adb.sh](create-adb.sh)|Create an Autonomous Database|
28+
|[create-compute-vm.sh](create-compute-vm.sh)|Create a VM in that VCN|
29+
|[create-all-resources.sh](create-all-resources.sh)|Creates your resource group, network, ADB and VM|
30+
|[create-data-lake-storage.sh](create-data-lake-storage.sh)|Creates an Azure Data Lake Gen 2 storage account, a container and uploads sample data into that container|
31+
|[delete-all-resources.sh](delete-all-resources.sh)|Deletes your resource group, network, ADB and VM|
32+
33+
### Configuration file
34+
The Azure cli deployment scripts rely on settings found in the config file. These resources **will be created** by the scripts. Update the config file prior to running any of the scripts.
35+
36+
>**IMPORTANT:** This file will contain a password that is used to connect to Autonomous Database and the virtual machine. Set the file's permissions so that only the file's owner can view its contents:
37+
```bash
38+
chmod 600 config
39+
```
40+
41+
|Setting|Description|Example|
42+
|----|----|----|
43+
|LOCATION|Region where resources will be deployed. [See documentation](https://docs.oracle.com/en-us/iaas/Content/database-at-azure/oaa_regions.htm) for regions where Oracle Database 23ai is available|"eastus"|
44+
|RESOURCE_GROUP|Target resource group for new resources|"development"|
45+
|ADB_NAME|Autonomous Database name. This name must be unique within a region location|"quickstart"|
46+
|VNET_NAME|Virtual network|"dev-vnet"|
47+
|VNET_PREFIX|CIDR range for the virtual network|"192.168.0.0/16"|
48+
|SUBNET_NAME|Delegated subnet where the database will be deployed|"dev-sn-db"|
49+
|SUBNET_PREFIX|CIDR range for the delegated subnet|"192.168.1.0/24"|
50+
|SUBNET2_NAME|Client subnet. The VM will be deployed to this subnet|"dev-sn-client"|
51+
|SUBNET2_PREFIX|CIDR range for the client subnet|"192.168.2.0/24"|
52+
|NSG_NAME|Name of the network security group used by the client subnet|$SUBNET2_NAME-nsg|
53+
|VM_NAME|Name of the virtual machine|"adb-vm-client"|
54+
|VM_PREFERRED_SIZES|A list of VM sizes. Change these values based on region availability. The script will attempt to create a VM based on the order listed|( "Standard_GS1" "Standard_DC1s_v2" "Standard_DC2s_v2" "Standard_DC2ads_v5" "Standard_L4s" )|
55+
|VM_IMAGE|The image used by the VM|"MicrosoftWindowsDesktop:Windows-11:win11-22h2-pro:latest"|
56+
|STORAGE_ACCOUNT_NAME|The name of an Azure Data Lake Storage Gen 2 account. This name must be unique across Azure. Sample data files will be uploaded into this storage account.|"mytenancysamplestorageaccount"|
57+
|STORAGE_CONTAINER_NAME|The name of the container where files will be uploaded|"adb-sample"|
58+
|USER_NAME|The name of the user for the virtual machine|"adb"|
59+
|USER_PASSWORD|The password for both the VM and the Autonomous Database admin user|"Welcome1234#abcd"|
60+
61+
### Using the scripts
62+
Log into azure: after updating the config file:
63+
64+
```bash
65+
az login
66+
```
67+
Then, run your scripts. The following will deploy a complete environment, but you can also install independent components. Just make sure you install dependencies (e.g. a VCN prior to Autonomous Database):
68+
69+
Creating all of the resources will take approximately 15-20 minutes.
70+
71+
```bash
72+
./create-all-resources.sh
73+
```
74+
75+
Check for errors after running the script. For example, VM availability can impact the success of creating the resource. If there is an issue, simply rerun the script that creates the resource (note: you may need to update the config file).
76+
77+
## What's next
78+
Connect to your Autonomous Database!
79+
* [Learn about connectivity options](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/connect-preparing.html)
80+
* Use these great VS Code extensions that help you develop and debug your database apps:
81+
* SQL Developer for VS Code ([Learn More](https://www.oracle.com/database/sqldeveloper/vscode/) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.sql-developer))
82+
* Oracle Developer Tools for VS Code ([Learn More](https://docs.oracle.com/en/database/oracle/developer-tools-for-vscode/getting-started/gettingstarted.html) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.oracledevtools))
83+
84+
#### JDBC Example:
85+
JDBC is a common way to connect to Autonomous Database. For example, you can use the **Custom JDBC URL** in the VS Code SQL Developer Extension:
86+
![connection dialog](../images/connect-dialog.png)
87+
88+
Notice the `jdbc:oracle:thin:@` prefix followed by a connection string. You can find the connection string in different ways.
89+
90+
1. Go to your Autonomous Database blade in the Azure Portal and go to **Settings -> Connections**:
91+
![Azure Portal connections](../images/connections-portal.png)
92+
2. Use the Azure cli script [`show-adb-info.sh`](./show-adb-info.sh). That script will return information about your Autonomous Database, including connection details.
93+
94+
<hr>
95+
Copyright (c) 2024 Oracle and/or its affiliates.<br>
96+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

multicloud/gcloud-cli/create-adb.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5+
6+
echo ""
7+
echo "##"
8+
echo "# create autonomous database"
9+
echo "##"
10+
echo ""
11+
# ensure you update the config file to match your deployment prior to running the deployment
12+
13+
source ./config
14+
15+
# ADB requires the IDs of the networking components
16+
NETWORK_ID=`gcloud compute networks list --filter="name=$VPC_NETWORK_NAME" --format="get(id)"`
17+
18+
gcloud oracle-database autonomous-databases create $ADB_NAME \
19+
--location=$REGION \
20+
--display-name=$ADB_NAME \
21+
--database=$ADB_NAME \
22+
--network=$NETWORK_ID \
23+
--cidr=$SUBNET_DB_IP_RANGE \
24+
--admin-password=$USER_PASSWORD \
25+
--properties-compute-count=4 \
26+
--properties-data-storage-size-gb=500 \
27+
--properties-db-version=23ai \
28+
--properties-license-type=LICENSE_INCLUDED \
29+
--properties-db-workload=OLTP \
30+
--properties-is-storage-auto-scaling-enabled \
31+
--properties-is-auto-scaling-enabled \
32+
--async
33+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
set -e
5+
6+
./create-network.sh
7+
./create-adb.sh
8+
./create-data-lake-storage.sh
9+
./create-compute-vm.sh
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
5+
echo ""
6+
echo "##"
7+
echo "# create compute vm"
8+
echo "##"
9+
echo ""
10+
11+
# ensure you update the config file to match your deployment prior to running the deployment
12+
source ./config
13+
14+
## Create a windows vm
15+
echo "Creating compute instance $VM_NAME"
16+
17+
gcloud compute instances create $VM_NAME \
18+
--image-family $VM_IMAGE_FAMILY \
19+
--image-project windows-cloud \
20+
--machine-type e2-standard-4 \
21+
--zone $REGION-a \
22+
--network $VPC_NETWORK_NAME \
23+
--network-tier=PREMIUM \
24+
--subnet $SUBNET_CLIENT_NAME \
25+
--boot-disk-size 50GB \
26+
--boot-disk-type pd-ssd \
27+
--enable-display-device \
28+
--tags=bastion
29+
30+
## Create it's password
31+
echo "Resetting the password for $VM_NAME"
32+
gcloud compute reset-windows-password $VM_NAME --zone=$REGION-a
33+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
5+
echo ""
6+
echo "##"
7+
echo "# Create a Google Cloud Storage bucket"
8+
echo "##"
9+
echo ""
10+
# ensure you update the config file to match your deployment prior to running the deployment
11+
12+
source config
13+
14+
echo "# Creating Google Cloud Storage bucket $STORAGE_ACCOUNT_NAME"
15+
gcloud storage buckets create gs://$BUCKET_NAME --location=$REGION --default-storage-class=STANDARD
16+
17+
echo "# Uploading sample files"
18+
echo "Support site files"
19+
gcloud storage cp -r ../../sql/support-site gs://$BUCKET_NAME/support-site
20+
21+
echo "Sample data sets"
22+
gcloud storage cp -r ../../sql/data gs://$BUCKET_NAME/data
23+
24+
echo "Done."
25+
gcloud storage ls --long --recursive gs://$BUCKET_NAME
26+
27+
echo ""
28+
echo "Bucket Name: $BUCKET_NAME"
29+
echo "Storage URL:"
30+
echo "https://storage.googleapis.com/$BUCKET_NAME"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
5+
echo ""
6+
echo "##"
7+
echo "# deploy network"
8+
echo "##"
9+
echo ""
10+
# ensure you update the config file to match your deployment prior to running the deployment
11+
source ./config
12+
13+
# Create a VPC
14+
gcloud compute networks create $VPC_NETWORK_NAME --subnet-mode=custom
15+
16+
#gcloud compute networks subnets create private-subnet \
17+
# --network=$VPC_NETWORK_NAME \
18+
# --region=$REGION \
19+
# --range=192.168.5.0/24 \
20+
# --enable-private-ip-google-access
21+
22+
gcloud compute networks subnets create $SUBNET_CLIENT_NAME \
23+
--network=$VPC_NETWORK_NAME \
24+
--region=$REGION \
25+
--range=$SUBNET_CLIENT_IP_RANGE \
26+
--enable-flow-logs \
27+
--enable-private-ip-google-access
28+
29+
gcloud compute firewall-rules create $VPC_FIREWALL_INGRESS_NAME \
30+
--direction=INGRESS \
31+
--priority=1000 \
32+
--network=$VPC_NETWORK_NAME \
33+
--action=ALLOW \
34+
--rules=tcp:22,tcp:80,tcp:443,tcp:1522,tcp:3389 \
35+
--source-ranges=0.0.0.0/0 \
36+
--description="Allow SSH, HTTP, HTTPS, Autonomous DB, and RDP access"
37+
--target-tags=bastion
38+
39+
gcloud compute firewall-rules create $VPC_FIREWALL_EGRESS_NAME \
40+
--direction=EGRESS \
41+
--priority=1000 \
42+
--network=$VPC_NETWORK_NAME \
43+
--action=ALLOW \
44+
--rules=tcp:22,tcp:80,tcp:443,tcp:1522,tcp:3389 \
45+
--destination-ranges=0.0.0.0/0 \
46+
--target-tags=bastion

multicloud/gcloud-cli/delete-adb.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5+
6+
# ensure you update the config file to match your deployment prior to running the deployment
7+
8+
source ./config
9+
10+
# Ask for confirmation
11+
echo "Are you sure you want to delete database '$ADB_NAME' in region '$REGION'?"
12+
echo "Enter (y/n):"
13+
read confirmation
14+
15+
if [[ $confirmation == [yY] || $confirmation == [yY][eE][sS] ]]; then
16+
echo "Deleting Autonomous Database"
17+
gcloud oracle-database autonomous-databases delete $ADB_NAME --location=$REGION --quiet
18+
19+
else
20+
echo "Deletion cancelled. The database was not deleted."
21+
fi
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5+
6+
# ensure you update the config file to match your deployment prior to running the deployment
7+
8+
source ./config
9+
10+
# Ask for confirmation
11+
echo ""
12+
echo "Are you sure you want to delete the sample resources?"
13+
echo "- ADB: $ADB_NAME"
14+
echo "- Bucket: $BUCKET_NAME"
15+
echo "- VM: $VM_NAME"
16+
echo ""
17+
echo "Enter (y/n)"
18+
read confirmation
19+
20+
if [[ $confirmation == [yY] || $confirmation == [yY][eE][sS] ]]; then
21+
echo "Deleting Autonomous Database"
22+
gcloud oracle-database autonomous-databases delete $ADB_NAME --location=$REGION --quiet
23+
24+
echo "Deleting storage bucket $BUCKET_NAME"
25+
gcloud storage rm -r gs://$BUCKET_NAME/*
26+
gcloud storage buckets delete gs://$BUCKET_NAME
27+
28+
echo "Deleting VM"
29+
gcloud compute instances delete $VM_NAME --zone $REGION-a
30+
31+
echo "The network has not been deleted. You can do that using the console.".
32+
else
33+
echo "Deletion cancelled."
34+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ask for confirmation
2+
source ./config
3+
echo ""
4+
echo "Deleting compute instance '$VM_NAME'"
5+
gcloud compute instances delete $VM_NAME --zone $REGION-a

0 commit comments

Comments
 (0)