Randomize time of execution for optimize script.
By default, time will be between midnight and 7:00 any day of the week. The values are currently hard-coded. This can have serious I/O repercussions on a server with multiple VMs that run mysql since they will all run their optimizations simultaneously.
This commit is contained in:
parent
6d9a846867
commit
ae2fbce7ac
3 changed files with 16 additions and 5 deletions
|
@ -8,6 +8,9 @@ class mysql::server (
|
||||||
$nagios_password_hash = 'absent',
|
$nagios_password_hash = 'absent',
|
||||||
$backup_cron = false,
|
$backup_cron = false,
|
||||||
$optimize_cron = false,
|
$optimize_cron = false,
|
||||||
|
$optimize_hour = fqdn_rand(7),
|
||||||
|
$optimize_minute = fqdn_rand(60),
|
||||||
|
$optimize_day = fqdn_rand(7),
|
||||||
$backup_dir = '/var/backups/mysql',
|
$backup_dir = '/var/backups/mysql',
|
||||||
$manage_backup_dir = true,
|
$manage_backup_dir = true,
|
||||||
$nagios_notcp = false
|
$nagios_notcp = false
|
||||||
|
|
|
@ -70,7 +70,11 @@ class mysql::server::base {
|
||||||
}
|
}
|
||||||
|
|
||||||
if $mysql::server::optimize_cron {
|
if $mysql::server::optimize_cron {
|
||||||
include mysql::server::cron::optimize
|
class { 'mysql::server::cron::optimize':
|
||||||
|
optimize_hour => $mysql::server::optimize_hour,
|
||||||
|
optimize_minute => $mysql::server::optimize_minute,
|
||||||
|
optimize_day => $mysql::server::optimize_day,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service { 'mysql':
|
service { 'mysql':
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# optimize mysql databases regurarely
|
# optimize mysql databases regurarely
|
||||||
class mysql::server::cron::optimize {
|
class mysql::server::cron::optimize (
|
||||||
|
$optimize_hour,
|
||||||
|
$optimize_minute,
|
||||||
|
$optimize_day
|
||||||
|
) {
|
||||||
|
|
||||||
file { 'mysql_optimize_script':
|
file { 'mysql_optimize_script':
|
||||||
path => '/usr/local/sbin/optimize_mysql_tables.rb',
|
path => '/usr/local/sbin/optimize_mysql_tables.rb',
|
||||||
|
@ -12,9 +16,9 @@ class mysql::server::cron::optimize {
|
||||||
cron { 'mysql_optimize_cron':
|
cron { 'mysql_optimize_cron':
|
||||||
command => '/usr/local/sbin/optimize_mysql_tables.rb',
|
command => '/usr/local/sbin/optimize_mysql_tables.rb',
|
||||||
user => 'root',
|
user => 'root',
|
||||||
minute => 40,
|
minute => $optimize_minute,
|
||||||
hour => 6,
|
hour => $optimize_hour,
|
||||||
weekday => 7,
|
weekday => $optimize_day,
|
||||||
require => [ Exec['mysql_set_rootpw'],
|
require => [ Exec['mysql_set_rootpw'],
|
||||||
File['mysql_root_cnf'],
|
File['mysql_root_cnf'],
|
||||||
File['mysql_optimize_script'] ],
|
File['mysql_optimize_script'] ],
|
||||||
|
|
Loading…
Reference in a new issue