Created
February 26, 2016 20:14
-
-
Save anonymous/25b75bc2dfa9211495e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "LizardFS CloudFormation template.", | |
"Parameters" : { | |
"DataNodeCount" : { | |
"Description" : "Number of data nodes to provision in cluster (2-18)", | |
"Type" : "Number", | |
"Default" : "2", | |
"MinValue" : "2", | |
"MaxValue" : "18", | |
"ConstraintDescription" : "must be between 2 and 18." | |
}, | |
"KeyPair": { | |
"Description" : "Name of an existing EC2 KeyPair: https://console.aws.amazon.com/ec2/v2/home#KeyPairs:", | |
"Type": "String", | |
"MinLength": "1", | |
"MaxLength": "255", | |
"AllowedPattern" : "[\\x20-\\x7E]*", | |
"ConstraintDescription" : "can contain only ASCII characters." | |
}, | |
"ClusterAccess" : { | |
"Description" : "CIDR IP range allowed to login to the cluster instances", | |
"Type": "String", | |
"MinLength": "9", | |
"MaxLength": "18", | |
"Default": "0.0.0.0/0", | |
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", | |
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." | |
}, | |
"ClusterInstanceType" : { | |
"Description" : "AMI instance type: https://aws.amazon.com/ec2/instance-types/", | |
"Type" : "String", | |
"Default" : "m1.medium" | |
} | |
}, | |
"Mappings" : { | |
"LinuxRegionMap" : { | |
"source" : { "URL" : "http://cloud-images.ubuntu.com/locator/ec2/ --> search for '14.04 amd64 instance aki' for details" }, | |
"ap-northeast-1" : { "AMI" : "ami-a3615bcd" }, | |
"ap-southeast-1" : { "AMI" : "ami-f6529d95" }, | |
"eu-central-1" : { "AMI" : "ami-42f3eb2e" }, | |
"eu-west-1" : { "AMI" : "ami-5f8e382c" }, | |
"sa-east-1" : { "AMI" : "ami-aa1999c6" }, | |
"us-east-1" : { "AMI" : "ami-91c5eafb" }, | |
"us-west-1" : { "AMI" : "ami-6f22540f" }, | |
"cn-north-1" : { "AMI" : "ami-d67db4bb" }, | |
"us-gov-west-1" : { "AMI" : "ami-5cbbd97f" }, | |
"ap-southeast-2" : { "AMI" : "ami-01dffb62" }, | |
"us-west-2" : { "AMI" : "ami-befd1bde" } | |
} | |
}, | |
"Resources" : { | |
"ClusterSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : { | |
"GroupDescription" : "Cluster Security Group", | |
"Tags" : [{ "Key" : "Name", "Value" : "Cluster Security Group" }], | |
"SecurityGroupIngress" : [ | |
{ | |
"IpProtocol" : "tcp", | |
"FromPort" : "22", | |
"ToPort" : "22", | |
"CidrIp" : { "Ref" : "ClusterAccess" } | |
} | |
] | |
} | |
}, | |
"UpdateSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroupIngress", | |
"Properties" : { | |
"GroupName" : { "Ref" : "ClusterSecurityGroup" }, | |
"SourceSecurityGroupName" : { "Ref" : "ClusterSecurityGroup" }, | |
"IpProtocol" : "tcp", | |
"FromPort" : "0", | |
"ToPort" : "65535" | |
} | |
}, | |
"Master1" : { | |
"Type" : "AWS::EC2::Instance", | |
"Properties" : { | |
"InstanceType" : { "Ref" : "ClusterInstanceType" }, | |
"SecurityGroups" : [ { "Ref" : "ClusterSecurityGroup" } ], | |
"KeyName" : { "Ref" : "KeyPair" }, | |
"ImageId" : { "Fn::FindInMap" : [ "LinuxRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"Tags" : [{ "Key" : "Name", "Value" : "LizardFS Server" }], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"sudo su -\n", | |
"echo 'deb http://packages.lizardfs.com/ubuntu/trusty trusty main' > /etc/apt/sources.list.d/lizardfs.list\n", | |
"echo 'deb-src http://packages.lizardfs.com/ubuntu/trusty trusty main' >> /etc/apt/sources.list.d/lizardfs.list\n", | |
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3EE4D2780BF8466D\n", | |
"apt-get update -y\n", | |
"apt-get install -y lizardfs-master lizardfs-chunkserver\n", | |
"echo 'PERSONALITY = master' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4 | cut -d '.' -f 1-2`'.0.0/16 / rw,alldirs,maproot=0' >> /etc/mfs/mfsexports.cfg\n", | |
"mv /var/lib/mfs/metadata.mfs.empty /var/lib/mfs/metadata.mfs\n", | |
"echo 'LIZARDFSMASTER_ENABLE=true' > /etc/default/lizardfs-master\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-master\n", | |
"/etc/init.d/lizardfs-master start\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4`' mfsmaster' >> /etc/hosts\n", | |
"mkdir -p /mnt/lfschunk\n", | |
"echo '/mnt/lfschunk' >> /etc/mfs/mfshdd.cfg\n", | |
"echo 'LIZARDFSCHUNKSERVER_ENABLE=true' > /etc/default/lizardfs-chunkserver\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-chunkserver\n", | |
"/etc/init.d/lizardfs-chunkserver start" | |
]]}} | |
} | |
}, | |
"Master2" : { | |
"Type" : "AWS::EC2::Instance", | |
"DependsOn" : "Master1", | |
"Properties" : { | |
"InstanceType" : { "Ref" : "ClusterInstanceType" }, | |
"SecurityGroups" : [ { "Ref" : "ClusterSecurityGroup" } ], | |
"KeyName" : { "Ref" : "KeyPair" }, | |
"ImageId" : { "Fn::FindInMap" : [ "LinuxRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"Tags" : [{ "Key" : "Name", "Value" : "LizardFS Server" }], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"sudo su -\n", | |
"echo 'deb http://packages.lizardfs.com/ubuntu/trusty trusty main' > /etc/apt/sources.list.d/lizardfs.list\n", | |
"echo 'deb-src http://packages.lizardfs.com/ubuntu/trusty trusty main' >> /etc/apt/sources.list.d/lizardfs.list\n", | |
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3EE4D2780BF8466D\n", | |
"apt-get update -y\n", | |
"apt-get install -y lizardfs-master lizardfs-chunkserver\n", | |
"echo 'PERSONALITY = shadow' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4 | cut -d '.' -f 1-2`'.0.0/16 / rw,alldirs,maproot=0' >> /etc/mfs/mfsexports.cfg\n", | |
"mv /var/lib/mfs/metadata.mfs.empty /var/lib/mfs/metadata.mfs\n", | |
"echo 'LIZARDFSMASTER_ENABLE=true' > /etc/default/lizardfs-master\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-master\n", | |
"/etc/init.d/lizardfs-master start\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4`' mfsmaster' >> /etc/hosts\n", | |
"mkdir -p /mnt/lfschunk\n", | |
"echo '/mnt/lfschunk' >> /etc/mfs/mfshdd.cfg\n", | |
"echo 'LIZARDFSCHUNKSERVER_ENABLE=true' > /etc/default/lizardfs-chunkserver\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-chunkserver\n", | |
"/etc/init.d/lizardfs-chunkserver start" | |
]]}} | |
} | |
}, | |
"Master3" : { | |
"Type" : "AWS::EC2::Instance", | |
"DependsOn" : "Master2", | |
"Properties" : { | |
"InstanceType" : { "Ref" : "ClusterInstanceType" }, | |
"SecurityGroups" : [ { "Ref" : "ClusterSecurityGroup" } ], | |
"KeyName" : { "Ref" : "KeyPair" }, | |
"ImageId" : { "Fn::FindInMap" : [ "LinuxRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"Tags" : [{ "Key" : "Name", "Value" : "LizardFS Server" }], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"sudo su -\n", | |
"echo 'deb http://packages.lizardfs.com/ubuntu/trusty trusty main' > /etc/apt/sources.list.d/lizardfs.list\n", | |
"echo 'deb-src http://packages.lizardfs.com/ubuntu/trusty trusty main' >> /etc/apt/sources.list.d/lizardfs.list\n", | |
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3EE4D2780BF8466D\n", | |
"apt-get update -y\n", | |
"apt-get install -y lizardfs-master lizardfs-chunkserver\n", | |
"echo 'PERSONALITY = shadow' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfsmaster.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4 | cut -d '.' -f 1-2`'.0.0/16 / rw,alldirs,maproot=0' >> /etc/mfs/mfsexports.cfg\n", | |
"mv /var/lib/mfs/metadata.mfs.empty /var/lib/mfs/metadata.mfs\n", | |
"echo 'LIZARDFSMASTER_ENABLE=true' > /etc/default/lizardfs-master\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-master\n", | |
"/etc/init.d/lizardfs-master start\n", | |
"echo 'WORKING_USER = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo 'WORKING_GROUP = root' >> /etc/mfs/mfschunkserver.cfg\n", | |
"echo `curl -s http://169.254.169.254/latest/meta-data/local-ipv4`' mfsmaster' >> /etc/hosts\n", | |
"mkdir -p /mnt/lfschunk\n", | |
"echo '/mnt/lfschunk' >> /etc/mfs/mfshdd.cfg\n", | |
"echo 'LIZARDFSCHUNKSERVER_ENABLE=true' > /etc/default/lizardfs-chunkserver\n", | |
"echo 'DAEMON_OPTS=\"\"' >> /etc/default/lizardfs-chunkserver\n", | |
"/etc/init.d/lizardfs-chunkserver start" | |
]]}} | |
} | |
}, | |
"DataNode" : { | |
"Type" : "AWS::AutoScaling::LaunchConfiguration", | |
"DependsOn" : "Master3", | |
"Properties" : { | |
"InstanceType" : { "Ref" : "ClusterInstanceType" }, | |
"SecurityGroups" : [ { "Ref" : "ClusterSecurityGroup" } ], | |
"KeyName" : { "Ref" : "KeyPair" }, | |
"ImageId" : { "Fn::FindInMap" : [ "LinuxRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"sudo su -\n", | |
"echo 'deb http://packages.lizardfs.com/ubuntu/trusty trusty main' > /etc/apt/sources.list.d/lizardfs.list\n", | |
"echo 'deb-src http://packages.lizardfs.com/ubuntu/trusty trusty main' >> /etc/apt/sources.list.d/lizardfs.list\n", | |
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3EE4D2780BF8466D\n", | |
"apt-get update -y\n", | |
"apt-get install -y lizardfs-client\n", | |
"echo '", | |
{ "Fn::GetAtt" : [ "Master1" , "PrivateIp" ] }, | |
" mfsmaster' >> /etc/hosts\n", | |
"mkdir -p /mnt/lizardfs\n", | |
"mfsmount /mnt/lizardfs" | |
]]}} | |
} | |
}, | |
"ClusterInit" : { | |
"Type" : "AWS::AutoScaling::AutoScalingGroup", | |
"Properties" : { | |
"AvailabilityZones" : { "Fn::GetAZs" : "" }, | |
"LaunchConfigurationName" : { "Ref" : "DataNode" }, | |
"MinSize" : "2", | |
"MaxSize" : "18", | |
"DesiredCapacity" : { "Ref" : "DataNodeCount" }, | |
"Tags" : [{ "Key" : "Name", "Value" : "LizardFS Node", "PropagateAtLaunch" : "true" }] | |
} | |
} | |
}, | |
"Outputs" : { | |
"Info" : { | |
"Description" : "Info", | |
"Value" : "Any file created on the 'LizardFS Node' instances in /mnt/lizardfs will be synced to all LizardFS Node instances." | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
Does this automatically handle failover from one master to another? If so, how?