Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Commit

Permalink
Added custom configurations for mysql server using vars
Browse files Browse the repository at this point in the history
  • Loading branch information
overdrive3000 committed Jun 6, 2014
1 parent 5315caf commit aa7312a
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
14 changes: 14 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
---
# Define root password for percona server
root_password: reallylongpassword

# Some defaults variables for percona server config file
port: 3306
bind_address: 0.0.0.0
max_allowed_packet: 16M
key_buffer: 16M
thread_stack: 192K
thread_cache_size: 8
# Uncomment following vars if you want to log queries
sqldebug: true
log_slow_queries: log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time: long_query_time = 2
log_queries_not_using_indexes: log-queries-not-using-indexes
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: restart percona
action: service name=mysql state=restarted
5 changes: 5 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@

- name: Create murmur_hash
command: /usr/bin/mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'" creates=/tmp/libmurmur_udf.so.done

- name: Write custom server configuration
template: src=my.cnf.j2 dest=/etc/mysql/my.cnf owner=root mode=0622
notify:
- restart percona
130 changes: 130 additions & 0 deletions templates/my.cnf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# NOTE: This file is automaticaly generated by Ansible
# please do not change any variable in this config file
# or will be override by ansible
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = {{ port }}
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = {{ port }}
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = {{ bind_address }}
#
# * Fine Tuning
#
key_buffer = {{ key_buffer }} # 16M
max_allowed_packet = {{ max_allowed_packet }} # 16M
thread_stack = {{ thread_stack }} # 192K
thread_cache_size = {{ thread_cache_size }} # 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
{% if sqldebug %}
{{ log_slow_queries }}
{{ long_query_time }}
{{ log_queries_not_using_indexes }}
{% endif -%}
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

0 comments on commit aa7312a

Please sign in to comment.