The following brick contains the logic to provision a MonoDB database cluster in a highly available architecture. This includes 3-7 Config Servers, 3-7 Shards and any number of query servers.
This brick is only supported on Oracle Linux for the time being.
The following is the reference architecture associated to this brick
- Pre-baked Artifact and Network Compartments
- Pre-baked VCN
If using Fixes Shapes.
######################################## COMMON VARIABLES ######################################
region = "re-region-1"
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
user_ocid = "ocid1.user.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
fingerprint = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
######################################## COMMON VARIABLES ######################################
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
ssh_public_key = "/absolute/path/to/api/key/your_ssh_public_key.pub"
ssh_private_key = "/absolute/path/to/api/key/your_ssh_private_key"
compute_nsg_name = "MY_NSG"
linux_compute_instance_compartment_name = "MY_ARTIFACT_COMPARTMENT"
linux_compute_network_compartment_name = "MY_NETWORK_COMPARTMENT"
private_network_subnet_name = "MY_PRIVATE_SUBNET"
vcn_display_name = "MY_VCN"
config_server_name = "MY_CONFIG_SERVER_NAME"
config_server_shape = "VM.Standard2.1"
config_server_count = 3
config_server_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
config_server_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
query_server_name = "MY_QUERY_SERVER"
query_server_shape = "VM.Standard2.1"
query_server_count = 2
query_server_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
query_server_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
shard_replica_set_name = "MY_SHARD_SERVER_NAME"
shard_replica_set_shape = "VM.Standard2.1"
shard_replica_set_count = 3
shard_replica_set_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
shard_replica_set_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
instance_backup_policy_level = "bronze"
config_disk_size_in_gb = "50"
config_disk_vpus_per_gb = "10"
config_backup_policy_level = "bronze"
query_disk_size_in_gb = "50"
query_disk_vpus_per_gb = "10"
query_backup_policy_level = "bronze"
database_size_in_gb = "50"
database_vpus_per_gb = "10"
database_backup_policy_level = "bronze"
mongodb_version = "5.0"
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
If using Flex Shapes.
######################################## COMMON VARIABLES ######################################
region = "re-region-1"
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
user_ocid = "ocid1.user.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
fingerprint = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
######################################## COMMON VARIABLES ######################################
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
ssh_public_key = "/absolute/path/to/api/key/your_ssh_public_key.pub"
ssh_private_key = "/absolute/path/to/api/key/your_ssh_private_key"
compute_nsg_name = "MY_NSG"
linux_compute_instance_compartment_name = "MY_ARTIFACT_COMPARTMENT"
linux_compute_network_compartment_name = "MY_NETWORK_COMPARTMENT"
private_network_subnet_name = "MY_PRIVATE_SUBNET"
vcn_display_name = "MY_VCN"
config_server_name = "MY_CONFIG_SERVER_NAME"
config_server_shape = "VM.Standard.E4.Flex"
config_server_count = 3
config_server_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
config_server_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
config_server_is_flex_shape = true
config_server_ocpus = 1
config_server_memory_in_gb = 16
query_server_name = "MY_QUERY_SERVER"
query_server_shape = "VM.Standard.E4.Flex"
query_server_count = 2
query_server_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
query_server_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
query_server_is_flex_shape = true
query_server_ocpus = 1
query_server_memory_in_gb = 16
shard_replica_set_name = "MY_SHARD_SERVER_NAME"
shard_replica_set_shape = "VM.Standard.E4.Flex"
shard_replica_set_count = 3
shard_replica_set_ad_list = ["aBCD:RE-REGION-1-AD-1", "aBCD:RE-REGION-1-AD-2","aBCD:RE-REGION-1-AD-3" ]
shard_replica_set_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
shard_replica_set_is_flex_shape = true
shard_replica_set_ocpus = 1
shard_replica_set_memory_in_gb = 16
instance_backup_policy_level = "bronze"
config_disk_size_in_gb = "50"
config_disk_vpus_per_gb = "10"
config_backup_policy_level = "bronze"
query_disk_size_in_gb = "50"
query_disk_vpus_per_gb = "10"
query_backup_policy_level = "bronze"
database_size_in_gb = "50"
database_vpus_per_gb = "10"
database_backup_policy_level = "bronze"
mongodb_version = "5.0"
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
- Compute ssh keys to later log into instances. Paths to the keys should be provided in variables
ssh_public_key
andssh_private_key
. - Variable
compute_nsg_name
is an optional network security group that can be attached. - Variable
mongodb_version
may be set to any of the supported version of MongoDB at the time of creating this brick(4.2, 4.4 or 5.0)
. - Variables
config_server_count
andshard_replica_set_count
are used to choose how many config and shard servers are provisioned respectively. These can be anywhere between1-7
, though it is recommended to use at least3
each for high availability setups to function correctly. - Variable
query_server_count
is used to choose how many query servers are provisioned.2
is a reasonable amount to provision. - Variable
instance_backup_policy_level
specifies the name of the backup policy used on the instance boot volumes. - Variables
config_backup_policy_level
andquery_backup_policy_level
specificy the name of the backup policy used on the ISCSI disks storing log files on the config and query servers respectively. - Variable
database_backup_policy_level
specifices the name of the backup policy used on the ISCSI disks storing database data on the shard servers. - Variables
config_disk_size_in_gb
andquery_disk_size_in_gb
specify the size of the ISCSI disks in GB used to store log files on the config and query servers respectively. This can be between50
and32768
. - Variable
config_disk_vpus_per_gb
andquery_disk_vpus_per_gb
specify the VPUs per GB of the ISCSI disks used to store log files on the config and query servers respectively. The value must be between0
and120
and be multiple of 10. - Variable
database_size_in_gb
specifices the size of the ISCSI disks in GB used to store database data on the shard servers. This can be between50
and32768
. - Variable
database_vpus_per_gb
specifices the VPUs per GB of the ISCSI disks used to store database data on the shard servers. The value must be between0
and120
and be multiple of 10. - Flex Shapes:
- Variable
config_server_is_flex_shape
should be defined as true when the config server instances are a flex shape. The variablesconfig_server_ocpus
andconfig_server_memory_in_gb
should then also be defined. Do not use any of these variables at all when using a standard shape as they are not needed and assume sensible defaults. - Variable
query_server_is_flex_shape
should be defined as true when the query server instances are a flex shape. The variablesquery_server_ocpus
andquery_server_memory_in_gb
should then also be defined. Do not use any of these variables at all when using a standard shape as they are not needed and assume sensible defaults. - Variable
shard_replica_set_is_flex_shape
should be defined as true when the shard server instances are a flex shape. The variablesshard_replica_set_ocpus
andshard_replica_set_memory_in_gb
should then also be defined. Do not use any of these variables at all when using a standard shape as they are not needed and assume sensible defaults.
- Variable
The following is the base provider definition to be used with this module
terraform {
required_version = ">= 0.13.5"
}
provider "oci" {
region = var.region
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
disable_auto_retries = "true"
}
provider "oci" {
alias = "home"
region = data.oci_identity_region_subscriptions.home_region_subscriptions.region_subscriptions[0].region_name
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
disable_auto_retries = "true"
}
Name | Version |
---|---|
terraform | >= 0.13.5 |
oci | >= 4.36.0 |
Name | Version |
---|---|
null | 3.1.0 |
oci | 4.45.0 |
template | 2.2.0 |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
compute_nsg_name | Name of the NSG associated to the computes | string |
"" |
no |
config_backup_policy_level | The backup policy of config server ISCSI disks | any |
n/a | yes |
config_disk_size_in_gb | The size of the attached disk to the config server instances, stores logging data | any |
n/a | yes |
config_disk_vpus_per_gb | The VPUS of the attached disk to the config server instances | any |
n/a | yes |
config_server_ad_list | The availability domains to provision the config server instances in | any |
n/a | yes |
config_server_count | The number of config server instances to provision | any |
n/a | yes |
config_server_fd_list | The fault domains to provision the config server instances in | any |
n/a | yes |
config_server_is_flex_shape | Boolean to determine if the config server instances are flex or not | bool |
false |
no |
config_server_memory_in_gb | The amount of memory in GB for the config server instances to use when flex shape is enabled | string |
"" |
no |
config_server_name | The name given to the config server instances | any |
n/a | yes |
config_server_ocpus | The number of OCPUS for the config server instances to use when flex shape is enabled | string |
"" |
no |
config_server_shape | The shape for the config server instances to use | any |
n/a | yes |
database_backup_policy_level | Backup policy level for Database ISCSI disks | any |
n/a | yes |
database_size_in_gb | The size of the attached disk to the shard server instances, stores database data | any |
n/a | yes |
database_vpus_per_gb | The VPUS of the attached disk to the shard server instances | any |
n/a | yes |
fingerprint | API Key Fingerprint for user_ocid derived from public API Key imported in OCI User config | any |
n/a | yes |
instance_backup_policy_level | The backup policy of all instances boot volumes | any |
n/a | yes |
linux_compute_instance_compartment_name | Defines the compartment name where the infrastructure will be created | any |
n/a | yes |
linux_compute_network_compartment_name | Defines the compartment where the Network is currently located | any |
n/a | yes |
mongodb_version | The version of MongoDB used in the setup | any |
n/a | yes |
private_key_path | Private Key Absolute path location where terraform is executed | any |
n/a | yes |
private_network_subnet_name | Defines the subnet display name where this resource will be created at | any |
n/a | yes |
query_backup_policy_level | The backup policy of query server ISCSI disks | any |
n/a | yes |
query_disk_size_in_gb | The size of the attached disk to the query server instances, stores logging data | any |
n/a | yes |
query_disk_vpus_per_gb | The VPUS of the attached disk to the query server instances | any |
n/a | yes |
query_server_ad_list | The availability domains to provision the query server instances in | any |
n/a | yes |
query_server_count | The number of query server instances to provision | any |
n/a | yes |
query_server_fd_list | The fault domains to provision the query server instances in | any |
n/a | yes |
query_server_is_flex_shape | Boolean to determine if the query server instances are flex or not | bool |
false |
no |
query_server_memory_in_gb | The amount of memory in GB for the query server instances to use when flex shape is enabled | string |
"" |
no |
query_server_name | The name given to the query server instances instance | any |
n/a | yes |
query_server_ocpus | The number of OCPUS for the query server instances to use when flex shape is enabled | string |
"" |
no |
query_server_shape | The shape for the query server instances to use | any |
n/a | yes |
region | Target region where artifacts are going to be created | any |
n/a | yes |
shard_replica_set_ad_list | The availability domains to provision the shard server instances in | any |
n/a | yes |
shard_replica_set_count | The number of shard server instances to provision | any |
n/a | yes |
shard_replica_set_fd_list | The fault domains to provision the shard server instances in | any |
n/a | yes |
shard_replica_set_is_flex_shape | Boolean to determine if the shard server instances are flex or not | bool |
false |
no |
shard_replica_set_memory_in_gb | The amount of memory in GB for the shard server instances to use when flex shape is enabled | string |
"" |
no |
shard_replica_set_name | The name given to the shard server instances | any |
n/a | yes |
shard_replica_set_ocpus | The number of OCPUS for the shard server instances to use when flex shape is enabled | string |
"" |
no |
shard_replica_set_shape | The shape for the shard server instances to use | any |
n/a | yes |
ssh_private_key | Defines SSH Private Key to be used in order to remotely connect to compute instances | any |
n/a | yes |
ssh_public_key | Defines SSH Public Key to be used in order to remotely connect to compute instances | any |
n/a | yes |
tenancy_ocid | OCID of tenancy | any |
n/a | yes |
user_ocid | User OCID in tenancy. Currently hardcoded to user denny.alquinta@oracle.com | any |
n/a | yes |
vcn_display_name | VCN Display name to execute lookup | any |
n/a | yes |
Name | Description |
---|---|
mongodb_config_servers | MongoDB Config Server Instances |
mongodb_query_servers | MongoDB Query Server Instances |
mongodb_shard_servers | MongoDB Shard Server Instances |
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.
Copyright (c) 2021 Oracle and/or its affiliates.
Licensed under the Universal Permissive License (UPL), Version 1.0.
See LICENSE for more details.