diff --git a/software/neoppod/instance-neo-storage-mysql.cfg.in b/software/neoppod/instance-neo-storage-mysql.cfg.in index 23208dff1e502309be208c3c3bdcf54c551ee219..c145619a1ceb64bc1725e2daae8a4fba8d4f8783 100644 --- a/software/neoppod/instance-neo-storage-mysql.cfg.in +++ b/software/neoppod/instance-neo-storage-mysql.cfg.in @@ -4,29 +4,38 @@ parts += neo-storage logrotate-storage -[mariadb-instance] -recipe = slapos.cookbook:generic.mysql -user = user -database = neo - -conf-file = ${directory:etc}/mariadb.cnf -# No networking (ip & port options) +[mysqld] +recipe = slapos.cookbook:generic.mysql.wrap_mysqld +output = ${directory:etc_run}/mariadb +binary = ${:mysql-base-directory}/bin/mysqld +configuration-file = ${my-cnf:rendered} data-directory = ${directory:srv_mariadb} -bin-directory = ${directory:bin} -pid-file = ${directory:var_run}/mariadb.pid +mysql-install-binary = ${:mysql-base-directory}/scripts/mysql_install_db +mysql-base-directory = {{ mariadb_location }} + +[my-cnf-parameters] socket = ${directory:var_run}/mariadb.sock +data-directory = ${mysqld:data-directory} +pid-file = ${directory:var_run}/mariadb.pid error-log = ${directory:log}/mariadb_error.log slow-query-log = ${directory:log}/mariadb_slowquery.log +long-query-time = {{ dumps(slapparameter_dict.get('long-query-time', 1)) }} +relaxed-writes = {{ dumps(slapparameter_dict.get('relaxed-writes', False)) }} +init-file = ${init-script:rendered} -wrapper = ${directory:etc_run}/mariadb -update-wrapper = ${directory:etc_run}/mariadb_update -mysql-base-directory = {{ mariadb_location }} -mysql-binary = {{ mariadb_location }}/bin/mysql -mysql-install-binary = {{ mariadb_location }}/scripts/mysql_install_db -mysql-upgrade-binary = {{ mariadb_location }}/bin/mysql_upgrade -mysqld-binary = {{ mariadb_location }}/bin/mysqld +[my-cnf] +recipe = slapos.recipe.template:jinja2 +rendered = ${directory:etc}/mariadb.cnf +template = {{ template_my_cnf }} +context = section parameter_dict my-cnf-parameters -mroonga = +[init-script] +recipe = slapos.recipe.template:jinja2 +# XXX: is there a better location ? +rendered = ${directory:etc}/mariadb_initial_setup.sql +database = neo +template = inline: + CREATE DATABASE IF NOT EXISTS ${:database}; [neo-storage] recipe = slapos.cookbook:neoppod.storage @@ -37,7 +46,7 @@ ip = {{ (ipv4_set | list)[0] }} cluster = {{ dumps(slapparameter_dict['cluster']) }} masters = {{ dumps(slapparameter_dict.get('masters', '')) }} database-adapter = MySQL -database-parameters = ${mariadb-instance:user}:${mariadb-instance:password}@${mariadb-instance:database}${mariadb-instance:socket} +database-parameters = root@${init-script:database}${my-cnf-parameters:socket} wait-database = 60 [directory] diff --git a/software/neoppod/instance.cfg.in b/software/neoppod/instance.cfg.in index 825ef6870d4f542a8c9df149f5ce5929e5fbc769..8318b480c17ff3c6ff07bcd8749443c519eaf4d2 100644 --- a/software/neoppod/instance.cfg.in +++ b/software/neoppod/instance.cfg.in @@ -46,6 +46,7 @@ template = {{ neo_storage_mysql }} extra-context = key master_cfg neo-master:rendered raw mariadb_location {{ mariadb_location }} + raw template_my_cnf {{ template_my_cnf }} [switch-softwaretype] recipe = slapos.cookbook:switch-softwaretype diff --git a/software/neoppod/my.cnf.in b/software/neoppod/my.cnf.in new file mode 100644 index 0000000000000000000000000000000000000000..c6368301ad80bd6966e79aa156747abc6d67a167 --- /dev/null +++ b/software/neoppod/my.cnf.in @@ -0,0 +1,38 @@ +{% set socket = parameter_dict['socket'] -%} +[mysqld] +skip_networking +socket = {{ socket }} +datadir = {{ parameter_dict['data-directory'] }} +pid_file = {{ parameter_dict['pid-file'] }} +log_error = {{ parameter_dict['error-log'] }} +slow_query_log +slow_query_log_file = {{ parameter_dict['slow-query-log'] }} +long_query_time = {{ parameter_dict['long-query-time'] }} + +init_file = {{ parameter_dict['init-file'] }} +log_warnings = 1 +disable-log-bin + +## The following settings come from ERP5 configuration. + +max_allowed_packet = 128M +query_cache_size = 32M +innodb_file_per_table = 0 +innodb_locks_unsafe_for_binlog = 1 + +# Some dangerous settings you may want to uncomment temporarily +# if you only want performance or less disk access. +{% set x = '' if parameter_dict['relaxed-writes'] else '#' -%} +{{x}}innodb_flush_log_at_trx_commit = 0 +{{x}}innodb_flush_method = nosync +{{x}}innodb_doublewrite = 0 +{{x}}sync_frm = 0 + +# Force utf8 usage +collation_server = utf8_unicode_ci +character_set_server = utf8 +skip_character_set_client_handshake + +[client] +socket = {{ socket }} +user = root diff --git a/software/neoppod/software.cfg b/software/neoppod/software.cfg index 6892c97a64f6dba389745eb54be7b26f32095e69..fdf6060bafd5d6610c459e9d9704db31c30afbd0 100644 --- a/software/neoppod/software.cfg +++ b/software/neoppod/software.cfg @@ -49,12 +49,17 @@ md5sum = 25724ba46203c57b680976dbe4ba67b7 [instance-neo-storage-mysql] < = cluster -md5sum = 1117184530207258b194e27dbe724cd5 +md5sum = 3fcf0e6146c62421f45fe9b3aeeb5cf5 + +[template-my-cnf] +recipe = slapos.recipe.build:download +url = ${:_profile_base_location_}/my.cnf.in +md5sum = 38b4eb7225f9b7c18875b4d2ab398278 [template] recipe = slapos.recipe.template:jinja2 template = ${:_profile_base_location_}/instance.cfg.in -md5sum = c7147d7c09294385b4995f6480fd976e +md5sum = fadc905aa50375e89cd3871741ad3507 # XXX: "template.cfg" is hardcoded in instanciation recipe rendered = ${buildout:directory}/template.cfg context = @@ -66,6 +71,7 @@ context = key neo_master instance-neo-master:target key neo_storage_mysql instance-neo-storage-mysql:target key mariadb_location mariadb:location + key template_my_cnf template-my-cnf:target key logrotate_base template-logrotate-base:rendered [neoppod]