From 18c4be016d0e1a28a5778256a5ec73cc498a1946 Mon Sep 17 00:00:00 2001 From: rbensley Date: Tue, 15 May 2018 15:31:58 +0100 Subject: [PATCH 1/2] New README, with new instructions. V2 focuses on mariadb and the socket auth plugin. --- README.md | 114 +++++++++++------- configs/acid.cnf | 7 ++ .../client-settings => configs/client.cnf | 4 +- mim.ss | 23 ++++ sql/secure-permissions.sql | 6 - templates/common-settings | 27 ----- templates/galera-example | 37 ------ templates/galera-n1 | 3 - templates/galera-n2 | 3 - templates/galera-n3 | 3 - templates/laptop-ssd-friendly | 11 -- templates/mariadb10 | 13 -- templates/olap | 11 -- templates/oltp-acid-transactional | 14 --- templates/utf8-settings | 10 -- 15 files changed, 105 insertions(+), 181 deletions(-) create mode 100644 configs/acid.cnf rename templates/client-settings => configs/client.cnf (56%) create mode 100755 mim.ss delete mode 100644 sql/secure-permissions.sql delete mode 100644 templates/common-settings delete mode 100644 templates/galera-example delete mode 100644 templates/galera-n1 delete mode 100644 templates/galera-n2 delete mode 100644 templates/galera-n3 delete mode 100644 templates/laptop-ssd-friendly delete mode 100644 templates/mariadb10 delete mode 100644 templates/olap delete mode 100644 templates/oltp-acid-transactional delete mode 100644 templates/utf8-settings diff --git a/README.md b/README.md index 6c8a5b6..62d680a 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,88 @@ -## MIM - Mini MySQL/MariaDB Instance Manager +# MIM, MariaDB Instance Manager +## Create and Manage mulitple MariaDB servers running in a single environment. == -mim is a single bash script ('my') to build and manage local installations of MySQL or MariaDB for development and testing. +## Up and running +Put mim in your PATH, or run ```make install```. -### Install - -* Put the 'my' bash script into a directory in your path, I tend to use ~/bin -* Create a directory to contain the binary tar.gz files for you platform. I.e. ~/mim-binaries -* Create a directory to contain the database installations. I.e. ~/mim-databases -* Export these directories as a the relevant variable in your bash profile: +Create a home for MIM, somewhere to keep data and binaries for our MariaDB installations. ```bash -export MIMBINARIES=~/mim-binaries -export MIMHOME=~/mim-databases +mkdir -p ${HOME}/mim/base ${HOME}/mim/data ${HOME}mim/data/configs +export MIMHOME=${HOME}/mim ``` +The configs directory can contain extra mysqld settings you wish to use when creating an instance. -* With 'my' now in your path, run 'my setup', this will create directories in $MIMHOME -* Copy the configs from example_configs to $MIMHOME/templates - - - - -### Create your first instance -* Put a binary package of MySQL or MariaDB in $MIMBINARIES: +Secure it! Just for your user. ```bash -$ cp ~/Downloads/mariadb-5.5.35-linux-x86_64.tar.gz $MIMBINARIES/ -$ cp ~/Downloads/mysql-5.5.35-linux-x86_64.tar.gz $MIMBINARIES/ +chmod -R 700 ${MIMHOME} ``` -* Create a config, we will call it master1 to run on port 3000, select options such as config and version as appropiate: -```bash -$ my build master1 3000 -``` -* If the above went smoothly, then you have installed MIM correctly, now install the instance: -```bash -$ my install master1 -``` -* Start the instance: -```bash -$ my start master1 -``` -* Print aliases for your configured instances, to easily access them: +Download a MariaDB Tarball to mim/base: ```bash -$ my aliases +DOWNLOAD_URL="https://downloads.mariadb.org/interstitial/mariadb-10.2.14/bintar-linux-x86_64/mariadb-10.2.14-linux-x86_64.tar.gz" +cd $MIMHOME/base && curl -L -O ${DOWNLOAD_URL} ``` -* Generate a PATH and LD_LIBRARY_PATH variables for the desired instance: -```bash -$ my client master1 + +Create a basic config for custom options ``` + echo -e "[mysqld]\nsql_mode = TRADITIONAL\nsync_binlog = 1" > ${MIMHOME}/configs/simple.cnf + ``` + +We are now ready to create an instance, or two, or twelve! + +Build and install the instance. +```mim build master1 3000``` +```mim install master1``` + +Building creates a config and directories in ```${MIMHOME}/data/master1```. +The install command has extracted the Tarball in ```${MIMHOME}/base```, and used the config and directories created by the build command to run mysql_install_db in ```${MIMHOME}/data/master1```. -### TODO - * MySQL 5.6+ and MariaDB 10+ GTID management for testing failover. - * Client path switching - * Library path switching for building C/C++ projects like ODBC connectors. - * ... better documentation. +Start the database server. +```mim start master1``` +Is it running? +```mim status master1``` +Login! +```mim go master1``` + + +## Extras +Secure the instance, similar to mysql_secure_installation: +```mim secure master1``` + +Add timezones from your system: +```mim tz master1``` + +Generate aliases for your shell: +```mim alias master1``` + +## Using a custom config + + + +## FAQ + +* Why not mysqlsandbox ? +Mim focuses only on MariaDB. There are some handy features which make + +* Why Scheme? +It's cool! + +* What about replication tooling? +Look else where traveller. + +* Can I use this in production? +Sure. Like any production database, you will still need monitoring and alerting, not provided by mim. +Mim's goal is to simply configure, start, stop multiple instances on a single server. +Unlike the default scripts used for init.d or systemd, there is no guessing or testing for empty/unset variables, Mim specifcally sets everything we need start a database server and it's relevant logging. + + +* Why not just use docker, kubernetes, etc. +Not all of us are using Linux (some of us are using jails and zones). +The main advantage of mim, is to not introduce anything too crazy or different to any environment. +Mim is a single file command line tool, which requires some directories with appropriate permissions. +Introducing new YUM or APT repositories into a managed environemnt can be a political and security minefield. + +== _R.I.P mysqlmanager_ diff --git a/configs/acid.cnf b/configs/acid.cnf new file mode 100644 index 0000000..d5f1a48 --- /dev/null +++ b/configs/acid.cnf @@ -0,0 +1,7 @@ +[mysqld] +local_infile = 1 +character_set_server = utf8 +init-connect = 'SET NAMES utf8' +collation_server = utf8_general_ci +sync_binlog = 1 +sql_mode = STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY diff --git a/templates/client-settings b/configs/client.cnf similarity index 56% rename from templates/client-settings rename to configs/client.cnf index 5bf0ab6..5f1a0e4 100644 --- a/templates/client-settings +++ b/configs/client.cnf @@ -1,8 +1,10 @@ [client] show-warnings +default-character-set = utf8 [mysql] show-warnings +default-character-set = utf8 [mysqldump] quick @@ -10,4 +12,4 @@ events comments routines triggers -single-transaction +single-transaction \ No newline at end of file diff --git a/mim.ss b/mim.ss new file mode 100755 index 0000000..d98bea2 --- /dev/null +++ b/mim.ss @@ -0,0 +1,23 @@ + +(define config) + + +(define build) + +(define install) + +(define start) + +(define stop) + +(define kill) + +(define status) + +(define secure) +; DROP DATABASE IF EXISTS test; +; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; +; DELETE FROM mysql.user WHERE user = ''; +; DELETE FROM mysql.user WHERE password = ''; +; DELETE FROM mysql.user WHERE user = 'root' AND host NOT IN ('localhost','127.0.0.1','::1'); +; FLUSH PRIVILEGES; diff --git a/sql/secure-permissions.sql b/sql/secure-permissions.sql deleted file mode 100644 index 25ba178..0000000 --- a/sql/secure-permissions.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP DATABASE IF EXISTS test; -DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; -DELETE FROM mysql.user WHERE user = ''; -DELETE FROM mysql.user WHERE password = ''; -DELETE FROM mysql.user WHERE user = 'root' AND host NOT IN ('localhost','127.0.0.1','::1'); -FLUSH PRIVILEGES; \ No newline at end of file diff --git a/templates/common-settings b/templates/common-settings deleted file mode 100644 index df03808..0000000 --- a/templates/common-settings +++ /dev/null @@ -1,27 +0,0 @@ -[mysqld] -tmpdir = /tmp -max_connect_errors = 1000000 -max_connections = 1000 -default-time-zone = '+00:00' -skip-name-resolve -skip-slave-start -query_cache_size = 0 -query_cache_type = 0 -local_infile = 1 -default_storage_engine = InnoDB -storage_engine = InnoDB -innodb_file_format = Barracuda -innodb_file_per_table = 1 - -## -## Disk Usage settings -## -innodb_log_file_size = 128M -innodb_log_files_in_group = 2 - -## -## RAM usage -## -key_buffer_size = 32M # MyISAM and Aria -innodb_buffer_pool_size = 32M -innodb_buffer_pool_instances = 4 diff --git a/templates/galera-example b/templates/galera-example deleted file mode 100644 index 3ef598b..0000000 --- a/templates/galera-example +++ /dev/null @@ -1,37 +0,0 @@ -[mysqld] -wsrep_auto_increment_control = ON -wsrep_causal_reads = OFF -wsrep_certify_nonpk = ON -wsrep_cluster_address = "gcom://127.0.0.1:3021,127.0.0.1:3022,127.0.0.1:3023" -wsrep_cluster_name = mim_galera_cluster -wsrep_convert_lock_to_trx = OFF -#wsrep_data_home_dir = # defaults to datadir -#wsrep_dbug_option = # dynamic -wsrep_debug = OFF -wsrep_desync = OFF -wsrep_drupal_282555_workaround = OFF -wsrep_forced_binlog_format = NONE -wsrep_load_data_splitting = ON -wsrep_log_conflicts = OFF -wsrep_max_ws_rows = 131072 -wsrep_max_ws_size = 1073741824 -wsrep_mysql_replication_bundle = 0 -wsrep_node_incoming_address = AUTO -#wsrep_notify_cmd = -wsrep_on = ON -wsrep_osu_method = TOI -wsrep_provider = none -wsrep_provider_options = -wsrep_recover = OFF -wsrep_replicate_myisam = OFF -wsrep_restart_slave = OFF -wsrep_retry_autocommit = 1 -wsrep_slave_fk_checks = ON -wsrep_slave_threads = 1 -wsrep_slave_uk_checks = OFF -#wsrep_sst_auth = username:password # masked in logs and 'SHOW VARIABLES' -#wsrep_sst_donor = 127.0.0.1:3024,127.0.0.1:3025 -wsrep_sst_donor_rejects_queries = OFF -wsrep_sst_method = rsync -wsrep_sst_receive_address = AUTO -wsrep_start_position = 00000000-0000-0000-0000-000000000000:-1 diff --git a/templates/galera-n1 b/templates/galera-n1 deleted file mode 100644 index d8ae7a4..0000000 --- a/templates/galera-n1 +++ /dev/null @@ -1,3 +0,0 @@ -[mysqld] -wsrep_node_address = 127.0.0.1:3021 -wsrep_node_name = n1 diff --git a/templates/galera-n2 b/templates/galera-n2 deleted file mode 100644 index 2cfcc61..0000000 --- a/templates/galera-n2 +++ /dev/null @@ -1,3 +0,0 @@ -[mysqld] -wsrep_node_address = 127.0.0.1:3022 -wsrep_node_name = n2 diff --git a/templates/galera-n3 b/templates/galera-n3 deleted file mode 100644 index a682422..0000000 --- a/templates/galera-n3 +++ /dev/null @@ -1,3 +0,0 @@ -[mysqld] -wsrep_node_address = 127.0.0.1:3023 -wsrep_node_name = n3 diff --git a/templates/laptop-ssd-friendly b/templates/laptop-ssd-friendly deleted file mode 100644 index 64af12f..0000000 --- a/templates/laptop-ssd-friendly +++ /dev/null @@ -1,11 +0,0 @@ -[mysqld] -performance_schema = 0 -binlog_format = STATEMENT -sql_mode = NO_ENGINE_SUBSTITUTION -innodb_flush_log_at_trx_commit = 0 -innodb_doublewrite = 0 -innodb_strict_mode = 0 -innodb_support_xa = 0 -innodb_checksums = 0 -sync_binlog = 0 -sync_frm = 0 diff --git a/templates/mariadb10 b/templates/mariadb10 deleted file mode 100644 index 7b761d6..0000000 --- a/templates/mariadb10 +++ /dev/null @@ -1,13 +0,0 @@ -# INSTALL PLUGIN server_audit SONAME 'server_audit'; -# INSTALL PLUGIN CONNECT SONAME 'ha_connect'; -# INSTALL PLUGIN SQL_ERROR_LOG SONAME 'sql_errlog'; -# INSTALL PLUGIN SEQUENCE SONAME 'ha_sequence'; - -[mysqld] -binlog_annotate_row_events = 1 -userstat = 1 -use_stat_tables = never -log_slow_verbosity = Query_plan,explain -slave_parallel_threads = 0 - -##slave_run_triggers_for_rbr diff --git a/templates/olap b/templates/olap deleted file mode 100644 index ca63ee9..0000000 --- a/templates/olap +++ /dev/null @@ -1,11 +0,0 @@ -[mysqld] -performance_schema = 1 -binlog_format = MIXED -sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES -innodb_flush_log_at_trx_commit = 0 -innodb_doublewrite = 0 -innodb_strict_mode = 1 -innodb_support_xa = 1 -innodb_checksums = 1 -sync_binlog = 0 -sync_frm = 0 diff --git a/templates/oltp-acid-transactional b/templates/oltp-acid-transactional deleted file mode 100644 index bdefaa3..0000000 --- a/templates/oltp-acid-transactional +++ /dev/null @@ -1,14 +0,0 @@ -[mysqld] -performance_schema = 0 -binlog_format = ROW -sql_mode = TRADITIONAL -innodb_flush_log_at_trx_commit = 1 -innodb_flush_method = O_DIRECT -innodb_doublewrite = 1 -innodb_strict_mode = 1 -innodb_purge_threads = 1 -innodb_checksums = 1 -sync_binlog = 1 -sync_relay_log = 1 -sync_relay_log_info = 1 -sync_master_info = 1 diff --git a/templates/utf8-settings b/templates/utf8-settings deleted file mode 100644 index c87433b..0000000 --- a/templates/utf8-settings +++ /dev/null @@ -1,10 +0,0 @@ -[client] -default-character-set = utf8 - -[mysql] -default-character-set = utf8 - -[mysqld] -character-set-server = utf8 -init-connect = 'SET NAMES utf8' -collation-server = utf8_general_ci From f6f7b3a3f0fdf00331b97d766e0895d9cd4ad1b2 Mon Sep 17 00:00:00 2001 From: rbensley Date: Mon, 21 May 2018 10:55:42 +0100 Subject: [PATCH 2/2] Lisp. --- Makefile | 3 ++ README.md | 47 ++++++++++++++++++------------- configs/{acid.cnf => default.cnf} | 0 mim.ss => mim.lisp | 18 ++++++------ 4 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 Makefile rename configs/{acid.cnf => default.cnf} (100%) rename mim.ss => mim.lisp (67%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de775fc --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +# Make MIM! +# Make guile and chez (scheme) options. +# Make test. diff --git a/README.md b/README.md index 62d680a..7848172 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # MIM, MariaDB Instance Manager -## Create and Manage mulitple MariaDB servers running in a single environment. +## Create and Manage mulitple MariaDB servers running on a single environment. == ## Up and running @@ -57,32 +57,39 @@ Add timezones from your system: Generate aliases for your shell: ```mim alias master1``` -## Using a custom config - - - ## FAQ +* What does Mim do again? +Configure, start, and stop multiple MariaDB databases on a single server. -* Why not mysqlsandbox ? -Mim focuses only on MariaDB. There are some handy features which make +* Why not mysqlsandbox? +Mim focuses only on MariaDB, and abuses a few MariaDB features like 'SHUTDOWN' and socket authentication. -* Why Scheme? -It's cool! +* Why not mysqlmanager? +It's dead Jim. -* What about replication tooling? -Look else where traveller. +* Why not docker, kubernetes, etc. +Not all of us are using Linux. +Not all of us are floating in the clouds. +Some of us are using jails, cgroups, zones, and even PowerVM. * Can I use this in production? Sure. Like any production database, you will still need monitoring and alerting, not provided by mim. -Mim's goal is to simply configure, start, stop multiple instances on a single server. -Unlike the default scripts used for init.d or systemd, there is no guessing or testing for empty/unset variables, Mim specifcally sets everything we need start a database server and it's relevant logging. +Mim has it's own log (```${MIMHOME}/log```), and of course each database instance has it's own mysqld error log file, e.g. ```${MIMHOME}/data/${INSTANCE_NAME}/error.log```. +* So Why Mim? +The main advantage of Mim, is to not introduce anything too crazy or different to any environment. +Mim is a single binary. +In some restricted production environments this is very useful. -* Why not just use docker, kubernetes, etc. -Not all of us are using Linux (some of us are using jails and zones). -The main advantage of mim, is to not introduce anything too crazy or different to any environment. -Mim is a single file command line tool, which requires some directories with appropriate permissions. -Introducing new YUM or APT repositories into a managed environemnt can be a political and security minefield. +* What did you use to write and compile mim? +Vim with lisp mode (```set lisp```), and sbcl. + +* What about replication tooling? +Look else where traveller. I will be taking a look at this in the future. + +# ToDo +* Replication management and monitoring interface? + * Multi-source replication. + * Galera? +* MariaDB ColumnStore management. -== -_R.I.P mysqlmanager_ diff --git a/configs/acid.cnf b/configs/default.cnf similarity index 100% rename from configs/acid.cnf rename to configs/default.cnf diff --git a/mim.ss b/mim.lisp similarity index 67% rename from mim.ss rename to mim.lisp index d98bea2..2f52187 100755 --- a/mim.ss +++ b/mim.lisp @@ -1,20 +1,20 @@ +#!/usr/bin/env sbcl --script -(define config) +(defun config) +(defun build) -(define build) +(defun install) -(define install) +(defun start) -(define start) +(defun stop) -(define stop) +(defun kill) -(define kill) +(defun status) -(define status) - -(define secure) +(defun secure) ; DROP DATABASE IF EXISTS test; ; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; ; DELETE FROM mysql.user WHERE user = '';