Two-Server HA MySQL Cluster

So…. I like MySQL… Most FOSS projects I play with use it as their backend, so other people must like it as well. Because of this, I soon found I was running a DB server on almost every server/workstation I have. This was kind of annoying so I decided to build a dedicated MySQL server to which everything else could connect.

It was nice for a while, it was easy to manage and easy to monitor, but it doesn’t take a college drop out to understand that this configuration creates a single point of failure for a handful of applications.

Simple solution? Build a minimal MySQL cluster across two machines.

Even more simple? Build a minimal MySQL cluster in two virtual machines and place them on two different physical servers.

Now, I know what you may be saying, “But Mike, I’m not a dba! I’m not awesome with sql, MySQL, or Unix! Can I do this?”

To be perfectly honest, yes. It really isn’t all that hard and I will try my best to explain it simply, yet effectively.

The first step is to build a pair of servers you can use. I would suggest CentOS, and I can even help you out!

Check out my post on how to build a small CentOS installation.

When you have two servers, you may now start to look at the four components of a MySQL cluster:

  1. Server
  2. Cluster Managemen
  3. Cluster Storage Engine
  4. Proxy/Load Balancer

The first three parts are included in the MySQL Cluster package.

For this installation, we are going to use the ‘Linux (non RPM packages)’ download for the sake of simplicity. This should be fine for testing, or an an x86 machine. Ideally, you’d be using a 64bit machine for production, in which case you’d either use distro specific packages or compile from source.

From here on in: Every step described should be done on both servers unless specified otherwise.

Download the MySQL cluster package to a directory on your server.

Create the mysql group and user

# groupadd mysql

# useradd -g mysql mysql

Unpack it to /usr/local/

# tar -C /usr/local/ -xzf  ./mysql-cluster-gpl-6.3.17-linux-i686-glibc23.tar.gz

Link your installation to /usr/local/mysql

# ln -s /usr/local/mysql-cluster-gpl-6.3.17-linux-i686-glibc23 /usr/local/mysql

Create system databases

# cd /usr/local/mysql

# ./scripts/mysql_install_db –user=mysql

Set directory permissions

# cd /usr/local/mysql

# chown -R root .

# chown -R mysql ./data

# chgrp mysql .

Install sysconfig rc script

# cp support-files/mysql.server /etc/init.d/mysqld

# chmod +x /etc/init.d/mysqld

# chkconfig –add mysqld

That is enough for today, you basically have a working MySQL server at this point. Next we will create the configuration files and start up the NDB storage engine and cluster mangement nodes.

…to be continued!

Mike’s RHEL/CentOS 5 Installation

Here is a quick guide to minimize RHEL/CentOS.

For those of you who don’t know, RHEL is one of two major players in the enterprise linux market ( the other being novell’s SUSE Linux ). It has been around forever and is always great to have knowledge on… It also costs a metric shitload. CentOS solved our problem! They took RHEL and build their own identical linux distro for free, which is legit due to RHELs open source licensing :)

This article is not overly in depth, but is enough to get an install off the ground with a small CPU and disk footprint. Anyway, let’s get to it.

First, perform an almost default install. The only section you need to modify is the software installation.

To install only the bare essentials, uncheck any and all software to be installed. This involves unchecking the Gnome desktop option, then choosing to customize software install, and unchecking every option under each software group.

RHEL/CentOS will then override your no-install option with only the bare essentials required to have a working system.

When your install is complete, you can get a list of all running services by issuing:

# chkconfig –list|grep \:on

I then disable a pile of services with the following script/command.

Many of these will fail as if you do a minimal software installation, many of these packages won’t exist. If you do a default install, all of these will exist.

# for service in acpid apmd auditd atd autofs bluetooth cpuspeed cups firstboot hidd gpm ip6tables iptables isdn kudzu mcstrans mdmonitor messagebus netfs nfslock pcscd portmap restorecond rpcgssd rpcidmapd sendmail smartd yum-updatesd; do \

chkconfig $service off; \

service $service stop; \

done

Add RPMforge to open up a pile more software options

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Remove unused/unwanted packages

# yum -y remove selinux*

Install any updates.

# yum update

Please note that this is a document in progress, but currently it gives you a stable, incredibly well known/supported, and flexible linux installation. ( and free if you use CentOS )

With the steps above, your installation size should be just under 550MB while including YUM for easy installation of the myriad of software out there for RHEL/CentOS.

Enjoy.

http://www.centos.org/

http://www.redhat.com/rhel/

Adele, the new NEW soulstress?

The first I saw of this artist was her performance on SNL last night. To be honest, at first glance I was preparing myself to be fairly disappointed. It looked like it was going to be on par with a dismal high school talent show performance. A sheepish girl on stage with a mixed batch of musicians… but holy crap was I wrong (first time.. honest).

The voice of this girl… and the power coming from the band… were just incredible and worked perfectly together.

I could gush on about this performance and the album behind it, but really, the best thing for me to do is share. This is her video for Chasing Pavements. The album is 19, I suggest checking it out.

Lost Monster Revealed!!!