2014-10-23

Installing MySQL 5.6 with Galera on Ubuntu 14.04

Inspired by this horror story of an install, I've decided to see if there's a more elegant way of getting it done. I *think* I have it, but the root cause may make this fix moot.

The problem that needs to be addressed is that the dependencies listed in the .deb files provided by Codership for installing the patched mysql binaries and Galera don't line up properly with packages that you can install in Ubuntu. The version provided by Codership is based on MySQL 5.6.16, where as the repositories are up to 5.6.19. This particular problem isn't exactly unexpected due to the nature of what's being installed: A patch to MySQL.

Before you go any further, I must state the following: I have not analyzed the impact of this procedure with great depth. All I know is that initial testing indicates that there's no problem with it, but there is a reality that cannot be denied: There might be a version mis-match with some of the binary files. Until Codership delivers a version of mysql greater than 5.6.19, if you want to use the packaged version of this tool, this is the reality.

With this in mind, I set about trying to find a method of modifying the data baked into the .deb files for the prerequisites. Here's the install procedure I've used and appears to be successful. All of the following is based on a freshly installed copy of Ubuntu 14.04 and the salt-minion package, with all of its requirements.

First, you'll need to install the MySQL 5.6 packages from the Universe repo. If you don't have the Universe repo enabled, check here.

After you have Universe enabled, you can simply install the mysql 5.6 packages, along with the required libssl0.9.8 package:

sudo apt-get install mysql-server-5.6 mysql-client-5.6 libssl0.9.8
You'll need to download the required .deb files for installation. These are the latest as of this writing.

wget https://launchpad.net/galera/3.x/25.3.5/+download/galera-25.3.5-amd64.deb https://launchpad.net/codership-mysql/5.6/5.6.16-25.5/+download/mysql-server-wsrep-5.6.16-25.5-amd64.deb

I hope that Codership will patch and release soon so this entire writeup isn't necessary to be indexed by anyone. The listed milestones on Codership's launchpad seems to suggest that they're probably close to a release using MySQL 5.6.20, which WILL make this ugly hack unneeded.

I found this thread with a nifty little script in it that I'll paste here with some very minor modifications. Take the following and save it to disk.

#!/bin/bash

if [[ -z "$1" ]]; then
  echo "Syntax: $0 debfile"
  exit 1
fi

DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb

if [[ -e "$OUTPUT" ]]; then
  echo "$OUTPUT exists."
  rm -r "$TMPDIR"
  exit 1
fi

dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN

if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
  echo DEBIAN/control not found.

  rm -r "$TMPDIR"
  exit 1
fi

CONTROL="$TMPDIR"/DEBIAN/control

MOD=`stat -c "%y" "$CONTROL"`
"${FCEDIT:-${VISUAL:-${EDITOR:-vi}}}" "$CONTROL"

if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
  echo Not modfied.
else
  echo Building new deb...
  dpkg -b "$TMPDIR" "$OUTPUT"
fi

rm -r "$TMPDIR"
Take the above script and save it to a file. The referenced post suggested videbcontrol, so I'll go with that.

You'll need to execute it. The easiest thing to do is set the execute bit:

# chmod +x videbcontrol

When you run videbcontrol mysql-server-wsrep-5.6.16-25.5-amd64.deb you'll be presented with the following:

Package: mysql-server-wsrep
Version: 5.6.16-25.5
Maintainer: Codership Oy
Architecture: amd64
Description: wsrep-enabled MySQL server
 Copyright: MySQL AB, Codership Oy, All Rights Reserved
 MySQL server + wsrep patch (https://launchpad.net/codership-mysql)
Depends: psmisc, debianutils (>= 1.6), libc6 (>= 2.4), libdbi-perl, libdbd-mysql-perl (>= 1.2202), libgcc1 (>= 4.1.1), libncurses5 (>= 5.6), libstdc++6 (>= 4.1.1), libwrap0 (>= 7.6), perl, zlib1g (>= 1.1.4), libaio1, mysql-client
Replaces: mysql-server-core (<= 5.6.16), mysql-server-core-5.0 (<= 5.6.16), mysql-server-core-5.1 (<= 5.6.16), mysql-server (<= 5.6.16), mysql-server-5.0 (<= 5.6.16), mysql-server-5.1 (<= 5.6.16), mysql-server-5.6 (<= 5.6.16), mysql-server-5.5 (<= 5.6.16)
Provides: mysql-server-core, mysql-server, mysql-server-5.6
The finished product that you'll save looks like below. I've hilighted the changes and additions.

Package: mysql-server-wsrep
Version: 5.6.16-25.5
Maintainer: Codership Oy
Architecture: amd64
Description: wsrep-enabled MySQL server
 Copyright: MySQL AB, Codership Oy, All Rights Reserved
 MySQL server + wsrep patch (https://launchpad.net/codership-mysql)
Depends: psmisc, debianutils (>= 1.6), libc6 (>= 2.4), libdbi-perl, libdbd-mysql-perl (>= 1.2202), libgcc1 (>= 4.1.1), libncurses5 (>= 5.6), libstdc++6 (>= 4.1.1), libwrap0 (>= 7.6), perl, zlib1g (>= 1.1.4), libaio1, mysql-client-5.6, libssl0.9.8
Replaces: mysql-server-core (<= 5.6.16), mysql-server-core-5.0 (<= 5.6.16), mysql-server-core-5.1 (<= 5.6.16), mysql-server (<= 5.6.16), mysql-server-5.0 (<= 5.6.16), mysql-server-5.1 (<= 5.6.16), mysql-server-5.6 (<= 5.6.20), mysql-server-5.5 (<= 5.6.16), mysql-server-core-5.6 (<= 5.6.20)
Provides: mysql-server-core, mysql-server, mysql-server-5.6, mysql-server-core-5.6

When you save and exit your editor, videbcontrol will save a new file called mysql-server-wsrep-5.6.16-25.5-amd64.modified.deb

You can then install the two .deb packages without any carping. Be sure you install the modified mysql package.

sudo dpkg -i mysql-server-wsrep-5.6.16-25.5-amd64.modfied.deb
sudo dpkg -i galera-25.3.5-amd64.deb 
Modify /etc/mysql/conf.d/wsrep.cnf by inserting the following lines in the [mysqld] section:

wsrep_provider = /usr/lib/galera/libgalera_smm.so wsrep_cluster_address = "gcomm://"

And finally, restart Mysql:

sudo service mysql restart

When you connect to mysql, it should give you the following:

Server version: 5.6.16 MySQL Community Server (GPL), wsrep_25.5.r4064

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Hopefully the version mismatches don't give you any trouble.

2014-08-30

Music of the moment, August 30 2014

Pandora's introduced me to a wide variety of music that's been great.

Ólafur Arnalds is one of those artists that will never really get a ton of traction in the mainstream, much like Jonsi/Sigur Ros, El Ten Eleven, et. al., until his music gets picked up and used on a major commercial project. I sincerely hope it will happen sooner than later, but my gut says it will happen.

While I have a lot of comments about this tune, enigmatically entitled 3055, I think it stands on its own well. Listen to it in a quite time, with an open mind, and let your imagination hear the story being told.