Skip to content

Commit

Permalink
Release modified MongoDB templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfox1111 committed Oct 31, 2013
1 parent 5e195dd commit 1d4ce30
Show file tree
Hide file tree
Showing 9 changed files with 2,615 additions and 0 deletions.
388 changes: 388 additions & 0 deletions cfn/F19/MongoDB_BaseCluster.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,388 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "MonboDB Base Cluster",
"Mappings": {
"AWSInstanceType2Arch": {
"m1.large": {
"Arch": "64"
},
"m1.medium": {
"Arch": "64"
},
"m1.small": {
"Arch": "64"
},
"m1.tiny": {
"Arch": "64"
},
"m1.xlarge": {
"Arch": "64"
}
},
"DistroArch2AMI": {
"F17": {
"32": "F17-i386-cfntools",
"64": "F17-x86_64-cfntools"
},
"F18": {
"32": "F18-i386-cfntools",
"64": "F18-x86_64-cfntools"
},
"RHEL-6.1": {
"32": "rhel61-i386-cfntools",
"64": "rhel61-x86_64-cfntools"
},
"RHEL-6.2": {
"32": "rhel62-i386-cfntools",
"64": "rhel62-x86_64-cfntools"
},
"RHEL-6.3": {
"32": "rhel63-i386-cfntools",
"64": "rhel63-x86_64-cfntools"
},
"SL6": {
"32": "NOT IMPLEMENTED",
"64": "SL-6.4-x86_64-cfntools"
},
"U10": {
"32": "U10-i386-cfntools",
"64": "U10-x86_64-cfntools"
}
}
},
"Outputs": {
"PrimaryConfigServerSecurityGroup": {
"Description": "Primary Config Server Security Group ID",
"Value": {
"Ref": "PrimaryConfigServerSecurityGroup"
}
},
"BackendConfigServerSecurityGroup": {
"Description": "Backend Config Server Security Group ID",
"Value": {
"Ref": "BackendConfigServerSecurityGroup"
}
},
"BackendNetworkId": {
"Description": "Backend Network ID",
"Value": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.NetworkId"
]
}
},
"BackendSubnetId": {
"Description": "Backend Subnet ID",
"Value": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.SubnetId"
]
}
},
"ConfigSvr1": {
"Description": "public DNS name of the MongoDB config server 1",
"Value": {
"Fn::GetAtt": [
"ConfigCluster",
"Outputs.ConfigSvr1"
]
}
},
"ConfigSvr2": {
"Description": "public DNS name of the MongoDB config server 2",
"Value": {
"Fn::GetAtt": [
"ConfigCluster",
"Outputs.ConfigSvr2"
]
}
},
"ConfigSvr3": {
"Description": "public DNS name of the MongoDB config server 3",
"Value": {
"Fn::GetAtt": [
"ConfigCluster",
"Outputs.ConfigSvr3"
]
}
}
},
"Parameters": {
"MongoDBYumRepo": {
"Description": "Mongo DB Yum Repo",
"Default": "http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/",
"Type": "String"
},
"BackendIpPrefix": {
"Default": "10.0.101",
"Description": "Ip Prefix to use",
"Type": "String"
},
"TemplateBaseUrl": {
"Description": "URL for templates",
"Type": "String"
},
"InstanceType": {
"AllowedValues": [
"m1.tiny",
"m1.small",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"c1.xlarge",
"cc1.4xlarge"
],
"Default": "m1.large",
"Description": "EC2 instance type (e.g. m1.large, m1.xlarge, m2.xlarge)",
"Type": "String"
},
"InstanceTypeConfigSvr": {
"AllowedValues": [
"m1.tiny",
"m1.small",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"c1.xlarge",
"cc1.4xlarge"
],
"Default": "m1.tiny",
"Description": "EC2 instance type (e.g. m1.large, m1.xlarge, m2.xlarge)",
"Type": "String"
},
"InstanceZone": {
"Default": "nova",
"Description": "AvailabilityZone for this instance",
"Type": "String"
},
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access",
"Type": "String"
},
"LinuxDistribution": {
"AllowedValues": [
"SL6",
"F18",
"F17",
"U10",
"RHEL-6.1",
"RHEL-6.2",
"RHEL-6.3"
],
"Default": "SL6",
"Description": "Distribution of choice",
"Type": "String"
},
"PrimaryNetworkId": {
"Description": "PrimaryNetworkId",
"Type": "String"
},
"ConfigStorageVolumeSize": {
"Default": "2",
"Description": "Volume size for each EBS volume",
"Type": "Number"
}
},
"Resources": {
"PrimaryConfigServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Primary Config Server Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": { "Ref": "PrimaryNetworkId" }
}
},
"BackendConfigServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Backend Config Server Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
{"IpProtocol" : "tcp", "FromPort" : "27019", "ToPort" : "27019", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.NetworkId"
]
}
}
},
"PrimaryReplicaSetSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Primary Replica Set Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": { "Ref": "PrimaryNetworkId" }
}
},
"BackendReplicaSetSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Backend Replica Set Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
{"IpProtocol" : "tcp", "FromPort" : "27017", "ToPort" : "27017", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.NetworkId"
]
}
}
},
"PrimaryRouterSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Primary Replica Set Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": { "Ref": "PrimaryNetworkId" }
}
},
"BackendRouterSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Backend Replica Set Security Group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
{"IpProtocol" : "tcp", "FromPort" : "27017", "ToPort" : "27017", "CidrIp" : "0.0.0.0/0" }
],
"VpcId": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.NetworkId"
]
}
}
},
"BackendNetwork": {
"Properties": {
"Parameters": {
"IpPrefix": {
"Ref": "BackendIpPrefix"
}
},
"TemplateURL": {
"Fn::Join": [
"",
[
{ "Ref": "TemplateBaseUrl" },
"/MongoDB_Network.template"
]
]
}
},
"Type": "AWS::CloudFormation::Stack"
},
"ConfigCluster": {
"Properties": {
"Parameters": {
"MongoDBYumRepo": {
"Ref": "MongoDBYumRepo"
},
"BackendIpPrefix": {
"Ref": "BackendIpPrefix"
},
"BackendNetworkId": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.NetworkId"
]
},
"BackendSubnetId": {
"Fn::GetAtt": [
"BackendNetwork",
"Outputs.SubnetId"
]
},
"InstanceType": {
"Ref": "InstanceTypeConfigSvr"
},
"InstanceZone": {
"Ref": "InstanceZone"
},
"KeyName": {
"Ref": "KeyName"
},
"PrimaryNetworkId": {
"Ref": "PrimaryNetworkId"
},
"VolumeSize": {
"Ref": "ConfigStorageVolumeSize"
},
"PrimarySecurityGroup": {
"Ref": "PrimaryConfigServerSecurityGroup"
},
"BackendSecurityGroup": {
"Ref": "BackendConfigServerSecurityGroup"
},
"TemplateBaseUrl": {
"Ref": "TemplateBaseUrl"
},
"ExtraUserData": {
"Fn::Join": [
"",
[
"yum install -y httpd\n",
"for FILE in MongoDB_ShardedReplicaSet.template MongoDB_Router.template; do \n",
"curl ",
{
"Ref": "TemplateBaseUrl"
},
"/$FILE.in > /var/www/html/$FILE.in \n",
"cat /var/www/html/$FILE.in | sed 's/@PrimaryNetworkId@/",
{ "Ref": "PrimaryNetworkId" },
"/g' | sed 's/@BackendNetworkId@/",
{ "Fn::GetAtt": [ "BackendNetwork", "Outputs.NetworkId" ] },
"/g' | sed 's/@BackendSubnetId@/",
{ "Fn::GetAtt": [ "BackendNetwork", "Outputs.SubnetId" ] },
"/g' | sed 's/@PrimaryReplicaSetSecurityGroup@/",
{ "Ref": "PrimaryReplicaSetSecurityGroup" },
"/g' | sed 's/@BackendReplicaSetSecurityGroup@/",
{ "Ref": "BackendReplicaSetSecurityGroup" },
"/g' | sed 's/@PrimaryRouterSecurityGroup@/",
{ "Ref": "PrimaryRouterSecurityGroup" },
"/g' | sed 's/@BackendRouterSecurityGroup@/",
{ "Ref": "BackendRouterSecurityGroup" },
"/g' | sed 's/@KEYNAME@/",
{ "Ref": "KeyName" },
"/g' | sed 's/@TemplateBaseUrl@/",
{ "Ref": "TemplateBaseUrl" },
"/g' | sed 's/@MongoDBYumRepo@/",
{ "Ref": "MongoDBYumRepo" },
"/g' | sed \"s/@CONFIGSVR1@/$CONFIGSVR1/g\" | sed \"s/@CONFIGSVR2@/$CONFIGSVR2/g\" | sed \"s/@CONFIGSVR3@/$CONFIGSVR3/g\"",
" > /var/www/html/$FILE\n",
"done\n",
"/etc/init.d/httpd restart\n"
]
]
}
},
"TemplateURL": {
"Fn::Join": [
"",
[
{ "Ref": "TemplateBaseUrl" },
"/MongoDB_ConfigCluster.template"
]
]
}
},
"Type": "AWS::CloudFormation::Stack"
}
}
}
Loading

3 comments on commit 1d4ce30

@igreenfield
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kfox1111
How I can define the size of replicaSet?
How I can define number of shards?

@kfox1111
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi igreenfield,

Due to some limitations in Havana Heat, those two things are currently harder then I would like. The heat folks are working on a new autoscaling api that would allow both of these things to be easily specified and scaled. Its tentatively scheduled for the Icehouse time frame. I'm working with them to try and simplify this use case as much as possible in the future.

But, as of now:

I'm guessing that when you say size of replicaSet, you mean the number of replica's in the set? At the moment this is hard coded to 2.
You can adjust this by duplicating the "ReplicaSetMember2" section in MongoDB_ReplicaSet.template to as many as you need.

As for the number of shards, once you start an instance of MongoDB_BaseCluster.template, there will be a web server running on each of the ConfigSvr's. You currently need to launch a new stack with the url http://<a_config_srv_floating_ip>/MongoDB_ShardedReplicaSet.template for each shard you want.

Thanks,
Kevin

@igreenfield
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much.
We are now developing an higher level of orchestration component.

Please sign in to comment.