Created — forked from fujin/8_vol_ebs_stripeset.rb

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

automatic 8 vol ebs LVM2 stripe set (raid0). 256k chunks, 8-way stripe. 65k readahead.

View 8_vol_ebs_stripeset.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
include_recipe "aws"
include_recipe "lvm"
include_recipe "xfs"
 
esvg = node.elasticsearch.ebs.lvm.volume_group
eslv = node.elasticsearch.ebs.lvm.logical_volume
Chef::Log.info "ElasticSearch: setting up 8 100G EBS volumes"
aws = data_bag_item("aws", node.app_environment)
8.times do |d|
disk = (d == 0 ? "/dev/sdi" : "/dev/sdi#{d}")
aws_ebs_volume "ElasticSearch EBS: #{disk}" do
aws_access_key aws['aws_access_key_id']
aws_secret_access_key aws['aws_secret_access_key']
size 100
device disk
action [ :create, :attach ]
end
 
execute "LVM: Initialize physical disk '#{disk}'" do
command "pvcreate #{disk}"
not_if "pvdisplay #{disk}"
end
 
execute "LVM: Create volume group #{esvg}" do
command "vgcreate #{esvg} #{disk}"
not_if "vgdisplay #{esvg}"
end
 
execute "LVM: Extend volume group #{esvg} with #{disk}" do
command "vgextend #{esvg} #{disk}"
not_if "pvs --noheadings -o vg_name #{disk} | grep #{esvg}"
end
end
 
execute "LVM: Create striped LV #{eslv}" do
command "lvcreate -i 8 -I 256 -n #{eslv}" +
" -l 100%FREE #{esvg}"
not_if "lvdisplay /dev/#{esvg}/#{eslv}"
end
 
execute "XFS: Format /dev/#{esvg}/#{eslv}" do
action :nothing
subscribes :run, resources(:execute => "LVM: Create striped LV #{eslv}"), :immediately
command "mkfs.xfs /dev/#{esvg}/#{eslv}"
end
 
directory node.elasticsearch.path.work
 
execute "blockdev --setra 65536 /dev/mapper/#{esvg}-#{eslv}" do
not_if "blockdev --getra /dev/mapper/#{esvg}-#{eslv} | grep 65536"
end
 
mount node.elasticsearch.path.work do
device "/dev/mapper/#{esvg}-#{eslv}"
fstype "xfs"
options "rw,noatime,inode64"
action :mount
end
 
ruby_block "update your databagz, yo" do
block do
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.