Merge pull request #167 from abraham1901/master
Implement character_set and other options
This commit is contained in:
commit
731036e272
4 changed files with 286 additions and 89 deletions
|
@ -1,27 +1,73 @@
|
|||
# Class: mysql::config
|
||||
#
|
||||
# Parameters:
|
||||
# [*bind_address*] - address to bind service.
|
||||
# [*config_file*] - my.cnf configuration file path.
|
||||
# [*datadir*] - path to datadir.
|
||||
# [*tmpdir*] - path to tmpdir.
|
||||
# [*default_engine] - configure a default table engine
|
||||
# [*etc_root_password*] - whether to save /etc/my.cnf.
|
||||
# [*log_error] - path to mysql error log
|
||||
# [*manage_config_file*] - if the config file should be managed (default: true)
|
||||
# [*max_allowed_packet*] - Maximum network packet size mysqld will accept
|
||||
# [*old_root_password*] - previous root user password,
|
||||
# [*port*] - port to bind service.
|
||||
# [*restart] - whether to restart mysqld (true/false)
|
||||
# [*root_group] - use specified group for root-owned files
|
||||
# [*root_password*] - root user password.
|
||||
# [*service_name*] - mysql service name.
|
||||
# [*socket*] - mysql socket.
|
||||
# [*ssl] - enable ssl
|
||||
# [*ssl_ca] - path to ssl-ca
|
||||
# [*ssl_cert] - path to ssl-cert
|
||||
# [*ssl_key] - path to ssl-key
|
||||
#
|
||||
# [*root_password*] - root user password.
|
||||
# [*old_root_password*] - previous root user password,
|
||||
# [*bind_address*] - address to bind service.
|
||||
# [*port*] - port to bind service.
|
||||
# [*etc_root_password*] - whether to save /etc/my.cnf.
|
||||
# [*service_name*] - mysql service name.
|
||||
# [*config_file*] - my.cnf configuration file path.
|
||||
# [*socket*] - mysql socket.
|
||||
# [*datadir*] - path to datadir.
|
||||
# [*ssl] - enable ssl
|
||||
# [*ssl_ca] - path to ssl-ca
|
||||
# [*ssl_cert] - path to ssl-cert
|
||||
# [*ssl_key] - path to ssl-key
|
||||
# [*log_error] - path to mysql error log
|
||||
# [*default_engine] - configure a default table engine
|
||||
# [*root_group] - use specified group for root-owned files
|
||||
# [*restart] - whether to restart mysqld (true/false)
|
||||
# [*character_set] - You can change the default server and
|
||||
# client character set
|
||||
# [*key_buffer] - Index blocks for MyISAM tables are buffered and
|
||||
# are shared by all threads. key_buffer_size is the size of the buffer used
|
||||
# for index blocks.
|
||||
# [*max_allowed_packet] - The maximum size of one packet or any
|
||||
# generated/intermediate string, or any parameter sent by the
|
||||
# mysql_stmt_send_long_data() C API function.
|
||||
# [*thread_stack] - The stack size for each thread.
|
||||
# [*thread_cache_size] - How many threads server should cache for reuse.
|
||||
# [*myisam-recover] - Set the MyISAM storage engine recovery mode.
|
||||
# [*query_cache_limit] - Do not cache results that are larger than this
|
||||
# number of bytes.
|
||||
# [*query_cache_size] - The amount of memory allocated for caching query
|
||||
# results.
|
||||
# [*max_connections] - The maximum permitted number of simultaneous
|
||||
# client connections.
|
||||
# [*tmp_table_size] - The maximum size of internal in-memory temporary
|
||||
# tables.
|
||||
# [*max_heap_table_size] - This variable sets the maximum size to which
|
||||
# user-created MEMORY tables are permitted to grow.
|
||||
# [*table_open_cache] - The number of open tables for all threads.
|
||||
# [*long_query_time] - If a query takes longer than this many seconds,
|
||||
# the server increments the Slow_queries status variable.
|
||||
# [*server_id] - The server ID, used in replication to give each
|
||||
# master and slave a unique identity.
|
||||
# [*sql_log_bin] - This variable controls whether logging to the
|
||||
# binary log is done. The default value is 1.
|
||||
# [*log_bin] - Enable binary logging. The server logs all
|
||||
# statements that change data to the binary log, which is used for backup
|
||||
# and replication.
|
||||
# [*max_binlog_size] - If a write to the binary log causes the current
|
||||
# log file size to exceed the value of this variable, the server rotates
|
||||
# the binary logs (closes the current file and opens the next one).
|
||||
# [*binlog_do_db] - This option affects binary logging in a manner
|
||||
# similar to the way that --replicate-do-db affects replication.
|
||||
# [*expire_logs_days] - The number of days for automatic binary log file
|
||||
# removal.
|
||||
# [*log_bin_trust_function_creators] - It controls whether stored function
|
||||
# creators can be trusted not to create stored functions that will cause
|
||||
# unsafe events to be written to the binary log.
|
||||
# [*replicate_ignore_table] - Tells the slave SQL thread not to
|
||||
# replicate any statement that updates the specified table, even if any
|
||||
# other tables might be updated by the same statement.
|
||||
# [*replicate_wild_do_table] - Tells the slave thread to restrict
|
||||
# replication to statements where any of the updated tables match the
|
||||
# specified database and table name patterns.
|
||||
# [*replicate_wild_ignore_table] - Tells the slave thread not to
|
||||
# replicate a statement where any table matches the given wildcard pattern.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -37,37 +83,57 @@
|
|||
# }
|
||||
#
|
||||
class mysql::config(
|
||||
$bind_address = $mysql::bind_address,
|
||||
$config_file = $mysql::config_file,
|
||||
$datadir = $mysql::datadir,
|
||||
$tmpdir = $mysql::tmpdir,
|
||||
$default_engine = $mysql::default_engine,
|
||||
$etc_root_password = $mysql::etc_root_password,
|
||||
$manage_config_file = $mysql::manage_config_file,
|
||||
$max_allowed_packet = $mysql::max_allowed_packet,
|
||||
$log_error = $mysql::log_error,
|
||||
$pidfile = $mysql::pidfile,
|
||||
$port = $mysql::port,
|
||||
$purge_conf_dir = $mysql::purge_conf_dir,
|
||||
$max_connections = $mysql::max_connections,
|
||||
$restart = $mysql::restart,
|
||||
$root_group = $mysql::root_group,
|
||||
$root_password = $mysql::root_password,
|
||||
$old_root_password = $mysql::old_root_password,
|
||||
$service_name = $mysql::service_name,
|
||||
$socket = $mysql::socket,
|
||||
$ssl = $mysql::ssl,
|
||||
$ssl_ca = $mysql::ssl_ca,
|
||||
$ssl_cert = $mysql::ssl_cert,
|
||||
$ssl_key = $mysql::ssl_key
|
||||
$root_password = $mysql::root_password,
|
||||
$old_root_password = $mysql::old_root_password,
|
||||
$bind_address = $mysql::bind_address,
|
||||
$port = $mysql::port,
|
||||
$etc_root_password = $mysql::etc_root_password,
|
||||
$manage_config_file = $mysql::manage_config_file,
|
||||
$service_name = $mysql::service_name,
|
||||
$config_file = $mysql::config_file,
|
||||
$socket = $mysql::socket,
|
||||
$pidfile = $mysql::pidfile,
|
||||
$datadir = $mysql::datadir,
|
||||
$ssl = $mysql::ssl,
|
||||
$ssl_ca = $mysql::ssl_ca,
|
||||
$ssl_cert = $mysql::ssl_cert,
|
||||
$ssl_key = $mysql::ssl_key,
|
||||
$log_error = $mysql::log_error,
|
||||
$default_engine = $mysql::default_engine,
|
||||
$root_group = $mysql::root_group,
|
||||
$restart = $mysql::restart,
|
||||
$purge_conf_dir = $mysql::purge_conf_dir,
|
||||
$key_buffer = $mysql::key_buffer,
|
||||
$max_allowed_packet = $mysql::max_allowed_packet,
|
||||
$thread_stack = $mysql::thread_stack,
|
||||
$thread_cache_size = $mysql::thread_cache_size,
|
||||
$myisam_recover = $mysql::myisam_recover,
|
||||
$query_cache_limit = $mysql::query_cache_limit,
|
||||
$query_cache_size = $mysql::query_cache_size,
|
||||
$max_binlog_size = $mysql::max_binlog_size,
|
||||
$expire_logs_days = $mysql::expire_logs_days,
|
||||
$max_connections = $mysql::max_connections,
|
||||
$tmp_table_size = 'UNSET',
|
||||
$max_heap_table_size = 'UNSET',
|
||||
$table_open_cache = 'UNSET',
|
||||
$long_query_time = 'UNSET',
|
||||
$character_set = 'UNSET',
|
||||
$server_id = 'UNSET',
|
||||
$sql_log_bin = 'UNSET',
|
||||
$log_bin = 'UNSET',
|
||||
$binlog_do_db = 'UNSET',
|
||||
$log_bin_trust_function_creators = 'UNSET',
|
||||
$replicate_ignore_table = 'UNSET',
|
||||
$replicate_wild_do_table = 'UNSET',
|
||||
$replicate_wild_ignore_table = 'UNSET'
|
||||
) inherits mysql {
|
||||
|
||||
File {
|
||||
owner => 'root',
|
||||
group => $root_group,
|
||||
mode => '0400',
|
||||
notify => $restart ? {
|
||||
true => Exec['mysqld-restart'],
|
||||
notify => $restart ? {
|
||||
true => Exec['mysqld-restart'],
|
||||
false => undef,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -26,6 +26,14 @@ class mysql::params {
|
|||
$root_password = 'UNSET'
|
||||
$restart = true
|
||||
$ssl = false
|
||||
$key_buffer = '16M'
|
||||
$thread_stack = '256K'
|
||||
$thread_cache_size = 8
|
||||
$myisam_recover = 'BACKUP'
|
||||
$query_cache_limit = '1M'
|
||||
$query_cache_size = '16M'
|
||||
$expire_logs_days = 10
|
||||
$max_binlog_size = 100M
|
||||
|
||||
case $::operatingsystem {
|
||||
'Ubuntu': {
|
||||
|
|
|
@ -3,16 +3,37 @@ describe 'mysql::config' do
|
|||
|
||||
let :constant_parameter_defaults do
|
||||
{
|
||||
:root_password => 'UNSET',
|
||||
:old_root_password => '',
|
||||
:max_connections => '151',
|
||||
:bind_address => '127.0.0.1',
|
||||
:port => '3306',
|
||||
:max_allowed_packet => '16M',
|
||||
:etc_root_password => false,
|
||||
:datadir => '/var/lib/mysql',
|
||||
:default_engine => 'UNSET',
|
||||
:ssl => false,
|
||||
:root_password => 'UNSET',
|
||||
:old_root_password => '',
|
||||
:max_connections => '151',
|
||||
:bind_address => '127.0.0.1',
|
||||
:port => '3306',
|
||||
:etc_root_password => false,
|
||||
:datadir => '/var/lib/mysql',
|
||||
:default_engine => 'UNSET',
|
||||
:ssl => false,
|
||||
:key_buffer => '16M',
|
||||
:max_allowed_packet => '16M',
|
||||
:thread_stack => '256K',
|
||||
:thread_cache_size => 8,
|
||||
:myisam_recover => 'BACKUP',
|
||||
:query_cache_limit => '1M',
|
||||
:query_cache_size => '16M',
|
||||
:max_binlog_size => '100M',
|
||||
:expire_logs_days => 10,
|
||||
:character_set => 'UNSET',
|
||||
:tmp_table_size => 'UNSET',
|
||||
:max_heap_table_size => 'UNSET',
|
||||
:table_open_cache => 'UNSET',
|
||||
:long_query_time => 'UNSET',
|
||||
:server_id => 'UNSET',
|
||||
:sql_log_bin => 'UNSET',
|
||||
:log_bin => 'UNSET',
|
||||
:binlog_do_db => 'UNSET',
|
||||
:log_bin_trust_function_creators => 'UNSET',
|
||||
:replicate_ignore_table => 'UNSET',
|
||||
:replicate_wild_do_table => 'UNSET',
|
||||
:replicate_wild_ignore_table => 'UNSET'
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -110,20 +131,29 @@ describe 'mysql::config' do
|
|||
[
|
||||
{},
|
||||
{
|
||||
:service_name => 'dans_service',
|
||||
:config_file => '/home/dan/mysql.conf',
|
||||
:service_name => 'dans_mysql',
|
||||
:pidfile => '/home/dan/mysql.pid',
|
||||
:socket => '/home/dan/mysql.sock',
|
||||
:bind_address => '0.0.0.0',
|
||||
:port => '3306',
|
||||
:max_allowed_packet => '32M',
|
||||
:datadir => '/path/to/datadir',
|
||||
:default_engine => 'InnoDB',
|
||||
:ssl => true,
|
||||
:ssl_ca => '/path/to/cacert.pem',
|
||||
:ssl_cert => '/path/to/server-cert.pem',
|
||||
:ssl_key => '/path/to/server-key.pem'
|
||||
:service_name => 'dans_service',
|
||||
:config_file => '/home/dan/mysql.conf',
|
||||
:service_name => 'dans_mysql',
|
||||
:pidfile => '/home/dan/mysql.pid',
|
||||
:socket => '/home/dan/mysql.sock',
|
||||
:bind_address => '0.0.0.0',
|
||||
:port => '3306',
|
||||
:datadir => '/path/to/datadir',
|
||||
:default_engine => 'InnoDB',
|
||||
:ssl => true,
|
||||
:ssl_ca => '/path/to/cacert.pem',
|
||||
:ssl_cert => '/path/to/server-cert.pem',
|
||||
:ssl_key => '/path/to/server-key.pem',
|
||||
:key_buffer => '16M',
|
||||
:max_allowed_packet => '32M',
|
||||
:thread_stack => '256K',
|
||||
:query_cache_size => '16M',
|
||||
:character_set => 'utf8',
|
||||
:max_connections => 1000,
|
||||
:tmp_table_size => '4096M',
|
||||
:max_heap_table_size => '4096M',
|
||||
:table_open_cache => 2048,
|
||||
:long_query_time => 0.5
|
||||
}
|
||||
].each do |passed_params|
|
||||
|
||||
|
@ -174,19 +204,63 @@ describe 'mysql::config' do
|
|||
it 'should have a template with the correct contents' do
|
||||
content = param_value(subject, 'file', param_values[:config_file], 'content')
|
||||
expected_lines = [
|
||||
"port = #{param_values[:port]}",
|
||||
"port = #{param_values[:port]}",
|
||||
"socket = #{param_values[:socket]}",
|
||||
"pid-file = #{param_values[:pidfile]}",
|
||||
"datadir = #{param_values[:datadir]}",
|
||||
"max_connections = #{param_values[:max_connections]}",
|
||||
"bind-address = #{param_values[:bind_address]}",
|
||||
"max_allowed_packet = #{param_values[:max_allowed_packet]}"
|
||||
"bind-address = #{param_values[:bind_address]}",
|
||||
"key_buffer = #{param_values[:key_buffer]}",
|
||||
"max_allowed_packet = #{param_values[:max_allowed_packet]}",
|
||||
"thread_stack = #{param_values[:thread_stack]}",
|
||||
"thread_cache_size = #{param_values[:thread_cache_size]}",
|
||||
"myisam-recover = #{param_values[:myisam_recover]}",
|
||||
"query_cache_limit = #{param_values[:query_cache_limit]}",
|
||||
"query_cache_size = #{param_values[:query_cache_size]}",
|
||||
"expire_logs_days = #{param_values[:expire_logs_days]}",
|
||||
"max_binlog_size = #{param_values[:max_binlog_size]}"
|
||||
]
|
||||
if param_values[:tmp_table_size] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "tmp_table_size = #{param_values[:tmp_table_size]}" ]
|
||||
end
|
||||
if param_values[:max_heap_table_size] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "max_heap_table_size = #{param_values[:max_heap_table_size]}" ]
|
||||
end
|
||||
if param_values[:table_open_cache] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "table_open_cache = #{param_values[:table_open_cache]}" ]
|
||||
end
|
||||
if param_values[:long_query_time] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "long_query_time = #{param_values[:long_query_time]}" ]
|
||||
end
|
||||
if param_values[:default_engine] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "default-storage-engine = #{param_values[:default_engine]}" ]
|
||||
else
|
||||
content.should_not match(/^default-storage-engine = /)
|
||||
end
|
||||
if param_values[:character_set] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "character-set-server = #{param_values[:character_set]}" ]
|
||||
end
|
||||
if param_values[:sql_log_bin] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "sql_log_bin = #{param_values[:sql_log_bin]}" ]
|
||||
end
|
||||
if param_values[:log_bin] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "log-bin = #{param_values[:log_bin]}" ]
|
||||
end
|
||||
if param_values[:binlog_do_db] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "binlog-do-db = #{param_values[:binlog_do_db]}" ]
|
||||
end
|
||||
if param_values[:log_bin_trust_function_creators] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "log_bin_trust_function_creators = #{param_values[:log_bin_trust_function_creators]}" ]
|
||||
end
|
||||
if param_values[:replicate_ignore_table] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "replicate-ignore-table = #{param_values[:replicate_ignore_table]}" ]
|
||||
end
|
||||
if param_values[:replicate_wild_do_table] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "replicate-wild-do-table = #{param_values[:replicate_wild_do_table]}" ]
|
||||
end
|
||||
if param_values[:replicate_wild_ignore_table] != 'UNSET'
|
||||
expected_lines = expected_lines | [ "replicate-wild-ignore-table = #{param_values[:replicate_wild_ignore_table]}" ]
|
||||
end
|
||||
if param_values[:ssl]
|
||||
expected_lines = expected_lines |
|
||||
[
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
[client]
|
||||
port = <%= @port %>
|
||||
port = <%= @port %>
|
||||
socket = <%= @socket %>
|
||||
<% if @character_set != 'UNSET' -%>
|
||||
default-character-set = <%= @character_set %>
|
||||
<% end -%>
|
||||
|
||||
[mysqld_safe]
|
||||
socket = <%= @socket %>
|
||||
nice = 0
|
||||
|
@ -18,30 +22,75 @@ tmpdir = <%= @tmpdir %>
|
|||
max_connections = <%= @max_connections %>
|
||||
skip-external-locking
|
||||
|
||||
<% if @bind_address %>
|
||||
bind-address = <%= @bind_address %>
|
||||
<% end %>
|
||||
|
||||
key_buffer = 16M
|
||||
max_allowed_packet = <%= @max_allowed_packet %>
|
||||
thread_stack = 192K
|
||||
thread_cache_size = 8
|
||||
myisam-recover = BACKUP
|
||||
query_cache_limit = 1M
|
||||
query_cache_size = 16M
|
||||
<% if @log_error != 'syslog' -%>
|
||||
log_error = <%= @log_error %>
|
||||
<% if @bind_address -%>
|
||||
bind-address = <%= @bind_address %>
|
||||
<% end -%>
|
||||
expire_logs_days = 10
|
||||
max_binlog_size = 100M
|
||||
key_buffer = <%= @key_buffer %>
|
||||
max_allowed_packet = <%= @max_allowed_packet %>
|
||||
thread_stack = <%= @thread_stack %>
|
||||
thread_cache_size = <%= @thread_cache_size %>
|
||||
myisam-recover = <%= @myisam_recover %>
|
||||
query_cache_limit = <%= @query_cache_limit %>
|
||||
query_cache_size = <%= @query_cache_size %>
|
||||
expire_logs_days = <%= @expire_logs_days %>
|
||||
max_binlog_size = <%= @max_binlog_size %>
|
||||
|
||||
<% if @max_connections != 'UNSET' -%>
|
||||
max_connections = <%= @max_connections %>
|
||||
<% end -%>
|
||||
<% if @tmp_table_size != 'UNSET' -%>
|
||||
tmp_table_size = <%= @tmp_table_size %>
|
||||
<% end -%>
|
||||
<% if @max_heap_table_size != 'UNSET' -%>
|
||||
max_heap_table_size = <%= @max_heap_table_size %>
|
||||
<% end -%>
|
||||
<% if @table_open_cache != 'UNSET' -%>
|
||||
table_open_cache = <%= @table_open_cache %>
|
||||
<% end -%>
|
||||
<% if @long_query_time != 'UNSET' -%>
|
||||
long_query_time = <%= @long_query_time %>
|
||||
<% end -%>
|
||||
<% if @server_id != 'UNSET' -%>
|
||||
server-id = <%= @server_id %>
|
||||
<% end -%>
|
||||
<% if @sql_log_bin != 'UNSET' -%>
|
||||
sql_log_bin = <%= @sql_log_bin %>
|
||||
<% end -%>
|
||||
<% if @log_bin != 'UNSET' -%>
|
||||
log-bin = <%= @log_bin %>
|
||||
<% end -%>
|
||||
<% if @binlog_do_db != 'UNSET' -%>
|
||||
binlog-do-db = <%= @binlog_do_db %>
|
||||
<% end -%>
|
||||
<% if @log_bin_trust_function_creators != 'UNSET' -%>
|
||||
log_bin_trust_function_creators = <%= @log_bin_trust_function_creators %>
|
||||
<% end -%>
|
||||
<% if @replicate_ignore_table != 'UNSET' -%>
|
||||
replicate-ignore-table = <%= @replicate_ignore_table %>
|
||||
<% end -%>
|
||||
<% if @replicate_wild_do_table != 'UNSET' -%>
|
||||
replicate-wild-do-table = <%= @replicate_wild_do_table %>
|
||||
<% end -%>
|
||||
<% if @replicate_wild_ignore_table != 'UNSET' -%>
|
||||
replicate-wild-ignore-table = <%= @replicate_wild_ignore_table %>
|
||||
<% end -%>
|
||||
|
||||
<% if @log_error != 'syslog' -%>
|
||||
log_error = <%= @log_error %>
|
||||
<% end -%>
|
||||
expire_logs_days = 10
|
||||
max_binlog_size = 100M
|
||||
<% if @default_engine != 'UNSET' %>
|
||||
default-storage-engine = <%= @default_engine %>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
<% if @character_set != 'UNSET' -%>
|
||||
character-set-server = <%= @character_set %>
|
||||
<% end -%>
|
||||
<% if @ssl == true %>
|
||||
ssl-ca = <%= @ssl_ca %>
|
||||
ssl-cert = <%= @ssl_cert %>
|
||||
ssl-key = <%= @ssl_key %>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
|
|
Loading…
Reference in a new issue