Last active
August 29, 2015 14:05
-
-
Save gswallow/05aae276ec1dc87fd301 to your computer and use it in GitHub Desktop.
mongodb on ebs
This file contains hidden or 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
<% unless @prefixes.nil? -%> | |
<% @prefixes.each do |pfx| -%> | |
ACTION=="add", KERNEL=="<%= pfx %>", ATTR{bdi/read_ahead_kb}="32" | |
<% end -%> | |
<% end -%> | |
<% unless @raid_dev.nil? -%> | |
ACTION=="add", KERNEL=="<%= @raid_dev %>", ATTR{bdi/read_ahead_kb}="32" | |
<% end -%> |
This file contains hidden or 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
package "numactl" | |
if node.attribute?('ec2') | |
unless node['mongodb']['client_only'] | |
directory "/data" | |
directory "/var/lib/mongodb" | |
Chef::Log.info node[:aws].inspect | |
node.set_unless[:aws][:raid][:size] = 0 | |
node.set_unless[:aws][:raid][:count] = 4 | |
node.set_unless[:aws][:raid][:level] = 0 | |
node.set_unless[:aws][:raid][:mount_point] = '/data' | |
disk_count = node[:aws][:raid][:count].to_i | |
disk_size = node[:aws][:raid][:size].to_i / disk_count | |
mount_point = node[:aws][:raid][:mount_point] | |
node.set_unless[:aws][:raid][:piops_ratio] = 10 | |
node.set_unless[:aws][:raid][mount_point][:filesystem] = 'xfs' | |
snapshots = node[:aws][:raid].has_key?('snapshots') ? node[:aws][:raid][:snapshots] : nil | |
unless disk_size == 0 | |
aws_ebs_raid 'db_ebs_volume' do | |
disk_size disk_size.ceil | |
disk_count disk_count | |
level node[:aws][:raid][:level] | |
filesystem node[:aws][:raid][mount_point][:filesystem] | |
disk_type "io1" | |
disk_piops (disk_size * node[:aws][:raid][:piops_ratio]).ceil | |
snapshots snapshots | |
mount_point node[:aws][:raid][:mount_point] | |
end | |
end | |
mount mount_point do | |
device lazy { "/dev/#{node[:aws][:raid][mount_point][:raid_dev]}" } | |
fstype lazy { node[:aws][:raid][mount_point][:filesystem] } | |
action :enable | |
end | |
directory "#{mount_point}/mongodb" do | |
action :create | |
end | |
mount "/var/lib/mongodb" do | |
device "#{mount_point}/mongodb" | |
fstype "none" | |
options "bind,rw" | |
action [ :enable, :mount ] | |
end | |
execute "set readahead on block devices" do | |
command lazy { "blockdev --setra 64 #{node[:aws][:raid][mount_point][:device_map].keys.collect {|d| d.gsub(/sd/,'/dev/xvd')}.join(' ')} /dev/#{node[:aws][:raid][mount_point][:raid_dev]}" } | |
end | |
end | |
template "/etc/udev/rules.d/90-ebs.rules" do | |
source "90-ebs.rules.erb" | |
owner "root" | |
group "root" | |
variables( lazy { | |
{ :prefixes => node[:aws][:raid][mount_point][:device_map].keys.collect {|d| d.gsub(/sd/,'xvd')}, | |
:raid_dev => node[:aws][:raid][mount_point][:raid_dev] } | |
} ) | |
action :create | |
end | |
end | |
if node['mongodb']['upgrade'] | |
include_recipe "ascent-wrappers::mongodb_upgrade" | |
else | |
include_recipe "ascent-wrappers::mongodb_install" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment