Templating MySQL my.cnf to configure in Puppet

I was assigned MySQL templates my.cnf in an attempt to standardize the configuration between subordinate databases using Puppet. Right now, I'm setting up innodb settings. Are there any configuration parameters that can be safely calculated in relation to technical characteristics such as memory, disk and procs?

+3
source share
3 answers

You need an employee.

puppet:/etc/puppet/modules/master/lib/facter$ cat disks.rb
#!/usr/bin/ruby
#require 'facter'

mount = `/bin/mount`
disks=Array.new 
mount.split("\n").each_with_index { | disk,i |
  unless disk.scan(/ext3|simfs|reiserfs|xfs/).empty?
    d=disk.split[2]
    disks.push d
    disks.push ','
 end
}

Facter.add('disks') do
 setcode do
   disks
 end 
end 

`and in puppet.pp I use the facts $ disks

#add disk check to zabbix
exec { "create_host":
    command => "/bin/echo $fqdn $ipaddress $disks | do_work",
    require => File["/root/ticket"],
    subscribe => File["/root/ticket"],
    refreshonly => true,
}

see "Adding Custom Facts to Facts" in puppet laboratories.

+4
source

I will be tempted to move the calculations to the erb file, for example, it is recommended to set key_buffer_size in 1/4 of the system memory:

set-variable = key_buffer_size=<%= (memorysize.split(' ')[0].to_i * 1024) / 4 -%>M

, , Facter ( ..), , , .

, ERB Ruby, , Ruby, ERB.

+2

the doll has an erb pattern, the erb pattern can use a fax value, such as a host name or memo. and you can write your own shell script.

0
source

Source: https://habr.com/ru/post/1793139/


All Articles