Skip to content

Instantly share code, notes, and snippets.

@fujin
Created November 24, 2010 21:48
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujin/714494 to your computer and use it in GitHub Desktop.
Save fujin/714494 to your computer and use it in GitHub Desktop.
automatic 8 vol ebs LVM2 stripe set (raid0). 256k chunks, 8-way stripe. 65k readahead.
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