Коммит
3bb2660a85
|
@ -0,0 +1,58 @@
|
|||
# Deploy a highly available MongoDB installation on Ubuntu and CentOS virtual machines
|
||||
|
||||
<a href="https://azuredeploy.net/" target="_blank">
|
||||
<img src="http://azuredeploy.net/deploybutton.png"/>
|
||||
</a>
|
||||
|
||||
This template creates a multi-server MongoDB deployment on Ubuntu and CentOS virtual machines, and configures the MongoDB installation for high availability using a replica set.
|
||||
The template also provisions storage accounts, virtual network, availability set, network interfaces, VMs, disks and other infrastructure and runtime resources required by the installation.
|
||||
In addition, and when explicitly enabled, the template can create one publicly accessible "jumpbox" VM allowing to ssh into the MongoDB nodes for diagnostics or troubleshooting purposes.
|
||||
|
||||
The template expects the following parameters:
|
||||
|
||||
| Name | Description | Default Value |
|
||||
|:--- |:---|:---|
|
||||
| adminUsername | Administrator user name used when provisioning virtual machines (which also becomes a system administrator in MongoDB) | |
|
||||
| adminPassword | Administrator password used when provisioning virtual machines (which is also a password for the system administrator in MongoDB) | |
|
||||
| storageAccountName | Unique namespace for the Storage Account where the Virtual Machine's disks will be placed (this name will be used as a prefix to create one or more storage accounts as per t-shirt size) | |
|
||||
| region | Location where resources will be provisioned | |
|
||||
| virtualNetworkName | The arbitrary name of the virtual network provisioned for the MongoDB deployment | mongodbVnet |
|
||||
| subnetName | Subnet name for the virtual network that resources will be provisioned in to | mongodbSubnet |
|
||||
| addressPrefix | The network address space for the virtual network | 10.0.0.0/16 |
|
||||
| subnetPrefix | The network address space for the virtual subnet | 10.0.0.0/24 |
|
||||
| nodeAddressPrefix | The IP address prefix that will be used for constructing a static private IP address for each node in the cluster | 10.0.0.1 |
|
||||
| jumpbox | The flag allowing to enable or disable provisioning of the jumpbox VM that can be used to access the MongoDB environment | Disabled |
|
||||
| tshirtSize | The t-shirt size of the MongoDB deployment (_XSmall_, _Small_, _Medium_, _Large_, _XLarge_, _XXLarge_) | XSmall |
|
||||
| osFamily | The target OS for the virtual machines running MongoDB (_Ubuntu_ or _CentOS_) | Ubuntu |
|
||||
| mongodbVersion | The version of the MongoDB packages to be deployed | 3.0.2 |
|
||||
| replicaSetName | The name of the MongoDB replica set | rs0 |
|
||||
| replicaSetKey | The shared secret key for the MongoDB replica set (6-1024 characters) |||
|
||||
|
||||
Topology
|
||||
--------
|
||||
|
||||
The deployment topology is comprised of a predefined number (as per t-shirt sizing) MongoDB member nodes configured as a replica set, along with the optional
|
||||
arbiter node. Replica sets are the preferred replication mechanism in MongoDB in small-to-medium installations. However, in a large deployment
|
||||
with more than 50 nodes, a master/slave replication is required.
|
||||
|
||||
The following table outlines the deployment topology characteristics for each supported t-shirt size:
|
||||
|
||||
| T-Shirt Size | Member Node VM Size | CPU Cores | Memory | Data Disks | Arbiter Node VM Size | # of Members | Arbiter | # of Storage Accounts |
|
||||
|:--- |:---|:---|:---|:---|:---|:---|:---|:---|
|
||||
| XSmall | Standard_D1 | 1 | 3.5 GB | 2x100 GB | Standard_A1 | 2 | Yes | 1 |
|
||||
| Small | Standard_D1 | 1 | 3.5 GB | 2x100 GB | Standard_A1 | 3 | No | 1 |
|
||||
| Medium | Standard_D2 | 2 | 7 GB | 4x250 GB | Standard_A1 | 4 | Yes | 2 |
|
||||
| Large | Standard_D2 | 2 | 7 GB | 4x250 GB | Standard_A1 | 8 | Yes | 4 |
|
||||
| XLarge | Standard_D3 | 4 | 14 GB | 8x500 GB | Standard_A1 | 8 | Yes | 4 |
|
||||
| XXLarge | Standard_D3 | 4 | 14 GB | 8x500 GB | Standard_A1 | 16 | No | 8 |
|
||||
|
||||
An optional single arbiter node is provisioned in addition to the number of members stated above, thus increasing the total number of nodes by 1.
|
||||
The size of the arbiter node is standardized as _Standard_A1_. Arbiters do not store the data, they vote in elections for primary and require just a bare minimum machine specification to perform their duties.
|
||||
|
||||
##Notes, Known Issues & Limitations
|
||||
- To access the individual MongoDB nodes, you need to use the publicly accessible jumpbox VM and _ssh_ from it into the individual MongoDB instances
|
||||
- The minimum architecture of a replica set is comprised of 3 members. A typical 3-member replica set can have either 3 members that hold data, or 2 members that hold data and an arbiter
|
||||
- The deployment script is not yet idempotent and cannot handle updates (although it currently works for initial provisioning only)
|
||||
- SSH key is not yet implemented and the template currently takes a password for the admin user
|
||||
- MongoDB version 3.0.0 and above is recommended in order to take advantage of high-scale replica sets offered by this template
|
||||
- The current version of the MongoDB template is shipped with Ubuntu support only (adding support for CentOS is just a matter of creating an additional installation .sh script)
|
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "nicArbiter",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipConfigArbiter",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "vmArbiter",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicArbiter')]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]",
|
||||
"platformGuestAgent": "true"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'arbiter')]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]",
|
||||
"linuxOperatingSystemProfile": {
|
||||
"disableSshPasswordAuthentication": "false"
|
||||
}
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces','nicArbiter')]"
|
||||
}
|
||||
],
|
||||
"inputEndpoints": [
|
||||
{
|
||||
"enableDirectServerReturn": "False",
|
||||
"endpointName": "SSH",
|
||||
"privatePort": 22,
|
||||
"publicPort": 22,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "vmArbiter/installmongodb",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmArbiter')]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"adminUsername": {
|
||||
"value": "MongoAdmin"
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": ""
|
||||
},
|
||||
"storageAccountName": {
|
||||
"value": ""
|
||||
},
|
||||
"region": {
|
||||
"value": "West US"
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"value": "mongodbVnet"
|
||||
},
|
||||
"subnetName": {
|
||||
"value": "mongodbSubnet"
|
||||
},
|
||||
"addressPrefix": {
|
||||
"value": "10.0.0.0/16"
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"value": "10.0.0.0/24"
|
||||
},
|
||||
"nodeAddressPrefix": {
|
||||
"value": "10.0.0.1"
|
||||
},
|
||||
"jumpbox": {
|
||||
"value": "Disabled"
|
||||
},
|
||||
"tshirtSize": {
|
||||
"value": "XSmall"
|
||||
},
|
||||
"osFamily": {
|
||||
"value": "Ubuntu"
|
||||
},
|
||||
"mongodbVersion": {
|
||||
"value": "3.0.2"
|
||||
},
|
||||
"replicaSetName": {
|
||||
"value": "rs0"
|
||||
},
|
||||
"replicaSetKey": {
|
||||
"value": ""
|
||||
}
|
||||
}
|
|
@ -0,0 +1,479 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"adminUsername": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Administrator user name used when provisioning virtual machines (which also becomes a system user administrator in MongoDB)"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "Administrator password used when provisioning virtual machines (which is also a password for the system administrator in MongoDB)"
|
||||
}
|
||||
},
|
||||
"storageAccountName": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"Description": "Unique namespace for the Storage Account where the Virtual Machine's disks will be placed (this name will be used as a prefix to create one or more storage accounts as per t-shirt size)"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Location where resources will be provisioned"
|
||||
}
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"type": "string",
|
||||
"defaultValue": "mongodbVnet",
|
||||
"metadata": {
|
||||
"Description": "The arbitrary name of the virtual network provisioned for the MongoDB deployment"
|
||||
}
|
||||
},
|
||||
"subnetName": {
|
||||
"type": "string",
|
||||
"defaultValue": "mongodbSubnet",
|
||||
"metadata": {
|
||||
"Description": "Subnet name for the virtual network that resources will be provisioned in to"
|
||||
}
|
||||
},
|
||||
"addressPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/16",
|
||||
"metadata": {
|
||||
"Description": "The network address space for the virtual network"
|
||||
}
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/24",
|
||||
"metadata": {
|
||||
"Description": "The network address space for the virtual subnet"
|
||||
}
|
||||
},
|
||||
"nodeAddressPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.1",
|
||||
"metadata": {
|
||||
"Description": "The IP address prefix that will be used for constructing a static private IP address for each node in the cluster"
|
||||
}
|
||||
},
|
||||
"jumpbox": {
|
||||
"type": "string",
|
||||
"defaultValue": "Disabled",
|
||||
"allowedValues": [
|
||||
"Enabled",
|
||||
"Disabled"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "The flag allowing to enable or disable provisioning of the jumpbox VM that can be used to access the MongoDB environment"
|
||||
}
|
||||
},
|
||||
"tshirtSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "XSmall",
|
||||
"allowedValues": [
|
||||
"XSmall",
|
||||
"Small",
|
||||
"Medium",
|
||||
"Large",
|
||||
"XLarge",
|
||||
"XXLarge"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "T-shirt size of the MongoDB deployment"
|
||||
}
|
||||
},
|
||||
"osFamily": {
|
||||
"type": "string",
|
||||
"defaultValue": "Ubuntu",
|
||||
"allowedValues": [
|
||||
"Ubuntu",
|
||||
"CentOS"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "The target OS for the virtual machines running MongoDB"
|
||||
}
|
||||
},
|
||||
"mongodbVersion": {
|
||||
"type": "string",
|
||||
"defaultValue": "3.0.2",
|
||||
"metadata": {
|
||||
"Description": "The version of the MongoDB packages to be deployed"
|
||||
}
|
||||
},
|
||||
"replicaSetName": {
|
||||
"type": "string",
|
||||
"defaultValue": "rs0",
|
||||
"metadata": {
|
||||
"Description": "The name of the MongoDB replica set"
|
||||
}
|
||||
},
|
||||
"replicaSetKey": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "The shared secret key for the MongoDB replica set"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"_comment0": "/* T-shirt sizes may vary for different reasons, and some customers may want to modify these - so feel free to go ahead and define your favorite t-shirts */",
|
||||
"tshirtSizeXSmall": {
|
||||
"vmSizeMember": "Standard_D1",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 1,
|
||||
"totalMemberCount": 2,
|
||||
"arbiter": "Enabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D1.json')]",
|
||||
"storageAccountCount": 1,
|
||||
"dataDiskSize": 100
|
||||
},
|
||||
"tshirtSizeSmall": {
|
||||
"vmSizeMember": "Standard_D1",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 2,
|
||||
"totalMemberCount": 3,
|
||||
"arbiter": "Disabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D1.json')]",
|
||||
"storageAccountCount": 1,
|
||||
"dataDiskSize": 100
|
||||
},
|
||||
"tshirtSizeMedium": {
|
||||
"vmSizeMember": "Standard_D2",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 3,
|
||||
"totalMemberCount": 4,
|
||||
"arbiter": "Enabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D2.json')]",
|
||||
"storageAccountCount": 2,
|
||||
"dataDiskSize": 250
|
||||
},
|
||||
"tshirtSizeLarge": {
|
||||
"vmSizeMember": "Standard_D2",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 7,
|
||||
"totalMemberCount": 8,
|
||||
"arbiter": "Enabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D2.json')]",
|
||||
"storageAccountCount": 4,
|
||||
"dataDiskSize": 250
|
||||
},
|
||||
"tshirtSizeXLarge": {
|
||||
"vmSizeMember": "Standard_D3",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 7,
|
||||
"totalMemberCount": 8,
|
||||
"arbiter": "Enabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D3.json')]",
|
||||
"storageAccountCount": 4,
|
||||
"dataDiskSize": 500
|
||||
},
|
||||
"tshirtSizeXXLarge": {
|
||||
"vmSizeMember": "Standard_D3",
|
||||
"vmSizeArbiter": "Standard_A1",
|
||||
"numberOfMembers": 15,
|
||||
"totalMemberCount": 16,
|
||||
"arbiter": "Disabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'member-resources-D3.json')]",
|
||||
"storageAccountCount": 8,
|
||||
"dataDiskSize": 500
|
||||
},
|
||||
"osFamilyUbuntu": {
|
||||
"osName": "ubuntu",
|
||||
"installerBaseUrl": "http://repo.mongodb.org/apt/ubuntu",
|
||||
"installerPackages": "mongodb-org"
|
||||
},
|
||||
"osFamilyCentOS": {
|
||||
"osName": "centos",
|
||||
"installerBaseUrl": "http://downloads-distro.mongodb.org/repo/ubuntu-upstart",
|
||||
"installerPackages": "mongo-10gen mongo-10gen-server"
|
||||
},
|
||||
"vmStorageAccountContainerName": "vhd-mongodb",
|
||||
"vmStorageAccountDomain": ".blob.core.windows.net",
|
||||
"vmSourceImageName": "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_2_LTS-amd64-server-20150309-en-us-30GB",
|
||||
"sourceImageName": "[concat('/',subscription().subscriptionId,'/services/images/',variables('vmSourceImageName'))]",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
|
||||
"sharedScriptUrl": "[concat('https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/shared_scripts/', variables('osFamilySpec').osName, '/')]",
|
||||
"scriptUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/mongodb-high-availability/",
|
||||
"templateBaseUrl": "[variables('scriptUrl')]",
|
||||
"jumpboxTemplateEnabled": "jumpbox-resources.json",
|
||||
"jumpboxTemplateDisabled": "empty-resources.json",
|
||||
"arbiterTemplateEnabled": "arbiter-resources.json",
|
||||
"arbiterTemplateDisabled": "empty-resources.json",
|
||||
"sharedTemplateUrl": "[concat(variables('templateBaseUrl'), 'shared-resources.json')]",
|
||||
"jumpboxTemplateUrl": "[concat(variables('templateBaseUrl'), variables(concat('jumpboxTemplate', parameters('jumpbox'))))]",
|
||||
"arbiterTemplateUrl": "[concat(variables('templateBaseUrl'), variables(concat('arbiterTemplate', variables('clusterSpec').arbiter)))]",
|
||||
"commonSettings": {
|
||||
"availabilitySetName": "mongodbAvailSet",
|
||||
"region": "[parameters('region')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"vhdStorageAccountName": "[parameters('storageAccountName')]",
|
||||
"vhdContainerName": "[variables('vmStorageAccountContainerName')]",
|
||||
"destinationVhdsContainer": "[concat('https://', parameters('storageAccountName'), variables('vmStorageAccountDomain'), '/', variables('vmStorageAccountContainerName'), '/')]",
|
||||
"storageAccountCount": "[variables('clusterSpec').storageAccountCount]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"virtualNetworkName": "[parameters('virtualNetworkName')]",
|
||||
"addressPrefix": "[parameters('addressPrefix')]",
|
||||
"subnetName": "[parameters('subnetName')]",
|
||||
"subnetPrefix": "[parameters('subnetPrefix')]",
|
||||
"subnetRef": "[concat(variables('vnetID'), '/subnets/', parameters('subnetName'))]",
|
||||
"machineIpPrefix": "[parameters('nodeAddressPrefix')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"adminPassword": "[parameters('adminPassword')]",
|
||||
"machineNamePrefix": "mongodb-",
|
||||
"osImageName": "[variables('sourceImageName')]"
|
||||
},
|
||||
"clusterSpec": "[variables(concat('tshirtSize', parameters('tshirtSize')))]",
|
||||
"osFamilySpec": "[variables(concat('osFamily', parameters('osFamily')))]",
|
||||
"installCommand": "[concat('bash mongodb-', variables('osFamilySpec').osName, '-install.sh', ' -i ', variables('osFamilySpec').installerBaseUrl, ' -b ', variables('osFamilySpec').installerPackages, ' -r ', parameters('replicaSetName'), ' -k ', parameters('replicaSetKey'), ' -u ', parameters('adminUsername'), ' -p ', parameters('adminPassword'), ' -x ', variables('networkSettings').machineIpPrefix, ' -n ', variables('clusterSpec').totalMemberCount)]",
|
||||
"vmScripts": {
|
||||
"scriptsToDownload": [
|
||||
"[concat(variables('scriptUrl'), 'mongodb-', variables('osFamilySpec').osName, '-install.sh')]",
|
||||
"[concat(variables('sharedScriptUrl'), 'vm-disk-utils-0.1.sh')]"
|
||||
],
|
||||
"regularNodeInstallCommand": "[variables('installCommand')]",
|
||||
"lastNodeInstallCommand": "[concat(variables('installCommand'), ' -l')]",
|
||||
"arbiterNodeInstallCommand": "[concat(variables('installCommand'), ' -a')]"
|
||||
},
|
||||
"_comment1": "/* The weird list of values below helps partition VM disks across multiple storage accounts to achieve a better throughput */",
|
||||
"_comment2": "/* Feel free to modify the default allocations if you are comfortable and understand what you are doing */",
|
||||
"storageAccountForXSmall_0": "0",
|
||||
"storageAccountForXSmall_1": "0",
|
||||
"storageAccountForSmall_0": "0",
|
||||
"storageAccountForSmall_1": "0",
|
||||
"storageAccountForSmall_2": "0",
|
||||
"storageAccountForMedium_0": "0",
|
||||
"storageAccountForMedium_1": "0",
|
||||
"storageAccountForMedium_2": "0",
|
||||
"storageAccountForMedium_3": "0",
|
||||
"storageAccountForLarge_0": "0",
|
||||
"storageAccountForLarge_1": "1",
|
||||
"storageAccountForLarge_2": "2",
|
||||
"storageAccountForLarge_3": "3",
|
||||
"storageAccountForLarge_4": "0",
|
||||
"storageAccountForLarge_5": "1",
|
||||
"storageAccountForLarge_6": "2",
|
||||
"storageAccountForLarge_7": "3",
|
||||
"storageAccountForXLarge_0": "0",
|
||||
"storageAccountForXLarge_1": "1",
|
||||
"storageAccountForXLarge_2": "2",
|
||||
"storageAccountForXLarge_3": "3",
|
||||
"storageAccountForXLarge_4": "0",
|
||||
"storageAccountForXLarge_5": "1",
|
||||
"storageAccountForXLarge_6": "2",
|
||||
"storageAccountForXLarge_7": "3",
|
||||
"storageAccountForXXLarge_0": "0",
|
||||
"storageAccountForXXLarge_1": "1",
|
||||
"storageAccountForXXLarge_2": "2",
|
||||
"storageAccountForXXLarge_3": "3",
|
||||
"storageAccountForXXLarge_4": "4",
|
||||
"storageAccountForXXLarge_5": "5",
|
||||
"storageAccountForXXLarge_6": "6",
|
||||
"storageAccountForXXLarge_7": "7",
|
||||
"storageAccountForXXLarge_8": "0",
|
||||
"storageAccountForXXLarge_9": "1",
|
||||
"storageAccountForXXLarge_10": "2",
|
||||
"storageAccountForXXLarge_11": "3",
|
||||
"storageAccountForXXLarge_12": "4",
|
||||
"storageAccountForXXLarge_13": "5",
|
||||
"storageAccountForXXLarge_14": "6",
|
||||
"storageAccountForXXLarge_15": "7"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"name": "shared-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('sharedTemplateUrl')]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": "[variables('storageSettings')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "jumpbox-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('jumpboxTemplateUrl')]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": {
|
||||
"vhdStorageAccountName": "[concat(variables('storageSettings').vhdStorageAccountName, '0')]",
|
||||
"vhdContainerName": "[variables('storageSettings').vhdContainerName]",
|
||||
"destinationVhdsContainer": "[concat('https://', variables('storageSettings').vhdStorageAccountName, '0', variables('vmStorageAccountDomain'), '/', variables('storageSettings').vhdContainerName, '/')]"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": "[variables('machineSettings')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"name": "[concat('member-resources', copyindex())]",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
|
||||
],
|
||||
"copy": {
|
||||
"name": "memberNodesLoop",
|
||||
"count": "[variables('clusterSpec').numberOfMembers]"
|
||||
},
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('clusterSpec').vmTemplate]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": {
|
||||
"vhdStorageAccountName": "[concat(variables('storageSettings').vhdStorageAccountName, variables(concat('storageAccountFor', parameters('tshirtSize'), '_', copyindex())))]",
|
||||
"vhdContainerName": "[variables('storageSettings').vhdContainerName]",
|
||||
"destinationVhdsContainer": "[concat('https://', variables('storageSettings').vhdStorageAccountName, variables(concat('storageAccountFor', parameters('tshirtSize'), '_', copyindex())), variables('vmStorageAccountDomain'), '/', variables('storageSettings').vhdContainerName, '/')]"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": {
|
||||
"adminUsername": "[variables('machineSettings').adminUsername]",
|
||||
"adminPassword": "[variables('machineSettings').adminPassword]",
|
||||
"machineNamePrefix": "[variables('machineSettings').machineNamePrefix]",
|
||||
"osImageName": "[variables('machineSettings').osImageName]",
|
||||
"vmSize": "[variables('clusterSpec').vmSizeMember]",
|
||||
"dataDiskSize": "[variables('clusterSpec').dataDiskSize]",
|
||||
"machineIndex": "[copyindex()]",
|
||||
"vmScripts": "[variables('vmScripts').scriptsToDownload]",
|
||||
"commandToExecute": "[variables('vmScripts').regularNodeInstallCommand]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"name": "lastmember-resources",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"memberNodesLoop"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('clusterSpec').vmTemplate]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": {
|
||||
"vhdStorageAccountName": "[concat(variables('storageSettings').vhdStorageAccountName, variables(concat('storageAccountFor', parameters('tshirtSize'), '_', variables('clusterSpec').numberOfMembers)))]",
|
||||
"vhdContainerName": "[variables('storageSettings').vhdContainerName]",
|
||||
"destinationVhdsContainer": "[concat('https://', variables('storageSettings').vhdStorageAccountName, variables(concat('storageAccountFor', parameters('tshirtSize'), '_', variables('clusterSpec').numberOfMembers)), variables('vmStorageAccountDomain'), '/', variables('storageSettings').vhdContainerName, '/')]"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": {
|
||||
"adminUsername": "[variables('machineSettings').adminUsername]",
|
||||
"adminPassword": "[variables('machineSettings').adminPassword]",
|
||||
"machineNamePrefix": "[variables('machineSettings').machineNamePrefix]",
|
||||
"osImageName": "[variables('machineSettings').osImageName]",
|
||||
"vmSize": "[variables('clusterSpec').vmSizeMember]",
|
||||
"dataDiskSize": "[variables('clusterSpec').dataDiskSize]",
|
||||
"machineIndex": "[variables('clusterSpec').numberOfMembers]",
|
||||
"vmScripts": "[variables('vmScripts').scriptsToDownload]",
|
||||
"commandToExecute": "[variables('vmScripts').lastNodeInstallCommand]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "arbiter-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Resources/deployments/', 'lastmember-resources')]"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('arbiterTemplateUrl')]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": {
|
||||
"vhdStorageAccountName": "[concat(variables('storageSettings').vhdStorageAccountName, '0')]",
|
||||
"vhdContainerName": "[variables('storageSettings').vhdContainerName]",
|
||||
"destinationVhdsContainer": "[concat('https://', variables('storageSettings').vhdStorageAccountName, '0', variables('vmStorageAccountDomain'), '/', variables('storageSettings').vhdContainerName, '/')]"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": {
|
||||
"adminUsername": "[variables('machineSettings').adminUsername]",
|
||||
"adminPassword": "[variables('machineSettings').adminPassword]",
|
||||
"machineNamePrefix": "[variables('machineSettings').machineNamePrefix]",
|
||||
"osImageName": "[variables('machineSettings').osImageName]",
|
||||
"vmSize": "[variables('clusterSpec').vmSizeArbiter]",
|
||||
"vmScripts": "[variables('vmScripts').scriptsToDownload]",
|
||||
"commandToExecute": "[concat(variables('vmScripts').arbiterNodeInstallCommand)]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
],
|
||||
"outputs": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"vmSize": "Standard_A0"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "jumpboxPublicIP",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "jumpboxNIC",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', 'jumpboxPublicIP')]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipConfigJumpbox",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses','jumpboxPublicIP')]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "jumpboxVM",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'jumpboxNIC')]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('vmSize')]",
|
||||
"platformGuestAgent": "true"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'jumpbox')]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]",
|
||||
"linuxOperatingSystemProfile": {
|
||||
"disableSshPasswordAuthentication": "false"
|
||||
}
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces','jumpboxNIC')]"
|
||||
}
|
||||
],
|
||||
"inputEndpoints": [
|
||||
{
|
||||
"enableDirectServerReturn": "False",
|
||||
"endpointName": "SSH",
|
||||
"privatePort": 22,
|
||||
"publicPort": 22,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk4",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 4,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk4.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk5",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 5,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk5.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk6",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 6,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk6.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk7",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 7,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk7.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk4",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 4,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk4.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk5",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 5,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk5.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk6",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 6,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk6.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk7",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 7,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk7.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk8",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 8,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk8.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk9",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 9,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk9.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk10",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 10,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk10.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk11",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 11,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk11.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk12",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 12,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk12.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk13",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 13,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk13.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk14",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 14,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk14.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk15",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 15,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk15.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,365 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk4",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 4,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk4.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk5",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 5,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk5.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk6",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 6,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk6.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk7",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 7,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk7.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk8",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 8,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk8.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk9",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 9,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk9.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk10",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 10,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk10.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk11",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 11,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk11.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk12",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 12,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk12.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk13",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 13,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk13.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk14",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 14,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk14.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk15",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 15,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk15.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk16",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 16,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk16.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk17",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 17,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk17.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk18",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 18,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk18.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk19",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 19,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk19.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk20",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 20,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk20.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk21",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 21,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk21.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk22",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 22,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk22.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk23",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 23,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk23.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk24",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 24,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk24.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk25",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 25,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk25.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk26",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 26,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk26.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk27",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 27,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk27.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk28",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 28,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk28.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk29",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 29,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk29.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk30",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 30,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk30.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk31",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 31,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk31.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk4",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 4,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk4.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk5",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 5,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk5.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk6",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 6,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk6.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk7",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 7,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk7.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('machineSettings').adminPassword]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"name": "dataDisk0",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 0,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk0.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk1",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 1,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk1.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk2",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 2,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk2.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk3",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 3,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk3.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk4",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 4,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk4.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk5",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 5,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk5.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk6",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 6,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk6.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk7",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 7,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk7.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk8",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 8,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk8.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk9",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 9,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk9.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk10",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 10,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk10.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk11",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 11,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk11.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk12",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 12,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk12.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk13",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 13,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk13.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk14",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 14,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk14.vhd')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataDisk15",
|
||||
"diskSizeGB": "[parameters('machineSettings').dataDiskSize]",
|
||||
"lun": 15,
|
||||
"vhd": {
|
||||
"Uri": "[concat(parameters('storageSettings').destinationVhdsContainer, 'vm', parameters('machineSettings').machineIndex, 'dataDisk15.vhd')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installmongodb')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"itemDisplayName": "Deploys MongoDB on Ubuntu Virtual Machines",
|
||||
"description": "This template creates a multi-server MongoDB deployment on Ubuntu virtual machines, and configures the MongoDB installation for high availability",
|
||||
"summary": "This template creates a multi-server MongoDB deployment on Ubuntu virtual machines",
|
||||
"githubUsername": "TheAzureGuy",
|
||||
"dateUpdated": "2015-04-18"
|
||||
}
|
|
@ -0,0 +1,338 @@
|
|||
#!/bin/bash
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MongoDB Template for Azure Resource Manager (brought to you by Full Scale 180 Inc)
|
||||
#
|
||||
# This script installs MongoDB on each Azure virtual machine. The script will be supplied with
|
||||
# runtime parameters declared from within the corresponding ARM template.
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
PACKAGE_URL=http://repo.mongodb.org/apt/ubuntu
|
||||
PACKAGE_NAME=mongodb-org
|
||||
REPLICA_SET_KEY_DATA=""
|
||||
REPLICA_SET_NAME=""
|
||||
REPLICA_SET_KEY_FILE="/etc/mongo-replicaset-key"
|
||||
DATA_DISKS="/datadisks"
|
||||
DATA_MOUNTPOINT="$DATA_DISKS/disk1"
|
||||
MONGODB_DATA="$DATA_MOUNTPOINT/mongodb"
|
||||
MONGODB_PORT=27017
|
||||
IS_ARBITER=false
|
||||
IS_LAST_MEMBER=false
|
||||
JOURNAL_ENABLED=true
|
||||
ADMIN_USER_NAME=""
|
||||
ADMIN_USER_PASSWORD=""
|
||||
INSTANCE_COUNT=1
|
||||
NODE_IP_PREFIX="10.0.0.1"
|
||||
LOGGING_KEY="[logging-key]"
|
||||
|
||||
help()
|
||||
{
|
||||
echo "This script installs MongoDB on the Ubuntu virtual machine image"
|
||||
echo "Options:"
|
||||
echo " -i Installation package URL"
|
||||
echo " -b Installation package name"
|
||||
echo " -r Replica set name"
|
||||
echo " -k Replica set key"
|
||||
echo " -u System administrator's user name"
|
||||
echo " -p System administrator's password"
|
||||
echo " -x Member node IP prefix"
|
||||
echo " -n Number of member nodes"
|
||||
echo " -a (arbiter indicator)"
|
||||
echo " -l (last member indicator)"
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
# If you want to enable this logging add a un-comment the line below and add your account key
|
||||
#curl -X POST -H "content-type:text/plain" --data-binary "$(date) | ${HOSTNAME} | $1" https://logs-01.loggly.com/inputs/${LOGGING_KEY}/tag/redis-extension,${HOSTNAME}
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
log "Begin execution of MongoDB installation script extension on ${HOSTNAME}"
|
||||
|
||||
if [ "${UID}" -ne 0 ];
|
||||
then
|
||||
log "Script executed without root permissions"
|
||||
echo "You must be root to run this program." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Parse script parameters
|
||||
while getopts :i:b:r:k:u:p:x:n:alh optname; do
|
||||
|
||||
# Log input parameters (except the admin password) to facilitate troubleshooting
|
||||
if [ ! "$optname" == "p" ] && [ ! "$optname" == "k" ]; then
|
||||
log "Option $optname set with value ${OPTARG}"
|
||||
fi
|
||||
|
||||
case $optname in
|
||||
i) # Installation package location
|
||||
PACKAGE_URL=${OPTARG}
|
||||
;;
|
||||
b) # Installation package name
|
||||
PACKAGE_NAME=${OPTARG}
|
||||
;;
|
||||
r) # Replica set name
|
||||
REPLICA_SET_NAME=${OPTARG}
|
||||
;;
|
||||
k) # Replica set key
|
||||
REPLICA_SET_KEY_DATA=${OPTARG}
|
||||
;;
|
||||
u) # Administrator's user name
|
||||
ADMIN_USER_NAME=${OPTARG}
|
||||
;;
|
||||
p) # Administrator's user name
|
||||
ADMIN_USER_PASSWORD=${OPTARG}
|
||||
;;
|
||||
x) # Private IP address prefix
|
||||
NODE_IP_PREFIX=${OPTARG}
|
||||
;;
|
||||
n) # Number of instances
|
||||
INSTANCE_COUNT=${OPTARG}
|
||||
;;
|
||||
a) # Arbiter indicator
|
||||
IS_ARBITER=true
|
||||
JOURNAL_ENABLED=false
|
||||
;;
|
||||
l) # Last member indicator
|
||||
IS_LAST_MEMBER=true
|
||||
;;
|
||||
h) # Helpful hints
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
\?) # Unrecognized option - show help
|
||||
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate parameters
|
||||
if [ "$ADMIN_USER_NAME" == "" ] || [ "$ADMIN_USER_PASSWORD" == "" ];
|
||||
then
|
||||
log "Script executed without admin credentials"
|
||||
echo "You must provide a name and password for the system administrator." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
#############################################################################
|
||||
tune_memory()
|
||||
{
|
||||
# Disable THP on a running system
|
||||
echo never > /sys/kernel/mm/transparent_hugepage/enabled
|
||||
echo never > /sys/kernel/mm/transparent_hugepage/defrag
|
||||
|
||||
# Disable THP upon reboot
|
||||
cp -p /etc/rc.local /etc/rc.local.`date +%Y%m%d-%H:%M`
|
||||
sed -i -e '$i \ if test -f /sys/kernel/mm/transparent_hugepage/enabled; then \
|
||||
echo never > /sys/kernel/mm/transparent_hugepage/enabled \
|
||||
fi \ \
|
||||
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then \
|
||||
echo never > /sys/kernel/mm/transparent_hugepage/defrag \
|
||||
fi \
|
||||
\n' /etc/rc.local
|
||||
}
|
||||
|
||||
tune_system()
|
||||
{
|
||||
# Add local machine name to the hosts file to facilitate IP address resolution
|
||||
if grep -q "${HOSTNAME}" /etc/hosts
|
||||
then
|
||||
echo "${HOSTNAME} was found in /etc/hosts"
|
||||
else
|
||||
echo "${HOSTNAME} was not found in and will be added to /etc/hosts"
|
||||
# Append it to the hsots file if not there
|
||||
echo "127.0.0.1 $(hostname)" >> /etc/hosts
|
||||
log "Hostname ${HOSTNAME} added to /etc/hosts"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
install_mongodb()
|
||||
{
|
||||
log "Downloading MongoDB package $PACKAGE_NAME from $PACKAGE_URL"
|
||||
|
||||
# Configure mongodb.list file with the correct location
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
|
||||
echo "deb ${PACKAGE_URL} "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
|
||||
|
||||
# Install updates
|
||||
apt-get -y update
|
||||
|
||||
# Remove any previously created configuration file to avoid a prompt
|
||||
if [ -f /etc/mongod.conf ]; then
|
||||
rm /etc/mongod.conf
|
||||
fi
|
||||
|
||||
#Install Mongo DB
|
||||
log "Installing MongoDB package $PACKAGE_NAME"
|
||||
apt-get -y install $PACKAGE_NAME
|
||||
|
||||
# Stop Mongod as it may be auto-started during the above step (which is not desirable)
|
||||
stop_mongodb
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_datadisks()
|
||||
{
|
||||
# Stripe all of the data
|
||||
log "Formatting and configuring the data disks"
|
||||
|
||||
bash ./vm-disk-utils-0.1.sh -b $DATA_DISKS -s
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_replicaset()
|
||||
{
|
||||
log "Configuring a replica set $REPLICA_SET_NAME"
|
||||
|
||||
echo "$REPLICA_SET_KEY_DATA" | tee "$REPLICA_SET_KEY_FILE" > /dev/null
|
||||
chown -R mongodb:mongodb "$REPLICA_SET_KEY_FILE"
|
||||
chmod 600 "$REPLICA_SET_KEY_FILE"
|
||||
|
||||
# Enable replica set in the configuration file
|
||||
sed -i "s|#keyFile: \"\"$|keyFile: \"${REPLICA_SET_KEY_FILE}\"|g" /etc/mongod.conf
|
||||
sed -i "s|authorization: \"disabled\"$|authorization: \"enabled\"|g" /etc/mongod.conf
|
||||
sed -i "s|#replication:|replication:|g" /etc/mongod.conf
|
||||
sed -i "s|#replSetName:|replSetName:|g" /etc/mongod.conf
|
||||
|
||||
# Stop the currently running MongoDB daemon as we will need to reload its configuration
|
||||
stop_mongodb
|
||||
|
||||
# Important not to attempt to start the daemon immediately after it was stopped as unclean shutdown may be wrongly perceived
|
||||
sleep 10s
|
||||
|
||||
# Attempt to start the MongoDB daemon so that configuration changes take effect
|
||||
start_mongodb
|
||||
|
||||
# Initiate a replica set (only run this section on the very last node)
|
||||
if [ "$IS_LAST_MEMBER" = true ]; then
|
||||
# Log a message to facilitate troubleshooting
|
||||
log "Initiating a replica set $REPLICA_SET_NAME with $INSTANCE_COUNT members"
|
||||
|
||||
# Initiate a replica set
|
||||
mongo master -u $ADMIN_USER_NAME -p $ADMIN_USER_PASSWORD --host 127.0.0.1 --eval "printjson(rs.initiate())"
|
||||
|
||||
# Add all members except this node as it will be included into the replica set after the above command completes
|
||||
for (( n=0 ; n<($INSTANCE_COUNT-1) ; n++))
|
||||
do
|
||||
MEMBER_HOST="${NODE_IP_PREFIX}${n}:${MONGODB_PORT}"
|
||||
|
||||
log "Adding member $MEMBER_HOST to replica set $REPLICA_SET_NAME"
|
||||
mongo master -u $ADMIN_USER_NAME -p $ADMIN_USER_PASSWORD --host 127.0.0.1 --eval "printjson(rs.add('${MEMBER_HOST}'))"
|
||||
done
|
||||
|
||||
# Print the current replica set configuration
|
||||
mongo master -u $ADMIN_USER_NAME -p $ADMIN_USER_PASSWORD --host 127.0.0.1 --eval "printjson(rs.conf())"
|
||||
mongo master -u $ADMIN_USER_NAME -p $ADMIN_USER_PASSWORD --host 127.0.0.1 --eval "printjson(rs.status())"
|
||||
fi
|
||||
|
||||
# Register an arbiter node with the replica set
|
||||
if [ "$IS_ARBITER" = true ]; then
|
||||
|
||||
# Work out the IP address of the last member node where we initiated a replica set
|
||||
let "PRIMARY_MEMBER_INDEX=$INSTANCE_COUNT-1"
|
||||
PRIMARY_MEMBER_HOST="${NODE_IP_PREFIX}${PRIMARY_MEMBER_INDEX}:${MONGODB_PORT}"
|
||||
CURRENT_NODE_IPS=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
|
||||
CURRENT_NODE_IP=${CURRENT_NODE_IPS[@]}
|
||||
|
||||
log "Adding an arbiter ${HOSTNAME} ($CURRENT_NODE_IP) node to the replica set $REPLICA_SET_NAME"
|
||||
mongo master -u $ADMIN_USER_NAME -p $ADMIN_USER_PASSWORD --host $PRIMARY_MEMBER_HOST --eval "printjson(rs.addArb('${CURRENT_NODE_IP}'))"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_mongodb()
|
||||
{
|
||||
log "Configuring MongoDB"
|
||||
|
||||
mkdir -p "$MONGODB_DATA"
|
||||
mkdir "$MONGODB_DATA/log"
|
||||
mkdir "$MONGODB_DATA/db"
|
||||
|
||||
chown -R mongodb:mongodb "$MONGODB_DATA/db"
|
||||
chown -R mongodb:mongodb "$MONGODB_DATA/log"
|
||||
chmod 755 "$MONGODB_DATA"
|
||||
|
||||
mkdir /var/run/mongodb
|
||||
touch /var/run/mongodb/mongod.pid
|
||||
chmod 777 /var/run/mongodb/mongod.pid
|
||||
|
||||
tee /etc/mongod.conf > /dev/null <<EOF
|
||||
systemLog:
|
||||
destination: file
|
||||
path: "$MONGODB_DATA/log/mongod.log"
|
||||
quiet: true
|
||||
logAppend: true
|
||||
processManagement:
|
||||
fork: true
|
||||
pidFilePath: "/var/run/mongodb/mongod.pid"
|
||||
net:
|
||||
port: $MONGODB_PORT
|
||||
security:
|
||||
#keyFile: ""
|
||||
authorization: "disabled"
|
||||
storage:
|
||||
dbPath: "$MONGODB_DATA/db"
|
||||
directoryPerDB: true
|
||||
journal:
|
||||
enabled: $JOURNAL_ENABLED
|
||||
#replication:
|
||||
#replSetName: "$REPLICA_SET_NAME"
|
||||
EOF
|
||||
}
|
||||
|
||||
start_mongodb()
|
||||
{
|
||||
log "Starting MongoDB daemon processes"
|
||||
service mongod start
|
||||
|
||||
# Wait for MongoDB daemon to start and initialize for the first time (this may take up to a minute or so)
|
||||
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/$MONGODB_PORT"; do sleep 10; done
|
||||
}
|
||||
|
||||
stop_mongodb()
|
||||
{
|
||||
# Find out what PID the MongoDB instance is running as (if any)
|
||||
MONGOPID=`ps -ef | grep '/usr/bin/mongod' | grep -v grep | awk '{print $2}'`
|
||||
|
||||
if [ ! -z "$MONGOPID" ]; then
|
||||
log "Stopping MongoDB daemon processes (PID $MONGOPID)"
|
||||
|
||||
kill -15 $MONGOPID
|
||||
fi
|
||||
}
|
||||
|
||||
configure_db_users()
|
||||
{
|
||||
# Create a system administrator
|
||||
log "Creating a system administrator"
|
||||
mongo master --host 127.0.0.1 --eval "db.createUser({user: '${ADMIN_USER_NAME}', pwd: '${ADMIN_USER_PASSWORD}', roles:[{ role: 'userAdminAnyDatabase', db: 'admin' }, { role: 'clusterAdmin', db: 'admin' }, { role: 'readWriteAnyDatabase', db: 'admin' }, { role: 'dbAdminAnyDatabase', db: 'admin' } ]})"
|
||||
}
|
||||
|
||||
# Step 1
|
||||
configure_datadisks
|
||||
|
||||
# Step 2
|
||||
tune_memory
|
||||
tune_system
|
||||
|
||||
# Step 3
|
||||
install_mongodb
|
||||
|
||||
# Step 4
|
||||
configure_mongodb
|
||||
|
||||
# Step 5
|
||||
start_mongodb
|
||||
|
||||
# Step 6
|
||||
configure_db_users
|
||||
|
||||
# Step 7
|
||||
configure_replicaset
|
||||
|
||||
# Exit (proudly)
|
||||
exit 0
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[concat(parameters('storageSettings').vhdStorageAccountName, copyindex())]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"copy": {
|
||||
"name": "storageAccountsLoop",
|
||||
"count": "[parameters('storageSettings').storageAccountCount]"
|
||||
},
|
||||
"properties": {
|
||||
"accountType": "Standard_LRS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Compute/availabilitySets",
|
||||
"name": "[parameters('commonSettings').availabilitySetName]",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[parameters('networkSettings').virtualNetworkName]",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[parameters('networkSettings').addressPrefix]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[parameters('networkSettings').subnetName]",
|
||||
"properties": {
|
||||
"addressPrefix": "[parameters('networkSettings').subnetPrefix]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
# Install Nagios Core on Ubuntu Virtual Machines using Custom Script Linux Extension
|
||||
|
||||
<a href="https://azuredeploy.net/" target="_blank">
|
||||
<img src="http://azuredeploy.net/deploybutton.png"/>
|
||||
</a>
|
||||
|
||||
This template deploys Nagios Core, a host/service/network monitoring solution released under the GNU General Public License. This template also provisions a storage account, virtual network, public IP addresses and network interfaces required by the installation.
|
||||
|
||||
Visit the Nagios homepage at http://www.nagios.org for documentation, new releases, bug reports, information on discussion forums, and more.
|
||||
|
||||
The template requires the following parameters:
|
||||
|
||||
| Name | Description |
|
||||
|:--- |:---|
|
||||
| storageAccountName | Unique DNS Name for the storage account where the virtual machine's disks will be placed |
|
||||
| adminUsername | Admin user name for the virtual machine |
|
||||
| adminPassword | Admin password for the virtual machine |
|
||||
| region | Region name where the corresponding Azure artifacts will be created |
|
||||
| virtualNetworkName | Name of virtual network |
|
||||
| subnetName | Name of the virtual network subnet |
|
||||
| addressPrefix | The IP address mask used by the virtual network |
|
||||
| subnetPrefix | The subnet mask used by the virtual network subnet |
|
||||
| domainName | Domain name of the publicly accessible Apache web server hosting Nagios |
|
||||
| tshirtSize | T-shirt size of the Nagios deployment |
|
||||
|
||||
Topology
|
||||
--------
|
||||
The Nagios deployment topology is comprised of a single VM instance that can be customized and scaled up using the _tshirtSize_ parameter. The following table outlines the VM characteristics for each supported t-shirt size:
|
||||
|
||||
| T-Shirt Size | VM Size | CPU Cores | Memory |
|
||||
|:--- |:---|:---|:---|
|
||||
| Small | Standard_A1 | 1 | 1.75 GB |
|
||||
| Medium | Standard_D1 | 1 | 3.5 GB |
|
||||
| Large | Standard_D2 | 2 | 7 GB |
|
||||
| XLarge | Standard_D3 | 4 | 14 GB |
|
||||
| XXLarge | Standard_D3 | 8 | 28 GB |
|
||||
|
||||
##Known Issues and Limitations
|
||||
- A single instance installation Nagios Core is performed by the template
|
||||
- This template does not install any monitoring targets
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"storageAccountName": {
|
||||
"value": "armdeploy4"
|
||||
},
|
||||
"adminUsername": {
|
||||
"value": "NagiosAdmin"
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": ""
|
||||
},
|
||||
"region": {
|
||||
"value": "West US"
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"value": "nagiosClustVnet"
|
||||
},
|
||||
"subnetName": {
|
||||
"value": "Subnet1"
|
||||
},
|
||||
"addressPrefix": {
|
||||
"value": "10.0.0.0/16"
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"value": "10.0.0.0/24"
|
||||
},
|
||||
"domainName": {
|
||||
"value": "nagiosonazure"
|
||||
},
|
||||
"tshirtSize": {
|
||||
"value": "Medium"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,264 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"adminUsername": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Administrator user name used when provisioning virtual machines"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "Administrator password used when provisioning virtual machines"
|
||||
}
|
||||
},
|
||||
"storageAccountName": {
|
||||
"type": "string",
|
||||
"defaultValue": "uniqueStorageAccountName",
|
||||
"metadata": {
|
||||
"Description": "Unique namespace for the Storage Account where the Virtual Machine's disks will be placed"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"defaultValue": "West US",
|
||||
"metadata": {
|
||||
"Description": "Location where resources will be provisioned"
|
||||
}
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"type": "string",
|
||||
"defaultValue": "myVNET",
|
||||
"metadata": {
|
||||
"Description": "The arbitrary name of the virtual network provisioned for the cluster"
|
||||
}
|
||||
},
|
||||
"addressPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/16",
|
||||
"metadata": {
|
||||
"Description": "The network address space for the virtual network"
|
||||
}
|
||||
},
|
||||
"subnetName": {
|
||||
"type": "string",
|
||||
"defaultValue": "Subnet-1",
|
||||
"metadata": {
|
||||
"Description": "Subnet name for the virtual network that resources will be provisioned in to"
|
||||
}
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/24",
|
||||
"metadata": {
|
||||
"Description": "Address space for the virtual network subnet"
|
||||
}
|
||||
},
|
||||
"domainName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Domain name of the publicly accessible Apache web server hosting Nagios"
|
||||
}
|
||||
},
|
||||
"tshirtSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "Medium",
|
||||
"allowedValues": [
|
||||
"Small",
|
||||
"Medium",
|
||||
"Large",
|
||||
"XLarge",
|
||||
"XXLarge"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "T-shirt size of the Nagios deployment"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"vmStorageAccountContainerName": "vhd",
|
||||
"vmSourceImageName": "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_2_LTS-amd64-server-20150309-en-us-30GB",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
|
||||
"subnetRef": "[concat(variables('vnetID'),'/subnets/',parameters('subnetName'))]",
|
||||
"sourceImageName": "[concat('/',subscription().subscriptionId,'/services/images/',variables('vmSourceImageName'))]",
|
||||
"computerNamePrefix": "NagiosCoreSrv_",
|
||||
"scriptUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/nagios-on-ubuntu/",
|
||||
"tshirtSizeSmall": {
|
||||
"numberOfInstances": 1,
|
||||
"vmSize": "Standard_A1"
|
||||
},
|
||||
"tshirtSizeMedium": {
|
||||
"numberOfInstances": 1,
|
||||
"vmSize": "Standard_D1"
|
||||
},
|
||||
"tshirtSizeLarge": {
|
||||
"numberOfInstances": 1,
|
||||
"vmSize": "Standard_D2"
|
||||
},
|
||||
"tshirtSizeXLarge": {
|
||||
"numberOfInstances": 1,
|
||||
"vmSize": "Standard_D3"
|
||||
},
|
||||
"tshirtSizeXXLarge": {
|
||||
"numberOfInstances": 1,
|
||||
"vmSize": "Standard_D4"
|
||||
},
|
||||
"numberOfInstances": "[variables(concat('tshirtSize', parameters('tshirtSize'))).numberOfInstances]",
|
||||
"vmSize": "[variables(concat('tshirtSize', parameters('tshirtSize'))).vmSize]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[parameters('storageAccountName')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('region')]",
|
||||
"properties": {
|
||||
"accountType": "Standard_LRS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[parameters('virtualNetworkName')]",
|
||||
"location": "[parameters('region')]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[parameters('addressPrefix')]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[parameters('subnetName')]",
|
||||
"properties": {
|
||||
"addressPrefix": "[parameters('subnetPrefix')]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[concat('publicIP', copyIndex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"copy": {
|
||||
"name": "publicIPLoop",
|
||||
"count": "[variables('numberOfInstances')]"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic",
|
||||
"dnsSettings": {
|
||||
"domainNameLabel": "[parameters('domainName')]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nic', copyindex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"copy": {
|
||||
"name": "nicLoop",
|
||||
"count": "[variables('numberOfInstances')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', 'publicIP', copyindex())]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses',concat('publicIP', copyindex()))]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[variables('subnetRef')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('nagiosSrv', copyindex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"copy": {
|
||||
"name": "virtualMachineLoop",
|
||||
"count": "[variables('numberOfInstances')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nic', copyindex())]",
|
||||
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('vmSize')]",
|
||||
"platformGuestAgent": "true"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(variables('computerNamePrefix'), copyIndex())]",
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"adminPassword": "[parameters('adminPassword')]",
|
||||
"linuxOperatingSystemProfile": {
|
||||
"disableSshPasswordAuthentication": "false"
|
||||
}
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[variables('sourceImageName')]"
|
||||
},
|
||||
"destinationVhdsContainer": "[concat('https://',parameters('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/')]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nic', copyindex()))]"
|
||||
}
|
||||
],
|
||||
"inputEndpoints": [
|
||||
{
|
||||
"enableDirectServerReturn": "False",
|
||||
"endpointName": "SSH",
|
||||
"privatePort": 22,
|
||||
"publicPort": 22,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('nagiosSrv', copyindex(), '/installnagios')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('region')]",
|
||||
"copy": {
|
||||
"name": "virtualMachineExtensionsLoop",
|
||||
"count": "[variables('numberOfInstances')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'nagiosSrv', copyindex())]",
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nic', copyindex())]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": [
|
||||
"[concat(variables('scriptUrl'), 'nagios-core-install.sh')]"
|
||||
],
|
||||
"commandToExecute": "[concat('bash nagios-core-install.sh -u ', parameters('adminUsername'), ' -p ', parameters('adminPassword'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"itemDisplayName": "Deploys Nagios Core on Ubuntu Virtual Machines",
|
||||
"description": "This template installs and configures Nagios Core, the industry standard, Open Source IT monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes",
|
||||
"summary": "This template creates a Nagios Core installation on Ubuntu virtual machines",
|
||||
"githubUsername": "TheAzureGuy",
|
||||
"dateUpdated": "2015-04-10"
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script parameters and their defaults
|
||||
SERVICE_USERNAME="nagios"
|
||||
ADMIN_USERNAME="nagios"
|
||||
ADMIN_PASSWORD="Zk8LgLeR4ZimcgipTNzJKUBXVABDpYH63B9bzMbh2uRm8gYwRFPhSz8AvYspz3vs" # Don't worry, this is not the actual password. The real password will be supplied by the ARM template.
|
||||
CORE_VERSION="4.0.8"
|
||||
PLUGINS_VERSION="2.0.3"
|
||||
LOGGING_KEY="[logging-key]"
|
||||
|
||||
########################################################
|
||||
# This script will install and configure Nagios Core
|
||||
########################################################
|
||||
help()
|
||||
{
|
||||
echo "This script installs and configures Nagios Core on the Ubuntu virtual machine image"
|
||||
echo "Available parameters:"
|
||||
echo "-u Admin_User_Name"
|
||||
echo "-p Admin_User_Password"
|
||||
echo "-v Core_Package_Version"
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
# If you want to enable this logging add a un-comment the line below and add your account key
|
||||
#curl -X POST -H "content-type:text/plain" --data-binary "$(date) | ${HOSTNAME} | $1" https://logs-01.loggly.com/inputs/${LOGGING_KEY}/tag/redis-extension,${HOSTNAME}
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
log "Begin execution of Nagios Core installation script on ${HOSTNAME}"
|
||||
|
||||
if [ "${UID}" -ne 0 ];
|
||||
then
|
||||
log "Script executed without root permissions"
|
||||
echo "You must be root to run this program." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Parse script parameters
|
||||
while getopts ":u:p:v:h" optname; do
|
||||
log "Option $optname set with value ${OPTARG}"
|
||||
|
||||
case "$optname" in
|
||||
u) # Admin user name
|
||||
ADMIN_USERNAME=${OPTARG}
|
||||
;;
|
||||
p) # Admin user name
|
||||
ADMIN_PASSWORD=${OPTARG}
|
||||
;;
|
||||
v) # Core package version
|
||||
CORE_VERSION=${OPTARG}
|
||||
;;
|
||||
h) # Helpful hints
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
\?) # Unrecognised option - show help
|
||||
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Install essentials
|
||||
log "Installing system essentials..."
|
||||
apt-get -y update
|
||||
|
||||
# Install Apache (a pre-requisite for Nagios)
|
||||
log "Installing Apache..."
|
||||
apt-get -y install apache2
|
||||
|
||||
# Install MySQL (a pre-requisite for Nagios)
|
||||
log "Installing MySQL..."
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -q -y install mysql-server mysql-client
|
||||
mysqladmin -u root password $ADMIN_PASSWORD
|
||||
|
||||
# Install PHP (a pre-requisite for Nagios)
|
||||
log "Installing PHP..."
|
||||
apt-get -y install php5 php5-mysql libapache2-mod-php5
|
||||
|
||||
# Install LAMP prerequisites
|
||||
log "Installing other LAMP prerequisites..."
|
||||
apt-get -y install build-essential libgd2-xpm-dev apache2-utils
|
||||
|
||||
# Restart apache2 service
|
||||
log "Restarting apache2 service..."
|
||||
service apache2 restart
|
||||
|
||||
# Create a new Nagios user account and give it a password
|
||||
log "Creating and configuring the Nagios service user account..."
|
||||
useradd -m $SERVICE_USERNAME
|
||||
echo '$SERVICE_USERNAME:$ADMIN_PASSWORD' | chpasswd -m
|
||||
|
||||
# Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
|
||||
log "Creating and configuring the Nagios security group for external access..."
|
||||
groupadd nagcmd
|
||||
usermod -a -G nagcmd $SERVICE_USERNAME
|
||||
usermod -a -G nagcmd www-data
|
||||
|
||||
# Download Nagios and plugins
|
||||
log "Downloading Nagios package and plugins..."
|
||||
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-$CORE_VERSION.tar.gz
|
||||
wget http://nagios-plugins.org/download/nagios-plugins-$PLUGINS_VERSION.tar.gz
|
||||
|
||||
# Install Nagios and plugins
|
||||
log "Configuring Nagios packages..."
|
||||
tar xzf nagios-$CORE_VERSION.tar.gz
|
||||
cd nagios-$CORE_VERSION
|
||||
./configure --with-command-group=nagcmd
|
||||
|
||||
# Compile and install nagios modules
|
||||
log "Compiling Nagios packages..."
|
||||
make all
|
||||
make install
|
||||
make install-init
|
||||
make install-config
|
||||
make install-commandmode
|
||||
|
||||
# Install Nagios Web interface
|
||||
log "Installing the Nagios Web interface..."
|
||||
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
|
||||
|
||||
# Create a nagios admin account for logging into the Nagios web interface.
|
||||
log "Creating the admin account for logging into the Nagios web interface..."
|
||||
htpasswd -cb /usr/local/nagios/etc/htpasswd.users $ADMIN_USERNAME $ADMIN_PASSWORD
|
||||
|
||||
# Install Nagios plugins
|
||||
log "Configuring Nagios plugins..."
|
||||
tar xzf nagios-plugins-$PLUGINS_VERSION.tar.gz
|
||||
cd nagios-plugins-$PLUGINS_VERSION
|
||||
./configure --with-nagios-user=nagios --with-nagios-group=nagios
|
||||
|
||||
log "Compiling Nagios plugins..."
|
||||
make
|
||||
make install
|
||||
|
||||
# Enable Apache’s rewrite and cgi modules
|
||||
log "Enabling Apache modules..."
|
||||
a2enmod rewrite
|
||||
a2enmod cgi
|
||||
service apache2 restart
|
||||
|
||||
# Check nagios.conf file for any syntax errors
|
||||
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
||||
|
||||
# Start nagios service and make it to start automatically on every boot
|
||||
log "Starting the Nagios service..."
|
||||
service nagios start
|
||||
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
|
||||
|
||||
log "Nagios Core was installed successfully"
|
|
@ -0,0 +1,49 @@
|
|||
# Install a Redis cluster on Ubuntu Virtual Machines using Custom Script Linux Extension
|
||||
|
||||
<a href="https://azuredeploy.net/" target="_blank">
|
||||
<img src="http://azuredeploy.net/deploybutton.png"/>
|
||||
</a>
|
||||
|
||||
This template deploys a Redis cluster on the Ubuntu virtual machines. This template also provisions a storage account, virtual network, availability sets, public IP addresses and network interfaces required by the installation.
|
||||
The template also creates 1 publicly accessible VM acting as a "jumpbox" and allowing to ssh into the Redis nodes for diagnostics or troubleshooting purposes.
|
||||
|
||||
The example expects the following parameters:
|
||||
|
||||
| Name | Description | Default Value |
|
||||
|:--- |:---|:---|
|
||||
| adminUsername | Administrator user name used when provisioning virtual machines | |
|
||||
| adminPassword | Administrator password used when provisioning virtual machines | |
|
||||
| storageAccountName | Unique namespace for the Storage Account where the Virtual Machine's disks will be placed | |
|
||||
| region | Location where resources will be provisioned | |
|
||||
| virtualNetworkName | The arbitrary name of the virtual network provisioned for the Redis cluster | redisVirtNet |
|
||||
| addressPrefix | The network address space for the virtual network | 10.0.0.0/16 |
|
||||
| subnetName | Subnet name for the virtual network that resources will be provisioned in to | redisSubnet1 |
|
||||
| subnetPrefix | Address space for the virtual network subnet | 10.0.0.0/24 |
|
||||
| nodeAddressPrefix | The IP address prefix that will be used for constructing a static private IP address for each node in the cluster | 10.0.0.1 |
|
||||
| jumpbox | The flag allowing to enable or disable provisioning of the jumpbox VM that can be used to access the Redis nodes | Disabled |
|
||||
| tshirtSize | The t-shirt size of the Redis deployment | Small |
|
||||
| redisVersion | The version of the Redis package to be deployed on the cluster (or use 'stable' to pull in the latest and greatest) | stable |
|
||||
| redisClusterName | The arbitrary name of the Redis cluster | redis-cluster |
|
||||
|
||||
Topology
|
||||
--------
|
||||
|
||||
The deployment topology is comprised of _numberOfInstances_ nodes running in the cluster mode.
|
||||
The AOF persistence is enabled by default, whereas the RDB persistence is tuned to perform less-frequent dumps (once every 60 minutes). For more details on Redis persistence options, please refer to the [official documentation](http://redis.io/topics/persistence).
|
||||
|
||||
The following table outlines the VM characteristics for each supported t-shirt size:
|
||||
|
||||
| T-Shirt Size | VM Size | CPU Cores | Memory | # of Masters | # of Slaves | Total # of Nodes |
|
||||
|:--- |:---|:---|:---|:---|:---|:---|
|
||||
| Small | Standard_A1 | 1 | 1.75 GB | 3 | 0 | 3 |
|
||||
| Medium | Standard_A2 | 2 | 3.5 GB | 3 | 3 | 6 |
|
||||
| Large | Standard_A5 | 2 | 14 GB | 3 | 6 | 9 |
|
||||
|
||||
In addition, some critical memory- and network-specific optimizations are applied to ensure the optimal performance and throughput.
|
||||
|
||||
NOTE: To access the individual Redis nodes, you need to enable and use the publicly accessible jumpbox VM and ssh from it into the Redis instances.
|
||||
|
||||
##Known Issues and Limitations
|
||||
- SSH key is not yet implemented and the template currently takes a password for the admin user
|
||||
- Redis version 3.0.0 or above is a requirement for the cluster (although this template also supports Redis 2.x which will be deployed using a traditional master-slave replication)
|
||||
- A static IP address (starting with the prefix defined in the _nodeAddressPrefix_ parameter) will be assigned to each Redis node in order to work around the current limitation of not being able to dynamically compose a list of IP addresses from within the template (by default, the first node will be assigned the private IP of 10.0.0.10, the second node - 10.0.0.11, and so on)
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"storageAccountName": {
|
||||
"value": "redisdeploy1"
|
||||
},
|
||||
"adminUsername": {
|
||||
"value": ""
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": ""
|
||||
},
|
||||
"region": {
|
||||
"value": "West US"
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"value": "redisClustVnet"
|
||||
},
|
||||
"subnetName": {
|
||||
"value": "Subnet1"
|
||||
},
|
||||
"addressPrefix": {
|
||||
"value": "10.0.0.0/16"
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"value": "10.0.0.0/24"
|
||||
},
|
||||
"nodeAddressPrefix": {
|
||||
"value": "10.0.0.1"
|
||||
},
|
||||
"redisVersion": {
|
||||
"value": "3.0.0"
|
||||
},
|
||||
"redisClusterName": {
|
||||
"value": "redis-arm-cluster"
|
||||
},
|
||||
"jumpbox": {
|
||||
"value": "Enabled"
|
||||
},
|
||||
"tshirtSize": {
|
||||
"value": "Small"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"adminUsername": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Administrator user name used when provisioning virtual machines"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "Administrator password used when provisioning virtual machines"
|
||||
}
|
||||
},
|
||||
"storageAccountName": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"Description": "Unique namespace for the Storage Account where the Virtual Machine's disks will be placed"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Location where resources will be provisioned"
|
||||
}
|
||||
},
|
||||
"virtualNetworkName": {
|
||||
"type": "string",
|
||||
"defaultValue": "redisVirtNet",
|
||||
"metadata": {
|
||||
"Description": "The arbitrary name of the virtual network provisioned for the Redis cluster"
|
||||
}
|
||||
},
|
||||
"addressPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/16",
|
||||
"metadata": {
|
||||
"Description": "The network address space for the virtual network"
|
||||
}
|
||||
},
|
||||
"subnetName": {
|
||||
"type": "string",
|
||||
"defaultValue": "redisSubnet1",
|
||||
"metadata": {
|
||||
"Description": "Subnet name for the virtual network that resources will be provisioned in to"
|
||||
}
|
||||
},
|
||||
"subnetPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.0/24",
|
||||
"metadata": {
|
||||
"Description": "Address space for the virtual network subnet"
|
||||
}
|
||||
},
|
||||
"nodeAddressPrefix": {
|
||||
"type": "string",
|
||||
"defaultValue": "10.0.0.1",
|
||||
"metadata": {
|
||||
"Description": "The IP address prefix that will be used for constructing a static private IP address for each node in the cluster"
|
||||
}
|
||||
},
|
||||
"jumpbox": {
|
||||
"type": "string",
|
||||
"defaultValue": "Disabled",
|
||||
"allowedValues": [
|
||||
"Enabled",
|
||||
"Disabled"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "The flag allowing to enable or disable provisioning of the jumpbox VM that can be used to access the Redis nodes"
|
||||
}
|
||||
},
|
||||
"tshirtSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "Small",
|
||||
"allowedValues": [
|
||||
"Small",
|
||||
"Medium",
|
||||
"Large"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "T-shirt size of the Redis deployment"
|
||||
}
|
||||
},
|
||||
"redisVersion": {
|
||||
"type": "string",
|
||||
"defaultValue": "stable",
|
||||
"metadata": {
|
||||
"Description": "The version of the Redis package to be deployed on the cluster (or use 'stable' to pull in the latest and greatest)"
|
||||
}
|
||||
},
|
||||
"redisClusterName": {
|
||||
"type": "string",
|
||||
"defaultValue": "redis-cluster",
|
||||
"metadata": {
|
||||
"Description": "The arbitrary name of the Redis cluster"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"_comment0": "/* T-shirt sizes may vary for different reasons, and some customers may want to modify these - so feel free to go ahead and define your favorite t-shirts */",
|
||||
"tshirtSizeSmall": {
|
||||
"vmSizeMember": "Standard_A1",
|
||||
"numberOfMasters": 3,
|
||||
"numberOfSlaves": 0,
|
||||
"totalMemberCount": 3,
|
||||
"totalMemberCountExcludingLast": 2,
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'node-resources.json')]"
|
||||
},
|
||||
"tshirtSizeMedium": {
|
||||
"vmSizeMember": "Standard_A2",
|
||||
"numberOfMasters": 3,
|
||||
"numberOfSlaves": 3,
|
||||
"totalMemberCount": 6,
|
||||
"totalMemberCountExcludingLast": 5,
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'node-resources.json')]"
|
||||
},
|
||||
"tshirtSizeLarge": {
|
||||
"vmSizeMember": "Standard_A5",
|
||||
"numberOfMasters": 3,
|
||||
"numberOfSlaves": 6,
|
||||
"totalMemberCount": 9,
|
||||
"totalMemberCountExcludingLast": 8,
|
||||
"arbiter": "Enabled",
|
||||
"vmTemplate": "[concat(variables('templateBaseUrl'), 'node-resources.json')]"
|
||||
},
|
||||
"vmStorageAccountContainerName": "vhd-redis",
|
||||
"vmStorageAccountDomain": ".blob.core.windows.net",
|
||||
"vmSourceImageName": "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_2_LTS-amd64-server-20150309-en-us-30GB",
|
||||
"sourceImageName": "[concat('/',subscription().subscriptionId,'/services/images/',variables('vmSourceImageName'))]",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
|
||||
"scriptUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/redis-high-availability/",
|
||||
"templateBaseUrl": "[variables('scriptUrl')]",
|
||||
"jumpboxTemplateEnabled": "jumpbox-resources.json",
|
||||
"jumpboxTemplateDisabled": "empty-resources.json",
|
||||
"sharedTemplateUrl": "[concat(variables('templateBaseUrl'), 'shared-resources.json')]",
|
||||
"jumpboxTemplateUrl": "[concat(variables('templateBaseUrl'), variables(concat('jumpboxTemplate', parameters('jumpbox'))))]",
|
||||
"commonSettings": {
|
||||
"availabilitySetName": "redisAvailSet",
|
||||
"region": "[parameters('region')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"vhdStorageAccountName": "[parameters('storageAccountName')]",
|
||||
"vhdContainerName": "[variables('vmStorageAccountContainerName')]",
|
||||
"destinationVhdsContainer": "[concat('https://', parameters('storageAccountName'), variables('vmStorageAccountDomain'), '/', variables('vmStorageAccountContainerName'), '/')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"virtualNetworkName": "[parameters('virtualNetworkName')]",
|
||||
"addressPrefix": "[parameters('addressPrefix')]",
|
||||
"subnetName": "[parameters('subnetName')]",
|
||||
"subnetPrefix": "[parameters('subnetPrefix')]",
|
||||
"subnetRef": "[concat(variables('vnetID'), '/subnets/', parameters('subnetName'))]",
|
||||
"machineIpPrefix": "[parameters('nodeAddressPrefix')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"machineNamePrefix": "redisnode-",
|
||||
"osImageName": "[variables('sourceImageName')]"
|
||||
},
|
||||
"clusterSpec": "[variables(concat('tshirtSize', parameters('tshirtSize')))]",
|
||||
"installCommand": "[concat('redis-cluster-install.sh -n ', parameters('redisClusterName'), ' -v ', parameters('redisVersion'), ' -c ', variables('clusterSpec').totalMemberCount, ' -m ', variables('clusterSpec').numberOfMasters, ' -s ', variables('clusterSpec').numberOfSlaves, ' -p ', variables('networkSettings').machineIpPrefix)]",
|
||||
"vmScripts": {
|
||||
"scriptsToDownload": [
|
||||
"[concat(variables('scriptUrl'), 'redis-cluster-install.sh')]",
|
||||
"[concat(variables('scriptUrl'), 'redis-cluster-setup.sh')]",
|
||||
"[concat(variables('scriptUrl'), 'redis-sentinel-startup.sh')]"
|
||||
],
|
||||
"installCommand": "[concat('bash ', variables('installCommand'))]",
|
||||
"setupCommand": "[concat('bash ', variables('installCommand'), ' -l')]"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"name": "shared-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('sharedTemplateUrl')]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": "[variables('storageSettings')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "jumpbox-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('jumpboxTemplateUrl')]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": "[variables('storageSettings')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": "[variables('machineSettings')]"
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": "[parameters('adminPassword')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"name": "[concat('node-resources', copyindex())]",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
|
||||
],
|
||||
"copy": {
|
||||
"name": "memberNodesLoop",
|
||||
"count": "[variables('clusterSpec').totalMemberCountExcludingLast]"
|
||||
},
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('clusterSpec').vmTemplate]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": "[variables('storageSettings')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": {
|
||||
"adminUsername": "[variables('machineSettings').adminUsername]",
|
||||
"machineNamePrefix": "[variables('machineSettings').machineNamePrefix]",
|
||||
"osImageName": "[variables('machineSettings').osImageName]",
|
||||
"vmSize": "[variables('clusterSpec').vmSizeMember]",
|
||||
"machineIndex": "[copyindex()]",
|
||||
"vmScripts": "[variables('vmScripts').scriptsToDownload]",
|
||||
"commandToExecute": "[concat(variables('vmScripts').installCommand, ' -i ', copyindex())]"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": "[parameters('adminPassword')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lastnode-resources",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2015-01-01",
|
||||
"dependsOn": [
|
||||
"memberNodesLoop"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"templateLink": {
|
||||
"uri": "[variables('clusterSpec').vmTemplate]",
|
||||
"contentVersion": "1.0.0.0"
|
||||
},
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"value": "[variables('commonSettings')]"
|
||||
},
|
||||
"storageSettings": {
|
||||
"value": "[variables('storageSettings')]"
|
||||
},
|
||||
"networkSettings": {
|
||||
"value": "[variables('networkSettings')]"
|
||||
},
|
||||
"machineSettings": {
|
||||
"value": {
|
||||
"adminUsername": "[variables('machineSettings').adminUsername]",
|
||||
"machineNamePrefix": "[variables('machineSettings').machineNamePrefix]",
|
||||
"osImageName": "[variables('machineSettings').osImageName]",
|
||||
"vmSize": "[variables('clusterSpec').vmSizeMember]",
|
||||
"machineIndex": "[variables('clusterSpec').totalMemberCountExcludingLast]",
|
||||
"vmScripts": "[variables('vmScripts').scriptsToDownload]",
|
||||
"commandToExecute": "[concat(variables('vmScripts').setupCommand, ' -i ', variables('clusterSpec').totalMemberCountExcludingLast)]"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": "[parameters('adminPassword')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"installCommand": {
|
||||
"value": "[variables('vmScripts').installCommand]",
|
||||
"type": "string"
|
||||
},
|
||||
"setupCommand": {
|
||||
"value": "[variables('vmScripts').setupCommand]",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
],
|
||||
"outputs": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "Administrator password used when provisioning virtual machines"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"vmSize": "Standard_A0"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "jumpboxPublicIP",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "jumpboxNIC",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', 'jumpboxPublicIP')]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipConfigJumpbox",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses','jumpboxPublicIP')]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "jumpboxVM",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'jumpboxNIC')]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('vmSize')]",
|
||||
"platformGuestAgent": "true"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'jumpbox')]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('adminPassword')]",
|
||||
"linuxOperatingSystemProfile": {
|
||||
"disableSshPasswordAuthentication": "false"
|
||||
}
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces','jumpboxNIC')]"
|
||||
}
|
||||
],
|
||||
"inputEndpoints": [
|
||||
{
|
||||
"enableDirectServerReturn": "False",
|
||||
"endpointName": "SSH",
|
||||
"privatePort": 22,
|
||||
"publicPort": 22,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"itemDisplayName": "Provisions a Redis cluster on Ubuntu virtual machines",
|
||||
"description": "This template creates a Redis cluster on Ubuntu virtual machine images, configures persistence and applies well known optimizations and proven practices",
|
||||
"summary": "This template creates a Redis cluster on Ubuntu virtual machines",
|
||||
"githubUsername": "TheAzureGuy",
|
||||
"dateUpdated": "2015-04-06"
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
},
|
||||
"machineSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Machine settings object"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "Administrator password used when provisioning virtual machines"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nicMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Static",
|
||||
"privateIPAddress": "[concat(parameters('networkSettings').machineIpPrefix, parameters('machineSettings').machineIndex)]",
|
||||
"subnet": {
|
||||
"id": "[parameters('networkSettings').subnetRef]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', 'nicMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('commonSettings').availabilitySetName)]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('machineSettings').vmSize]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('machineSettings').machineNamePrefix, 'member', parameters('machineSettings').machineIndex)]",
|
||||
"adminUsername": "[parameters('machineSettings').adminUsername]",
|
||||
"adminPassword": "[parameters('adminPassword')]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"sourceImage": {
|
||||
"id": "[parameters('machineSettings').osImageName]"
|
||||
},
|
||||
"destinationVhdsContainer": "[parameters('storageSettings').destinationVhdsContainer]"
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nicMember', parameters('machineSettings').machineIndex))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat('vmMember', parameters('machineSettings').machineIndex, '/installscript')]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', 'vmMember', parameters('machineSettings').machineIndex)]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": "[parameters('machineSettings').vmScripts]",
|
||||
"commandToExecute": "[parameters('machineSettings').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,383 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script parameters and their defaults
|
||||
VERSION="3.0.0"
|
||||
CLUSTER_NAME="redis-cluster"
|
||||
IS_LAST_NODE=0
|
||||
IS_CLUSTER_AWARE=0
|
||||
INSTANCE_COUNT=1
|
||||
MASTER_NODE_COUNT=0
|
||||
SLAVE_NODE_COUNT=0
|
||||
NODE_INDEX=0
|
||||
IP_PREFIX="10.0.0.0"
|
||||
LOGGING_KEY="[account-key]"
|
||||
REDIS_PORT=6379
|
||||
CURRENT_DIRECTORY=$(pwd)
|
||||
|
||||
########################################################
|
||||
# This script will install Redis from sources
|
||||
########################################################
|
||||
help()
|
||||
{
|
||||
echo "This script installs Redis Cache on the Ubuntu virtual machine image"
|
||||
echo "Available parameters:"
|
||||
echo "-n Cluster name"
|
||||
echo "-v Redis package version"
|
||||
echo "-c Number of instances"
|
||||
echo "-s Number of master nodes"
|
||||
echo "-s Number of slave nodes"
|
||||
echo "-i Sequential node index (starting from 0)"
|
||||
echo "-p Private IP address prefix"
|
||||
echo "-l (Indicator of the last node)"
|
||||
echo "-h Help"
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
log()
|
||||
{
|
||||
# If you want to enable this logging, uncomment the line below and specify your logging key
|
||||
#curl -X POST -H "content-type:text/plain" --data-binary "$(date) | ${HOSTNAME} | $1" https://logs-01.loggly.com/inputs/${LOGGING_KEY}/tag/redis-extension,${HOSTNAME}
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
log "Begin execution of Redis installation script extension on ${HOSTNAME}"
|
||||
|
||||
if [ "${UID}" -ne 0 ];
|
||||
then
|
||||
log "Script executed without root permissions"
|
||||
echo "You must be root to run this program." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Parse script parameters
|
||||
while getopts :n:v:c:m:s:i:p:lh optname; do
|
||||
log "Option $optname set with value ${OPTARG}"
|
||||
|
||||
case $optname in
|
||||
n) # Cluster name
|
||||
CLUSTER_NAME=${OPTARG}
|
||||
;;
|
||||
v) # Version to be installed
|
||||
VERSION=${OPTARG}
|
||||
if [[ $VERSION == 3.* ]]; then IS_CLUSTER_AWARE=1; fi
|
||||
;;
|
||||
c) # Number of instances
|
||||
INSTANCE_COUNT=${OPTARG}
|
||||
;;
|
||||
m) # Number of master nodes
|
||||
MASTER_NODE_COUNT=${OPTARG}
|
||||
;;
|
||||
s) # Number of slave nodes
|
||||
SLAVE_NODE_COUNT=${OPTARG}
|
||||
;;
|
||||
i) # Sequential node index
|
||||
NODE_INDEX=${OPTARG}
|
||||
;;
|
||||
p) # Private IP address prefix
|
||||
IP_PREFIX=${OPTARG}
|
||||
;;
|
||||
l) # Indicator of the last node
|
||||
IS_LAST_NODE=1
|
||||
;;
|
||||
h) # Helpful hints
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
\?) #unrecognized option - show help
|
||||
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#############################################################################
|
||||
tune_system()
|
||||
{
|
||||
log "Tuning the system configuration"
|
||||
|
||||
# Ensure the source list is up-to-date
|
||||
apt-get -y update
|
||||
|
||||
# Add local machine name to the hosts file to facilitate IP address resolution
|
||||
if grep -q "${HOSTNAME}" /etc/hosts
|
||||
then
|
||||
echo "${HOSTNAME} was found in /etc/hosts"
|
||||
else
|
||||
echo "${HOSTNAME} was not found in and will be added to /etc/hosts"
|
||||
# Append it to the hsots file if not there
|
||||
echo "127.0.0.1 $(hostname)" >> /etc/hosts
|
||||
log "Hostname ${HOSTNAME} added to /etc/hosts"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
tune_memory()
|
||||
{
|
||||
log "Tuning the memory configuration"
|
||||
|
||||
# Get the supporting utilities
|
||||
apt-get -y install hugepages
|
||||
|
||||
# Resolve a "Background save may fail under low memory condition." warning
|
||||
sysctl vm.overcommit_memory=1
|
||||
|
||||
# Disable the Transparent Huge Pages (THP) support in the kernel
|
||||
sudo hugeadm --thp-never
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
tune_network()
|
||||
{
|
||||
log "Tuning the network configuration"
|
||||
|
||||
>/etc/sysctl.conf cat << EOF
|
||||
|
||||
# Disable syncookies (syncookies are not RFC compliant and can use too muche resources)
|
||||
net.ipv4.tcp_syncookies = 0
|
||||
|
||||
# Basic TCP tuning
|
||||
net.ipv4.tcp_keepalive_time = 600
|
||||
net.ipv4.tcp_synack_retries = 3
|
||||
net.ipv4.tcp_syn_retries = 3
|
||||
|
||||
# RFC1337
|
||||
net.ipv4.tcp_rfc1337 = 1
|
||||
|
||||
# Defines the local port range that is used by TCP and UDP to choose the local port
|
||||
net.ipv4.ip_local_port_range = 1024 65535
|
||||
|
||||
# Log packets with impossible addresses to kernel log
|
||||
net.ipv4.conf.all.log_martians = 1
|
||||
|
||||
# Disable Explicit Congestion Notification in TCP
|
||||
net.ipv4.tcp_ecn = 0
|
||||
|
||||
# Enable window scaling as defined in RFC1323
|
||||
net.ipv4.tcp_window_scaling = 1
|
||||
|
||||
# Enable timestamps (RFC1323)
|
||||
net.ipv4.tcp_timestamps = 1
|
||||
|
||||
# Enable select acknowledgments
|
||||
net.ipv4.tcp_sack = 1
|
||||
|
||||
# Enable FACK congestion avoidance and fast restransmission
|
||||
net.ipv4.tcp_fack = 1
|
||||
|
||||
# Allows TCP to send "duplicate" SACKs
|
||||
net.ipv4.tcp_dsack = 1
|
||||
|
||||
# Controls IP packet forwarding
|
||||
net.ipv4.ip_forward = 0
|
||||
|
||||
# No controls source route verification (RFC1812)
|
||||
net.ipv4.conf.default.rp_filter = 0
|
||||
|
||||
# Enable fast recycling TIME-WAIT sockets
|
||||
net.ipv4.tcp_tw_recycle = 1
|
||||
net.ipv4.tcp_max_syn_backlog = 20000
|
||||
|
||||
# How may times to retry before killing TCP connection, closed by our side
|
||||
net.ipv4.tcp_orphan_retries = 1
|
||||
|
||||
# How long to keep sockets in the state FIN-WAIT-2 if we were the one closing the socket
|
||||
net.ipv4.tcp_fin_timeout = 20
|
||||
|
||||
# Don't cache ssthresh from previous connection
|
||||
net.ipv4.tcp_no_metrics_save = 1
|
||||
net.ipv4.tcp_moderate_rcvbuf = 1
|
||||
|
||||
# Increase Linux autotuning TCP buffer limits
|
||||
net.ipv4.tcp_rmem = 4096 87380 16777216
|
||||
net.ipv4.tcp_wmem = 4096 65536 16777216
|
||||
|
||||
# increase TCP max buffer size
|
||||
net.core.rmem_max = 16777216
|
||||
net.core.wmem_max = 16777216
|
||||
net.core.netdev_max_backlog = 2500
|
||||
|
||||
# Increase number of incoming connections
|
||||
net.core.somaxconn = 65000
|
||||
EOF
|
||||
|
||||
# Reload the networking settings
|
||||
/sbin/sysctl -p /etc/sysctl.conf
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
install_redis()
|
||||
{
|
||||
log "Installing Redis v${VERSION}"
|
||||
|
||||
# Installing build essentials (if missing) and other required tools
|
||||
apt-get -y install build-essential
|
||||
|
||||
wget http://download.redis.io/releases/redis-$VERSION.tar.gz
|
||||
tar xzf redis-$VERSION.tar.gz
|
||||
cd redis-$VERSION
|
||||
make
|
||||
make install prefix=/usr/local/bin/
|
||||
|
||||
log "Redis package v${VERSION} was downloaded and built successfully"
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_redis()
|
||||
{
|
||||
# Configure the general settings
|
||||
sed -i "s/^port.*$/port ${REDIS_PORT}/g" redis.conf
|
||||
sed -i "s/^daemonize no$/daemonize yes/g" redis.conf
|
||||
sed -i 's/^logfile ""/logfile \/var\/log\/redis.log/g' redis.conf
|
||||
sed -i "s/^loglevel verbose$/loglevel notice/g" redis.conf
|
||||
sed -i "s/^dir \.\//dir \/var\/redis\//g" redis.conf
|
||||
sed -i "s/\${REDISPORT}.conf/redis.conf/g" utils/redis_init_script
|
||||
sed -i "s/_\${REDISPORT}.pid/.pid/g" utils/redis_init_script
|
||||
|
||||
# Configure the sentinel bits
|
||||
echo "daemonize yes" >> sentinel.conf
|
||||
echo "logfile /var/log/redis-sentinel.log" >> sentinel.conf
|
||||
echo "loglevel notice" >> sentinel.conf
|
||||
echo "pidfile /var/run/redis-sentinel.pid" >> sentinel.conf
|
||||
|
||||
# Create all essentials directories and copy files to the correct locations
|
||||
mkdir /etc/redis
|
||||
mkdir /var/redis
|
||||
|
||||
cp redis.conf /etc/redis/redis.conf
|
||||
cp sentinel.conf /etc/redis/sentinel.conf
|
||||
cp utils/redis_init_script /etc/init.d/redis-server
|
||||
cp ${CURRENT_DIRECTORY}/redis-sentinel-startup.sh /etc/init.d/redis-sentinel
|
||||
|
||||
# Copy the cluster configuration utility (if exists)
|
||||
if [ -f src/redis-trib.rb ]; then
|
||||
cp src/redis-trib.rb /usr/local/bin/
|
||||
fi
|
||||
|
||||
# Clean up temporary files
|
||||
cd ..
|
||||
rm redis-$VERSION -R
|
||||
rm redis-$VERSION.tar.gz
|
||||
|
||||
log "Redis configuration was applied successfully"
|
||||
|
||||
# Create service user and configure for permissions
|
||||
useradd -r -s /bin/false redis
|
||||
chown redis:redis /var/run/redis.pid
|
||||
chmod 755 /etc/init.d/redis-server
|
||||
chmod 755 /etc/init.d/redis-sentinel
|
||||
|
||||
# Start the script automatically at boot time
|
||||
update-rc.d redis-server defaults
|
||||
|
||||
log "Redis service was created successfully"
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_redis_cluster()
|
||||
{
|
||||
# Enable the AOF persistence
|
||||
sed -i "s/^appendonly no$/appendonly yes/g" /etc/redis/redis.conf
|
||||
|
||||
# Tune the RDB persistence
|
||||
sed -i "s/^save.*$/# save/g" /etc/redis/redis.conf
|
||||
echo "save 3600 1" >> /etc/redis/redis.conf
|
||||
|
||||
# Add cluster configuration (expected to be commented out in the default configuration file)
|
||||
echo "cluster-enabled yes" >> /etc/redis/redis.conf
|
||||
echo "cluster-node-timeout 5000" >> /etc/redis/redis.conf
|
||||
echo "cluster-config-file ${CLUSTER_NAME}.conf" >> /etc/redis/redis.conf
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
initialize_redis_cluster()
|
||||
{
|
||||
# Cluster setup must run on the last node (a nasty workaround until ARM can recognize multiple custom script extensions)
|
||||
if [ "$IS_LAST_NODE" -eq 1 ]; then
|
||||
let REPLICA_COUNT=$SLAVE_NODE_COUNT/$MASTER_NODE_COUNT
|
||||
sudo bash redis-cluster-setup.sh -c $INSTANCE_COUNT -s $REPLICA_COUNT -p $IP_PREFIX
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_redis_replication()
|
||||
{
|
||||
log "Configuring master-slave replication"
|
||||
|
||||
if [ "$NODE_INDEX" -lt "$MASTER_NODE_COUNT" ]; then
|
||||
log "Redis node ${HOSTNAME} is considered a MASTER, no further configuration changes are required"
|
||||
else
|
||||
log "Redis node ${HOSTNAME} is considered a SLAVE, additional configuration changes will be made"
|
||||
|
||||
let MASTER_NODE_INDEX=$NODE_INDEX%$MASTER_NODE_COUNT
|
||||
MASTER_NODE_IP="${IP_PREFIX}${MASTER_NODE_INDEX}"
|
||||
|
||||
echo "slaveof ${MASTER_NODE_IP} ${REDIS_PORT}" >> /etc/redis/redis.conf
|
||||
log "Redis node ${HOSTNAME} is configured as a SLAVE of ${MASTER_NODE_IP}:${REDIS_PORT}"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
configure_sentinel()
|
||||
{
|
||||
let MASTER_NODE_INDEX=$NODE_INDEX%$MASTER_NODE_COUNT
|
||||
MASTER_NODE_IP="${IP_PREFIX}${MASTER_NODE_INDEX}"
|
||||
|
||||
# Patch the sentinel configuration file with a new master
|
||||
sed -i "s/^sentinel monitor.*$/sentinel monitor mymaster ${MASTER_NODE_IP} ${REDIS_PORT} ${MASTER_NODE_COUNT}/g" /etc/redis/sentinel.conf
|
||||
|
||||
# Make a writable log file
|
||||
touch /var/log/redis-sentinel.log
|
||||
chown redis:redis /var/log/redis-sentinel.log
|
||||
chmod u+w /var/log/redis-sentinel.log
|
||||
|
||||
# Change owner for /etc/redis/ to allow sentinel change the configuration files
|
||||
chown -R redis.redis /etc/redis/
|
||||
|
||||
# Start the script automatically at boot time
|
||||
update-rc.d redis-sentinel defaults
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
start_redis()
|
||||
{
|
||||
# Start the Redis daemon
|
||||
/etc/init.d/redis-server start
|
||||
log "Redis daemon was started successfully"
|
||||
}
|
||||
|
||||
start_sentinel()
|
||||
{
|
||||
# Start the Redis sentinel daemon
|
||||
/etc/init.d/redis-sentinel start
|
||||
log "Redis sentinel daemon was started successfully"
|
||||
}
|
||||
|
||||
# Step1
|
||||
tune_system
|
||||
tune_memory
|
||||
tune_network
|
||||
|
||||
# Step 2
|
||||
install_redis
|
||||
|
||||
# Step 3
|
||||
configure_redis
|
||||
|
||||
# Step 4
|
||||
if [ "$IS_CLUSTER_AWARE" -eq 1 ]; then
|
||||
configure_redis_cluster
|
||||
else
|
||||
configure_redis_replication
|
||||
configure_sentinel
|
||||
fi
|
||||
|
||||
# Step 5
|
||||
start_redis
|
||||
|
||||
# Step 6
|
||||
if [ "$IS_CLUSTER_AWARE" -eq 1 ]; then
|
||||
initialize_redis_cluster
|
||||
else
|
||||
start_sentinel
|
||||
fi
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script parameters and their defaults
|
||||
INSTANCE_COUNT=1
|
||||
SLAVE_COUNT=0
|
||||
IP_PREFIX="10.0.0."
|
||||
REDIS_PORT=6379
|
||||
LOGGING_KEY="[account-key]"
|
||||
|
||||
########################################################
|
||||
# This script will configures a Redis cluster
|
||||
########################################################
|
||||
help()
|
||||
{
|
||||
echo "This script configures a Redis cluster on the Ubuntu virtual machine image"
|
||||
echo "Available parameters:"
|
||||
echo "-c Instance Count"
|
||||
echo "-s Slave Count"
|
||||
echo "-p Redis Node IP Prefix"
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
# If you want to enable this logging add a un-comment the line below and add your account key
|
||||
#curl -X POST -H "content-type:text/plain" --data-binary "$(date) | ${HOSTNAME} | $1" https://logs-01.loggly.com/inputs/${LOGGING_KEY}/tag/redis-extension,${HOSTNAME}
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
# Expand a list of successive IP range defined by a starting address prefix (e.g. 10.0.0.1) and the number of machines in the range
|
||||
# 10.0.0.1-3 would be converted to "10.0.0.10 10.0.0.11 10.0.0.12"
|
||||
expand_ip_range() {
|
||||
IFS='-' read -a HOST_IPS <<< "$1"
|
||||
|
||||
declare -a EXPAND_STATICIP_RANGE_RESULTS=()
|
||||
|
||||
for (( n=0 ; n<("${HOST_IPS[1]}"+0) ; n++))
|
||||
do
|
||||
HOST="${HOST_IPS[0]}${n}:${REDIS_PORT}"
|
||||
EXPAND_STATICIP_RANGE_RESULTS+=($HOST)
|
||||
done
|
||||
|
||||
echo "${EXPAND_STATICIP_RANGE_RESULTS[@]}"
|
||||
}
|
||||
|
||||
log "Begin execution of Redis cluster configuration script extension on ${HOSTNAME}"
|
||||
|
||||
if [ "${UID}" -ne 0 ];
|
||||
then
|
||||
log "Script executed without root permissions"
|
||||
echo "You must be root to run this program." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Parse script parameters
|
||||
while getopts :c:s:p:h optname; do
|
||||
log "Option $optname set with value ${OPTARG}"
|
||||
|
||||
case $optname in
|
||||
c) # Number of instances
|
||||
INSTANCE_COUNT=${OPTARG}
|
||||
;;
|
||||
s) # Number of slave nodes
|
||||
SLAVE_COUNT=${OPTARG}
|
||||
;;
|
||||
p) # Private IP address prefix
|
||||
IP_PREFIX=${OPTARG}
|
||||
;;
|
||||
h) # Helpful hints
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
\?) #unrecognized option - show help
|
||||
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
log "Configuring Redis cluster on ${INSTANCE_COUNT} nodes with ${SLAVE_COUNT} slave(s) for every master node"
|
||||
|
||||
# Install the Ruby runtime that the cluster configuration script uses
|
||||
apt-get -y install ruby-full
|
||||
|
||||
# Install the Redis client gem (a pre-requisite for redis-trib.rb)
|
||||
gem install redis
|
||||
|
||||
# Create a cluster based upon the specified host list and replica count
|
||||
echo "yes" | /usr/local/bin/redis-trib.rb create --replicas ${SLAVE_COUNT} $(expand_ip_range "${IP_PREFIX}-${INSTANCE_COUNT}")
|
||||
|
||||
log "Redis cluster was configured successfully"
|
|
@ -0,0 +1,66 @@
|
|||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: redis-sentinel
|
||||
# Required-Start: $syslog $remote_fs
|
||||
# Required-Stop: $syslog $remote_fs
|
||||
# Should-Start: $local_fs
|
||||
# Should-Stop: $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: redis-sentinel - Failover for Redis
|
||||
# Description: redis-sentinel - Failover for Redis
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DAEMON=/usr/local/bin/redis-sentinel
|
||||
DAEMON_ARGS=/etc/redis/sentinel.conf
|
||||
NAME=redis-sentinel
|
||||
DESC=redis-sentinel
|
||||
PIDFILE=/var/run/redis-sentinel.pid
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting $DESC: "
|
||||
touch $PIDFILE
|
||||
chown redis:redis $PIDFILE
|
||||
if start-stop-daemon --start --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
|
||||
then
|
||||
echo "$NAME."
|
||||
else
|
||||
echo "failed"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $DESC: "
|
||||
if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
|
||||
then
|
||||
echo "$NAME."
|
||||
else
|
||||
echo "failed"
|
||||
fi
|
||||
rm -f $PIDFILE
|
||||
;;
|
||||
|
||||
restart|force-reload)
|
||||
${0} stop
|
||||
${0} start
|
||||
;;
|
||||
|
||||
status)
|
||||
echo -n "$DESC is "
|
||||
if start-stop-daemon --stop --quiet --signal 0 --name ${NAME} --pidfile ${PIDFILE}
|
||||
then
|
||||
echo "running"
|
||||
else
|
||||
echo "not running"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/$NAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"commonSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Common settings object"
|
||||
}
|
||||
},
|
||||
"storageSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Storage settings object"
|
||||
}
|
||||
},
|
||||
"networkSettings": {
|
||||
"type": "object",
|
||||
"metadata": {
|
||||
"Description": "Network settings object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[concat(parameters('storageSettings').vhdStorageAccountName)]",
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"accountType": "Standard_LRS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Compute/availabilitySets",
|
||||
"name": "[parameters('commonSettings').availabilitySetName]",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2014-12-01-preview",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[parameters('networkSettings').virtualNetworkName]",
|
||||
"location": "[parameters('commonSettings').region]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[parameters('networkSettings').addressPrefix]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[parameters('networkSettings').subnetName]",
|
||||
"properties": {
|
||||
"addressPrefix": "[parameters('networkSettings').subnetPrefix]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче