我正在尝试为Cassandra设置新的食谱,并在cassandra.yaml
文件上设置了关于最佳设置的以下评论:
# For workloads with more data than can fit in memory, Cassandra's
# bottleneck will be reads that need to fetch data from
# disk. "concurrent_reads" should be set to (16 * number_of_drives) in
# order to allow the operations to enqueue low enough in the stack
# that the OS and drives can reorder them.
#
# On the other hand, since writes are almost never IO bound, the ideal
# number of "concurrent_writes" is dependent on the number of cores in
# your system; (8 * number_of_cores) is a good rule of thumb.
但是,无法确定属性中预定义的numbers of cores
或numbers of disk drives
,因为已部署的服务器可能具有不同的硬件设置。
是否可以使用已部署的硬件设置动态覆盖属性?我读了Opscode doc,我认为没有办法捕获输出
cat /proc/cpuinfo | grep processor | wc -l
我在考虑这样的事情:
食谱-卡桑德拉/食谱/ default.rb
cores = command "cat /proc/cpuinfo | grep processor | wc -l"
node.default["cassandra"]["concurrent_reads"] = cores*8
node.default["cassandra"]["concurrent_writes"] = cores*8
食谱-卡桑德拉/属性/ default.rb
default[:cassandra] = {
...
# determined by 8 * number of cores
:concurrent_reads => 16,
:concurrent_writes => 16,
..
}
答案 0 :(得分:2)
您可以使用stdout
(此处为文档:https://github.com/opscode/mixlib-shellout)在Chef中捕获mixlib-shellout
。
在您的示例中,您可以执行以下操作:
cc = Mixlib::ShellOut.new("cat /proc/cpuinfo | grep processor | wc -l")
cores = cc.run_command.stdout.to_i # runs it, gets stdout, converts to integer
答案 1 :(得分:2)
我已经找到了一种在食谱中执行此操作的方法,但我尚未将其部署到任何框中以进行验证。
num_cores = Integer(`cat /proc/cpuinfo | grep processor | wc -l`)
if ( num_cores > 8 && num_cores != 0 ) # sanity check
node.default["cassandra"]["concurrent_reads"] = (8 * num_cores)
node.default["cassandra"]["concurrent_writes"] = (8 * num_cores)
end
答案 2 :(得分:0)
我正在使用厨师11,因此在以前的版本中可能无法使用,但有一个node['cpu']
属性,其中包含有关cpus,内核等的信息。
chef > x = nodes.show 'nodename.domain'; true
=> true
chef > x['cpu']['total']
=> 16
你可以在你的食谱上使用它。这就是Nginx食谱的功能。