set innodb_file_per_table to ON for MySQL / Galera
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Jan 2017 17:13:29 +0000 (12:13 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 1 Feb 2017 21:12:13 +0000 (16:12 -0500)
InnoDB uses a single file by default which can grow to be
tens/hundreds of gigabytes, and is not shrinkable even
if data is deleted from the database.

Best practices are that innodb_file_per_table is set to ON
which instead stores each database table in its own file, each of
which is also shrinkable by the InnoDB engine.

Closes-Bug: #1660722
Change-Id: I59ee53f6462a2eeddad72b1d75c77a69322d5de4

manifests/profile/base/database/mysql.pp
manifests/profile/pacemaker/database/mysql.pp
releasenotes/notes/innodb_file_per_table-f925b3bbf29d44ea.yaml [new file with mode: 0644]

index 4ccfabc..d3c3f21 100644 (file)
@@ -119,13 +119,14 @@ class tripleo::profile::base::database::mysql (
     # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
     $mysql_server_default = {
       'mysqld' => {
-        'bind-address'     => $bind_address,
-        'max_connections'  => hiera('mysql_max_connections'),
-        'open_files_limit' => '-1',
-        'ssl'              => $enable_internal_tls,
-        'ssl-key'          => $tls_keyfile,
-        'ssl-cert'         => $tls_certfile,
-        'ssl-ca'           => undef,
+        'bind-address'          => $bind_address,
+        'max_connections'       => hiera('mysql_max_connections'),
+        'open_files_limit'      => '-1',
+        'innodb_file_per_table' => 'ON',
+        'ssl'                   => $enable_internal_tls,
+        'ssl-key'               => $tls_keyfile,
+        'ssl-cert'              => $tls_certfile,
+        'ssl-ca'                => undef,
       }
     }
     $mysql_server_options_real = deep_merge($mysql_server_default, $mysql_server_options)
index 6a83f10..ca9a1a8 100644 (file)
@@ -75,6 +75,7 @@ class tripleo::profile::pacemaker::database::mysql (
       'default-storage-engine'        => 'innodb',
       'innodb_autoinc_lock_mode'      => '2',
       'innodb_locks_unsafe_for_binlog'=> '1',
+      'innodb_file_per_table'         => 'ON',
       'query_cache_size'              => '0',
       'query_cache_type'              => '0',
       'bind-address'                  => $bind_address,
diff --git a/releasenotes/notes/innodb_file_per_table-f925b3bbf29d44ea.yaml b/releasenotes/notes/innodb_file_per_table-f925b3bbf29d44ea.yaml
new file mode 100644 (file)
index 0000000..e0b7c3c
--- /dev/null
@@ -0,0 +1,20 @@
+---
+features:
+  - Enable innodb_file_per_table for MySQL/MariaDB databases
+upgrade:
+  - |
+    Newly created MySQL database tables will be stored in their own datafiles,
+    instead of in a single monolithic ibdata file.
+  - |
+    Existing MySQL database tables that are persisted within the monolithic
+    ibdata file will remain so unless the database is migrated as well.
+  - |
+    Migration of all current database tables out of the monolithic ibdata
+    file is possible by dumping and restoring the whole database to a new data
+    directory, however when using Galera the entire cluster must be shut
+    down and upgraded at once.
+  - |
+    Migration of individual tables to datafiles is possible using the
+    MySQL command "ALTER TABLE <databasename>.<tablename> ENGINE=InnoDB;",
+    however this will not shrink the ibdata file and also is not safe to run
+    on a running Galera cluster for large tables.