MariaDB is a fork of the MySQL codebase by founding developer Monty Widenius. Unlike MySQL which is now the property of Oracle Corporation (which is no bad thing if you like paying per seat and per cpu licence fees), MariaDB is true opensource and community led and should be to all intents and purposes 100% compatible with the same major version from MySQL.
Backup the datafiles in case you want to go back to mysql5.1:
$ sudo /etc/init.d/mysql stop
$ grep datadir /etc/mysql/my.cnf
datadir = /var/lib/mysql
$ cd /var/lib
$ mv mysql mysql5.1.bakSee what packages you have installed:
$ dpkg --get-selections | grep mysql
libdbd-mysql-perl install
libmysqlclient-dev install
libmysqlclient16 install
mysql-client-5.1 install
mysql-client-core-5.1 install
mysql-common install
mysql-server-5.1 install
mysql-server-core-5.1 install
mysql-workbench-gpl install
mysqltuner install
php5-mysql installPurge each of these packages from the system - being careful not to remove workbench (which I did first time round, sigh):
$ sudo apt-get purge mysql-server-5.1 libmysqlclient16 mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server-core-5.1 libdbd-mysql-perlAdd the ourdelta repository to your system and update your repo’s:
$ wget -O- http://ourdelta.org/deb/ourdelta.gpg | sudo apt-key add -
$ sudo wget http://ourdelta.org/deb/sources/lucid-mariadb-ourdelta.list \
-O /etc/apt/sources.list.d/ourdelta.list
$ sudo apt-get updateThen install mariadb and follow the onscreen instructions to set a root password:
$ sudo apt-get install mariadb-server-5.1Whilst its not a million miles away from mysql 5.1, a quick browse of the conf file at /etc/mysql/my.cnf has a few differences that we’ll investigate at a later date. For now we’ve made the following changes to support our work.
utf-8 - we support multiple languages in all our work so using utf-8 from the get go is useful. MariaDB defaults to latin-1, so uncomment the sections in the client and server sections:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8
…..
#
# * Character sets
#
# Default is Latin1, if you need UTF-8 set all this (also in client section)
#
default-character-set = utf8
default-collation = utf8_general_ci
character_set_server = utf8
collation_server = utf8_general_ciThe slow query log is useful for tuning performance - it logs all queries that take longer than ‘long_query_time’ to run. Its also negatively effects performance, so we tend to turn it off unless we need it. Its ok to leave the vars uncommented - for now although they probably use a tiny bit of memory at runtime.
‘log_slow_admin_statements’ is a new one on me, but according to the manual ‘Log slow administrative statements such as OPTIMIZE TABLE, ANALYZE TABLE, and ALTER TABLE to the slow query log.’ - which is quite unnecessary when we’re not tuning.
#
# Here you can see queries with especially long duration
#log_slow_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#log_slow_admin_statementsBinary logging is useful for replication and an online backup. Disable it in development, and beware of any performance impact in live.
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#report_host = master1
#auto_increment_increment = 2
#auto_increment_offset = 1
#log_bin = /var/log/mysql/mariadb-bin
#log_bin_index = /var/log/mysql/mariadb-bin.indexInnodb is set as the default storage engine, but this isn’t your fathers InnoDB, it's a highly optimised version called XtraDB from the MySQL performance consultancy Percona. Huzzah! Among other things XtraDB a direct binary replacement for InnoDB and you ‘should’ be able to use the same datafiles as MySQL if using the same major version. Theoretically we could have left the datafiles in place as we were moving from MySQL 5.1 to MariaDB 5.1. Its called InnoDB in the conf file, and InnoDB commands will work for compatibility.
A sign that this is a performance oriented distubution is that ‘O_DIRECT' is set by default. This stops the OS caching the filesystem as well as the storage engine. ‘innodb_file_per_table’ is also enabled by default which does exactly what it says on the tin. No changes required here until you know your app needs them through experimentation and testing - if you know you’re going to host many databases in live then at the very least increasing ‘innodb_open_files’ will be needed - but as this is for a desktop development drupal 7 environment, we can leave it for the time being.
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB
sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
# you can't just change log file size, requires special procedure
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECTOnce you’ve hacked away on the conf file, restart the server using the same commands you know and love:
$ sudo /etc/init.d/mysql restart
* Stopping MariaDB database server mysqld [ OK ]
* Starting MariaDB database server mysqld [ OK ]
* Checking for corrupt, not cleanly closed and upgrade needing tables.Once this is done you can use the same mysql command line as ever. You’ll know you’re getting some MariaDB love if you see a prompt like this:
$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 5.1.49-MariaDB-mariadb82 (MariaDB - http://mariadb.com/)
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> From here on in its just like being back in babies arms. Minus Larry Ellison breathing down your neck. Although i’d like to think he’s a nicer bedfellow than Steve Jobs, one can’t help but wonder at what point the rug will be pulled out from under MySQL.
So for Drupal 7, follow the install procedure and choose MariaDB on the install dialogue. Once i’ve had a play i’ll be sure to post some metrics and performance tweaks for a D7 install.

Add new comment