Jcrespo has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363195 )

Change subject: [WIP] Support multiple instances on the mariadb module
......................................................................

[WIP] Support multiple instances on the mariadb module

This is just a first idea that doesn't work yet, but could be
one of the ways to implement it.

The idea is to have a common mariadb::config, and then one
resouces mariadb::instance usage for each mysql run, with its own
datadir, tmpdir, port and socket. The custom config should include
the extra config files on /etc/mysql/mysqld.config.d and either
init.d or systemd (with mariadb@.service) should be able to
handle the different configs.

Many questions are still left about the details.

Bug: T169514
Change-Id: Ib313d12e6784700e0afaccd443acb181b7a0e1d4
---
A modules/mariadb/manifests/instance.pp
A modules/mariadb/templates/instance.cnf.erb
A modules/role/manifests/mariadb/dbstore3.pp
3 files changed, 98 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/95/363195/1

diff --git a/modules/mariadb/manifests/instance.pp 
b/modules/mariadb/manifests/instance.pp
new file mode 100644
index 0000000..ef6474b
--- /dev/null
+++ b/modules/mariadb/manifests/instance.pp
@@ -0,0 +1,39 @@
+# Setups additional instances for hosts that hosts more
+# than one instance
+define mariadb::instance(
+    $port,
+    $datadir = 'undefined',
+    $tmpdir  = 'undefined',
+    $socket  = 'undefined',
+) {
+    if $datadir == 'undefined' {
+        $datadir = "/srv/sqldata.${title}",
+    }
+    if $tmpdir == 'undefined' {
+        $tmpdir  = '/srv/tmp.${title}',
+    }
+    if $tmpdir == 'undefined' {
+        $socket  = '/run/mysqld/mysqld.${title}.sock',
+    }
+
+    file { $datadir:
+        ensure => directory,
+        owner  => 'mysql',
+        group  => 'mysql',
+        mode   => '0755',
+    }
+
+    file { $tmpdir:
+        ensure => directory,
+        owner  => 'mysql',
+        group  => 'mysql',
+        mode   => '0755',
+    }
+
+    file { "/etc/mysql/mysql.conf.d/${title}.cnf"
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0644',
+        content => template('mariadb/instance.cnf.erb'),
+    }
+}
diff --git a/modules/mariadb/templates/instance.cnf.erb 
b/modules/mariadb/templates/instance.cnf.erb
new file mode 100644
index 0000000..9aefd5f
--- /dev/null
+++ b/modules/mariadb/templates/instance.cnf.erb
@@ -0,0 +1,4 @@
+[mysqld@<%= @title %>]
+datadir=<%= @datadir %>
+socket=<%= @socket %>
+port=<%= @port %>
diff --git a/modules/role/manifests/mariadb/dbstore3.pp 
b/modules/role/manifests/mariadb/dbstore3.pp
new file mode 100644
index 0000000..f72f94d
--- /dev/null
+++ b/modules/role/manifests/mariadb/dbstore3.pp
@@ -0,0 +1,55 @@
+class role::mariadb::dbstore3 {
+    system::role { 'mariadb::core':
+        description => "DBStore multi-instance Server",
+    }
+
+    include ::standard
+    include ::base::firewall
+    include role::mariadb::monitor
+    #TODO: Custom firewall rules
+
+    #TODO: define one group per shard
+    class {'mariadb::groups':
+        mysql_group => 'dbstore',
+        mysql_shard => 's1',
+        mysql_role  => 'slave',
+        socket      => '/run/mysqld/mysqld.s1.sock',
+    }
+
+    class {'mariadb::packages_wmf': }
+    class {'mariadb::service':
+        # for now we will keep things simple, we probably should have a
+        # higher-level interface with templates
+        override => "[Service]\nLimitNOFILE=200000",
+    }
+
+    # Read only forced on also for the masters of the primary datacenter
+    class { 'mariadb::config':
+        config           => 'role/mariadb/mysqld_config/dbstore3.my.cnf.erb',
+        p_s              => 'on',
+        ssl              => 'puppet-cert',
+        binlog_format    => 'ROW',
+    }
+
+    mariadb::instance {'s1':
+        port => 3311,
+    }
+    mariadb::instance {'s2':
+        port => 3312,
+    }
+    mariadb::instance {'s3':
+        port => 3313,
+    }
+    mariadb::instance {'s4':
+        port => 3314,
+    }
+    mariadb::instance {'s5':
+        port => 3315,
+    }
+    mariadb::instance {'s6':
+        port => 3316,
+    }
+    mariadb::instance {'s7':
+        port => 3317,
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/363195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib313d12e6784700e0afaccd443acb181b7a0e1d4
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Jcrespo <jcre...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to