diff options
author | Don Brewer <dbrewer@dbrewer-host.usersys.redhat.com> | 2008-04-09 09:22:48 -0400 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2008-04-15 10:37:38 -0400 |
commit | 1bdc1f426185f05beb573eb7ca63d404d849d753 (patch) | |
tree | 175ae51b1d692b74b4d34a16a9545aa03be0e5e9 | |
parent | 28544868b29c412418436e9924f301ac210c6236 (diff) | |
download | puppet-mysql-1bdc1f426185f05beb573eb7ca63d404d849d753.tar.gz puppet-mysql-1bdc1f426185f05beb573eb7ca63d404d849d753.tar.xz puppet-mysql-1bdc1f426185f05beb573eb7ca63d404d849d753.zip |
added server_id and master_ip factors
-rw-r--r-- | manifests/init.pp | 29 | ||||
-rw-r--r-- | templates/gather_master_data.bash.erb | 8 | ||||
-rw-r--r-- | templates/my.cnf.erb | 2 |
3 files changed, 29 insertions, 10 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index 38ae339..c840baa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -76,7 +76,7 @@ class mysql::server { class mysql::standalone inherits mysql::server { $binary_logging = false - $server_id = "1" + file { "/etc/my.cnf": ensure => present, owner => "mysql", @@ -89,7 +89,6 @@ class mysql::standalone inherits mysql::server { class mysql::master inherits mysql::server { $binary_logging = true - $server_id = $variables::mysql_master_server_id file { "/etc/my.cnf": ensure => present, @@ -99,12 +98,32 @@ class mysql::master inherits mysql::server { content => template("mysql/my.cnf.erb"), before => Service["mysql"], } + + file { "/var/lib/mysql/gather_master_data.bash": + owner => "mysql", + group => "mysql", + ensure => present, + mode => 0755, + content => template("mysql/gather_master_data.bash.erb"), + require => Exec["grants all to replication user"], + } + + exec { "set master data for slave": + command => "/var/lib/mysql/gather_master_data.bash", + creates => "/var/lib/mysql/set_master_repl_data.sql", + unless => "/usr/bin/mysql --user=$mysql_replication_user --host=$mysql_master_ip_address --password=$mysql_replication_password --database=$mysql_root_database --execute=\"show master status;\"", + require => File["/var/lib/mysql/gather_master_data.bash"], + } + + exec { "start slave server": + command => "$mysql_cmd_repl_with_pwd --execute=\"start slave;\"", + unless => "$mysql_cmd_repl_with_pwd --execute=\"show slave status;\" | grep Wait", + require => Exec["set master data for slave"], + } } class mysql::slave inherits mysql::server { $binary_logging = true - $server_id = $variables::mysql_slave_server_id - $master_host_ip ='10.11.227.42' file { "/etc/my.cnf": ensure => present, @@ -121,13 +140,13 @@ class mysql::slave inherits mysql::server { ensure => present, mode => 0755, content => template("mysql/gather_master_data.bash.erb"), -# source => "puppet://$puppetserver/mysql/gather_master_data.bash", require => Exec["grants all to replication user"], } exec { "set master data for slave": command => "/var/lib/mysql/gather_master_data.bash", creates => "/var/lib/mysql/set_master_repl_data.sql", + unless => "/usr/bin/mysql --user=$mysql_replication_user --host=$mysql_master_ip_address --password=$mysql_replication_password --database=$mysql_root_database --execute=\"show master status;\"", require => File["/var/lib/mysql/gather_master_data.bash"], } diff --git a/templates/gather_master_data.bash.erb b/templates/gather_master_data.bash.erb index c9d3804..53cf2cf 100644 --- a/templates/gather_master_data.bash.erb +++ b/templates/gather_master_data.bash.erb @@ -2,20 +2,20 @@ PATH=$PATH -logname=$(mysql -u replication --host=<%= master_host_ip %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $1 }') +logname=$(mysql -u replication --host=<%= mysql_master_ip_address %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $1 }') export logname -position=$(mysql -u replication --host=<%= master_host_ip %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $2 }') +position=$(mysql -u replication --host=<%= mysql_master_ip_address %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $2 }') export position rm /var/lib/mysql/set_master_repl_data.sql -export master_host_ip=<%= master_host_ip %> +export mysql_master_ip_address=<%= mysql_master_ip_address %> #Build MySQL Master Data Script # echo CHANGE MASTER TO >> /var/lib/mysql/set_master_repl_data.sql -echo MASTER_HOST=\'$master_host_ip\', >> /var/lib/mysql/set_master_repl_data.sql +echo MASTER_HOST=\'$mysql_master_ip_address\', >> /var/lib/mysql/set_master_repl_data.sql echo MASTER_USER=\'replication\', >> /var/lib/mysql/set_master_repl_data.sql echo MASTER_PASSWORD=\'password\', >> /var/lib/mysql/set_master_repl_data.sql echo MASTER_LOG_FILE=\'$logname\', >> /var/lib/mysql/set_master_repl_data.sql diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index 4013650..1c009fa 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -78,7 +78,7 @@ innodb_file_per_table # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted -server-id = <%= server_id %> +server-id = <%= mysql_server_id %> # Replication Slave (comment out master section to use this) # |