Defined Type: mariadb::instance

Defined in:
modules/mariadb/manifests/instance.pp

Overview

Setups additional instances for hosts that hosts more than one instance

  • port: Port where to run the instance (required)

  • datadir: datadir mysql config, by default /srv/sqldata.title

  • tmpdir: datadir mysql config, by default /srv/tmp.title

  • socket: socket mysql config, by default /run/mysqld/mysqld.title.sock

  • innodb_buffer_pool_size: config of the same name, it controls how much memory the instace uses. By default, or if it is configured as false, it is unconfigured, and it will default to the one on the common config template (or the mysql default, if not configured there). When configured, it must be passed as a string, such as '11G' or '10000000'.

  • is_critical: config flag to decide whether we page or not for this alert

  • mysqld_extra_config Hash of extra config key => value pairs to render in mysqld.conf.d/$title.cnf for this instance. Used by the default template config file mariadb/instance.cnf.erb. If you specify a different template, you can choose to use this if you like. Default: {}

Parameters:

  • port (Any)
  • datadir (Any) (defaults to: 'undefined')
  • tmpdir (Any) (defaults to: 'undefined')
  • socket (Any) (defaults to: 'undefined')
  • innodb_buffer_pool_size (Any) (defaults to: false)
  • template (Any) (defaults to: 'mariadb/instance.cnf.erb')
  • is_critical (Any) (defaults to: false)
  • read_only (Any) (defaults to: 1)
  • event_scheduler (Any) (defaults to: 1)
  • source_dc (Any) (defaults to: mediawiki::state('primary_dc'))
  • mysqld_extra_configs (Any) (defaults to: {})


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'modules/mariadb/manifests/instance.pp', line 18

define mariadb::instance(
    $port,
    $datadir = 'undefined',
    $tmpdir  = 'undefined',
    $socket  = 'undefined',
    $innodb_buffer_pool_size = false,
    $template = 'mariadb/instance.cnf.erb',
    $is_critical = false,
    $read_only = 1,
    $event_scheduler         = 1,
    $source_dc = mediawiki::state('primary_dc'),
    $mysqld_extra_configs = {},
) {
    if $datadir == 'undefined' {
        $datadir_instance = "/srv/sqldata.${title}"
    } else {
        $datadir_instance = $datadir
    }
    if $tmpdir == 'undefined' {
        $tmpdir_instance = "/srv/tmp.${title}"
    } else {
        $tmpdir_instance = $tmpdir
    }
    if $socket == 'undefined' {
        $socket_instance = "/run/mysqld/mysqld.${title}.sock"
    } else {
        $socket_instance = $socket
    }

    file { $datadir_instance:
        ensure => directory,
        owner  => 'mysql',
        group  => 'mysql',
        mode   => '0755',
    }

    file { $tmpdir_instance:
        ensure => directory,
        owner  => 'mysql',
        group  => 'mysql',
        mode   => '0755',
    }

    file { "/etc/mysql/mysqld.conf.d/${title}.cnf":
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        content => template($template),
    }

    mariadb::monitor_replication{ $title:
        socket      => $socket_instance,
        is_critical => $is_critical,
        source_dc   => $source_dc,
    }
    mariadb::monitor_readonly{ $title:
        port      => $port,
        read_only => $read_only,
    }

    file { "/usr/local/bin/mysql.${title}":
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        content => template('mariadb/mysql-section.sh.erb'),
    }
}