From 86fbcbe251538232fce94ff32cca4dc1ce1e4c12 Mon Sep 17 00:00:00 2001 From: Chris Alfonso Date: Thu, 3 Jul 2008 09:00:40 -0400 Subject: Adding mysql_grade server parameter to decide what mysql packages to install --- manifests/init.pp | 33 ++++++-- templates/my.cnf.5.0.erb | 216 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+), 6 deletions(-) create mode 100644 templates/my.cnf.5.0.erb diff --git a/manifests/init.pp b/manifests/init.pp index fc33154..755d2c1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -8,7 +8,19 @@ import "passwords" class mysql::server { include passwords include variables - + + case $mysql_grade{ + community: { + $mysql_server_package = "MySQL-server-community" + $mysql_client_package = "MySQL-client-community" + $mysql_service_name = "mysql" + } + default: { + $mysql_server_package = "mysql-server" + $mysql_client_package = "mysql" + $mysql_service_name = "mysqld" + } + } group { "mysql": ensure => present, require => User["mysql"], @@ -20,17 +32,18 @@ class mysql::server { } package { "mysql-client": - name => "MySQL-client-community", + name => $mysql_client_package, ensure => installed, } package { "mysql-server": - name => "MySQL-server-community", + name => $mysql_server_package, ensure => installed, require => Package["mysql-client"], } service { "mysql": + name => $mysql_service_name, ensure => running, hasstatus => true, require => Package["mysql-server"], @@ -122,16 +135,24 @@ class mysql::m2m inherits mysql::server { } define mysql::mysql_config ($binary_logging){ + case $mysql_grade{ + community: { + $mysql_config = "mysql/my.cnf.erb" + } + default: { + $mysql_config = "mysql/my.cnf.5.0.erb" + } + } file { "/etc/my.cnf": ensure => present, owner => "mysql", group => "mysql", mode => 0644, - content => template("mysql/my.cnf.erb"), + content => template("$mysql_config"), require => [Service["mysql"],Exec["grants all to replication user"]] } exec { "restart mysql server": - command => "service mysql restart", + command => "service $mysql_service_name restart", unless => "$mysql_cmd_repl_with_pwd --execute=\"show master status;\" | grep mysqllog", require => File["/etc/my.cnf"], } @@ -162,7 +183,7 @@ define mysql::mysql_replication { } } -define mysql::datasource($rootpw, $ds_name, $ds_owner, $ds_owner_pwd, $ds_user, $ds_user_pwd, $ds_schema, mysql_replication_user, mysql_replication_password, mysql_root_database, mysql_root_local_host, $ds_owner_permissions, $ds_user_permissions) { +define mysql::datasource($rootpw, $ds_name, $ds_owner, $ds_owner_pwd, $ds_user, $ds_user_pwd, $ds_schema, $mysql_replication_user, $mysql_replication_password, $mysql_root_database, $mysql_root_local_host, $ds_owner_permissions, $ds_user_permissions) { case $mysql_type { standalone: { $mysql_root_cmd = "/usr/bin/mysql --user=root --password=$rootpw " diff --git a/templates/my.cnf.5.0.erb b/templates/my.cnf.5.0.erb new file mode 100644 index 0000000..b1a6968 --- /dev/null +++ b/templates/my.cnf.5.0.erb @@ -0,0 +1,216 @@ +# Example MySQL config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# an important part, or systems up to 128M where MySQL is used together with +# other programs (such as a web server) +# +# You can copy this file to +# /etc/my.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /var/lib/mysql) or +# ~/.my.cnf to set user-specific options. +# +# In this file, you can use all long options that a program supports. +# If you want to know which options a program supports, run the program +# with the "--help" option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +socket = /var/lib/mysql/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +socket = /var/lib/mysql/mysql.sock +skip-locking +key_buffer = 16M +max_allowed_packet = 1M +table_cache = 64 +sort_buffer_size = 512K +net_buffer_length = 8K +read_buffer_size = 256K +read_rnd_buffer_size = 512K +myisam_sort_buffer_size = 8M +# Added default character set +#default-character-set=utf8 +default-character-set=utf8 + +# Don't listen on a TCP/IP port at all. This can be a security enhancement, +# if all processes that need to connect to mysqld run on the same host. +# All interaction with mysqld must be made via Unix sockets or named pipes. +# Note that using this option without enabling named pipes on Windows +# (via the "enable-named-pipe" option) will render mysqld useless! +# +#skip-networking + +# Replication Master Server (default) +# binary logging is required for replication +#log-bin=mysql-bin +# +# +<% if binary_logging %> +#log-output =FILE +#log =/var/lib/mysql/mysqllog_general.log +log-slow-queries=/var/lib/mysql/mysqllog_slow_queries.log +log-error =/var/lib/mysql/mysqlderror.log +log-bin =/var/lib/mysql/mysqllog_bin.log +log-queries-not-using-indexes +long-query-time=2 + +innodb_flush_log_at_trx_commit=1 +sync_binlog=0 + +<% end %> + +#To change the connection charset permanently to UTF-8 +init-connect='SET NAMES utf8' + + +# Create tablespace per schema. +innodb_file_per_table + + +# Auto Increment Parameters +auto_increment_increment = 10 +auto_increment_offset = <%= mysql_server_id %> + +# +# 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 = <%= mysql_server_id %> + +# Replication Slave (comment out master section to use this) +# +# To configure this host as a replication slave, you can choose between +# two methods : +# +# 1) Use the CHANGE MASTER TO command (fully described in our manual) - +# the syntax is: +# +# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, +# MASTER_USER=, MASTER_PASSWORD= ; +# +# where you replace , , by quoted strings and +# by the master's port number (3306 by default). +# +# Example: +# +# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, +# MASTER_USER='joe', MASTER_PASSWORD='secret'; +# +# OR +# +# 2) Set the variables below. However, in case you choose this method, then +# start replication for the first time (even unsuccessfully, for example +# if you mistyped the password in master-password and the slave fails to +# connect), the slave will create a master.info file, and any later +# change in this file to the variables' values below will be ignored and +# overridden by the content of the master.info file, unless you shutdown +# the slave server, delete master.info and restart the slaver server. +# For that reason, you may want to leave the lines below untouched +# (commented) and instead use CHANGE MASTER TO (see above) +# +# required unique id between 2 and 2^32 - 1 +# (and different from the master) +# defaults to 2 if master-host is set +# but will not function as a slave if omitted +#server-id = 2 +# +# The replication master for this slave - required +#master-host = +# +# The username the slave will use for authentication when connecting +# to the master - required +#master-user = +# +# The password the slave will authenticate with when connecting to +# the master - required +#master-password = +# +# The port the master is listening on. +# optional - defaults to 3306 +#master-port = +# +# binary logging - not required for slaves, but recommended +#log-bin=mysql-bin + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +# Uncomment the following if you are using InnoDB tables +#innodb_data_home_dir = /var/lib/mysql/ +#innodb_data_file_path = ibdata1:10M:autoextend +#innodb_log_group_home_dir = /var/lib/mysql/ +#innodb_log_arch_dir = /var/lib/mysql/ +# You can set .._buffer_pool_size up to 50 - 80 % +# of RAM but beware of setting memory usage too high +#innodb_buffer_pool_size = 16M + +innodb_buffer_pool_size=<%= +mem = memorysize[0..-4].to_f +unit = memorysize[-2..-2] +if unit == "G" +mem = mem*1024 +unit = "M" +end +(mem / 2.0).round +%><%= +unit +%> + + +#innodb_additional_mem_pool_size = 2M +# Set .._log_file_size to 25 % of buffer pool size +#innodb_log_file_size = 5M +#innodb_log_buffer_size = 8M +#innodb_flush_log_at_trx_commit = 1 +#innodb_lock_wait_timeout = 50 + + +[mysqldump] +quick +max_allowed_packet = 16M + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates + +[isamchk] +key_buffer = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[myisamchk] +key_buffer = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout + +<% if binary_logging %> +[mysqld_safe] +#log-output =FILE +#log =/var/lib/mysql/mysqllog_general.log +log-slow-queries=/var/lib/mysql/mysqllog_slow_queries.log +log-error =/var/lib/mysql/mysqlderror.log +log-bin =/var/lib/mysql/mysqllog_bin.log +log-queries-not-using-indexes +long-query-time=5 + +innodb_flush_log_at_trx_commit=1 +sync_binlog=0 + +<% end %> + +[mysqld_safe] +syslog -- cgit