PostgreSQL – Rock Solid in the face of forking MySQL

PostgreSQLEver since Sun Microsystems agreed to acquire MySQL back in 2008, there has been a fair bit of uncertainty and chaos surrounding the world’s most popular Open Source database. With many big names in the MySQL community pulling in different directions and the recent Oracle / Sun acquisition, the choice of which Open Source database to use is now easier than ever – PostgreSQL. :twisted:

One of MySQL’s key strengths has always been its simplicity to both install, manage and code against, resulting in mass adoption over time, which in turn forced the once web bound database to evolve into a near fully fledged enterprise RDBMS.

PostgreSQL on the other hand was born an RDBMS and instead worked silently in the background improving the performance, reliability and feature list of the world’s most advanced Open Source database, and all under the lesser restrictive BSD license – nice work!.

Getting up to speed with PostgreSQL can take a little longer for MySQL veterans, mostly due to the many subtle differences, but more importantly the extensive feature set (one of the reasons it is taking longer to add PostgreSQL support to dbRecorder ;) ) but the rewards are worth it, as companies such as Skype can attest to.

It was installing OpenNMS several years ago that convinced me to get to grips with PostgreSQL, and although there is a distinct lack of new reading material out there the manual covers everything you need to start building your next web app.

The GUI tool pgAdmin has also come a long way and provides a great interface to PostgreSQL, with excellent instructional prompts and support for all major platforms, there really is no better tool to help you work with PostgreSQL while getting to grips with the vast feature set. Check out the latest beta over at the pgAdmin site.

If you’re not yet excited about PostgreSQL, maybe you should check out the feature list planned for release 8.4 (currently at beta2), with cool features such as Column Level Permissions and SSL Connections you can feel less stressed about the security of your data, oh and the performance improvements won’t hurt either!.

While keeping with the BSD license, another notable release last month was FreeBSD 7.2, a great platform to complement the reliability of PostgreSQL and another way to gain some performance improvements.
Speaking of performance I was pleased to read that Jails are much improved in the latest release, and that it seems I am not the only one that prefers Jails / Zones over VM solutions!.

I’m off to make some progress with PostgreSQLDump.java, the worker class that will allow me to add PostgreSQL support to dbRecorder.
Watch this space…..

Merry Christmas!

Christmas2008I spent the last month taking a break from Open Source, partly due to FreeBSD 7.1 failing to hit the FTP servers as scheduled (any excuse), but mostly due to Santa’s early delivery of Ableton Live. Not really Open Source I may add but extremely cool nonetheless and a much needed break from coding!.

I find that staring too much at code can hamper the creative process (hehe), and as you know Creativity and Innovation go hand in hand with Open Source Software!.

Speaking of which, while I have been busy playing with waveforms and elastic audio, the Open Source world has been all guns blazing with cool releases like MySQL 5.1 GA, Open Solaris 2008.11, VirtualBox 2.1 and WordPress 2.7 to name a few.
You really cannot take a break these days without something big in the world of Open Source happening in your absence. :)

So the year is nearly at an end which got me thinking, what was the highlight of 2008 in the world of Open Source?.
I have to confess to spending more time than I would have liked this year working with proprietary software, always in combination with Open Source tools of course!. So if I had to highlight anything from 2008 it would be that Open Source is now more pervasive than ever. From your OSX laptop at home to the Linux servers at work, right the way up to the Internet’s biggest sites and services (running FreeBSD ;) ), you’ll find Open Source Software behind every successful venture. In fact it is now so popular even Microsoft could not resist the urge to get in on the game!.

In fact there are so many Companies using Open Source now that proprietary software may actually be the minority! We all know everyone loves an underdog, so maybe propreitary software will be the hit in 2009? Then again with the state of the economy maybe not! ;)

The biggest influence for me this year (both good and bad) had to be Sun Microsystems who played a large part in Open Source adoption in the enterprise and continue to lead the way with their open business model (GlassFish, MySQL, Netbeans, OpenJDK, OpenSolaris and VirtualBox to name just a few of their many contributions).

Although most of the time it seems like they cannot do anything right, one thing is for sure, without the corporate weight of Sun behind the Open Source ethos we may not have made it here so quickly. So while your saving big bucks with your ZFS storage and processing millions of transactions with MySQL, don’t forget to say thank you to Sun next time you are complaining about JavaFX or MySQL 5.1.
You may even want to swap those complaints for contributions (I know complaining is often easier). :twisted: Thanks Sun!

So if you are one of the few companies yet to Open your code to the world, what are you waiting for? This Christmas give the gift of knowledge and share your achievements instead of fearing the competition and wrapping your code in a black box (don’t worry we won’t laugh at it). You’ll feel much better knowing you helped make the world a better place!

Until next year I wish you all a Very Open Source Christmas!! and as always Happy Coding!

If only Guy Fawkes had a G1…

Google AndroidHappy Halloween! – well by the time you read this it will be more – Remember, remember the 5th of November!. So what’s been happening?

Well I spent the last month getting to grips with DB2 – why I hear you ask?.
You shouldn’t keep all your eggs in one basket, and there were rumors that DB2 might become Open Source at some point (or not). Anyway even if that never happens there is a lot to learn from the original DBMS and with DB2 Express-C available for free there’s nothing to stop your Open Source app taking advantage of that fact. Besides competition is a good thing.

Anyway not forgetting my favorite DBMS, I managed to find time to spend a morning at the 4th MySQL Conference in London where the keynote opened to – here comes the sun – cute. There was a lot of emphasis on the fact that MySQL was not being written to run faster on Solaris (even though I got the impression that it does, with features like ZFS and snappy 64bit libraries outlined during the second session).

It was a relief to hear that MySQL 5.1 will finally go GA during the first week in December along with the new query analyzer (aka proxy). I couldn’t help get the feeling of déjà vu out of my head, after all it was only last October that I remember seeing some very similar slides – anyway fingers crossed for a December release!.

My only disappointment at the conference was hearing that the auditing / security features would not make an appearance until after 2010? (TBD), frustrating especially with items like PCI compliance high on everyones agenda. Still with a little ingenuity and help from the MySQL Proxy Server you can roll your own auditing solution and customise it to your own needs (is there anything proxy can’t do :) ).

Speaking of which it looks like the Proxy Server will finally hit GA early next year in the form of the MySQL Load Balancer. In fact it is planned to make an appearance in December in the form of the Query Analyzer – yes that’s based on the Proxy too!. Time to brush up on your Lua and check out the samples over at the Forge.

The big news this October/November goes to the G1, the first phone to take advantage of Android: a complete, open, and free mobile platform.

My own G1 adventure started last Thursday with a call to T-Mobile who were keen to dispatch my phone next day, but not so keen to deliver it to my workplace. Not a problem, I could wait till the weekend even if it meant paying £6 for delivery.

Saturday morning came and went with no sign of a Royal Mail van and after a 20 minute call to T-Mobile it seemed I would not be getting my G1 anytime soon. I listened to several explanations ranging from the order not going through to high demand exhausting stock. No offer of apology or even a discount of any kind!.

Not one to accept lame excuses I asked for the order to be cancelled and fought for another 15 minutes with a customer service rep who claimed the order could not be cancelled over the phone. His manager however had no problem canceling the order – funny that eh. A quick Google search confirmed my thoughts!.

My local T-Mobile shop was not much help either claiming that the plan I had accepted on Thursday no longer existed on Saturday due to it now being November. They did however have the G1 in stock, well they did until I decided to purchase it, then it seemed Monday was the earliest I could get one. I picked mine up on Sunday from Bluewater and even got the plan that no longer existed this month… :)

The fun didn’t end there though as it was about 5 minutes after opening the phone that I managed to lock the SIM while trying to set-up the password protection – PUK locked please contact customer services – do I have to I thought!. 30 minutes later the customer services rep had no idea how we could unlock the phone and instead decided to give me my PUK code along with the phone number for HTC‘s customer services (it’s their problem not T-Mobile’s) – which as you may have guessed already happened to be closed at the weekend. Maybe Google could help!.

Another quick search and it seemed I was not the only one with this problem and the only answer so far was to place the sim in another phone to enter the PUK code and unlock the SIM. Simple when you know how! (and you have a spare mobile to hand). Anyway my phone is now unlocked and I’m ready to start exploring Android. I did try logging into the My T-Mobile site to register my phone etc however the link failed – no surprises there.

As with most Open Source projects it is the community that provides the support and with the G1 / Android this is no exception. If you want to learn more about Android on the G1 don’t waste your time contacting T-Mobile, instead head on over to the website or forum and marvel at what is no doubt going to be THE mobile platform of 2009. All I need to do now is think up an idea for an app…..

Code Me In!

Code Me In
If you are security conscious and nowadays who isn’t?, you may have pondered over ways to make your external SSH connection safer.
Of course there’s always One-time Passwords and Public Keys, but if like me you watch the daily barrage of brute force attacks you may be thinking it’s only a matter of time…

That’s what I was thinking at about the same time an SMS arrived on my mobile….then it hit me….I take my mobile everywhere, if only my server could call me and ask if it is really me trying to log in.

My first instinct was to try and insert a Perl or Python script into the login process. After all Clickatell have several libraries that you can use to send SMS messages. How hard could it be? ;)
Well for starters it didn’t feel right relying on a script that runs within an interpreter that is running within a shell, but how else could it be done? Pluggable Authentication sprang to mind but that’s hard right? Wrong!.

Hitting the FreeBSD handbook I was able to gain a decent understanding of PAM functionality and even managed to find some sample code. Shame the programming section had not yet been written. O’Reilly to the rescue. After reading a few articles on PAM it wasn’t long before I had a working prototype, in fact most of my time was spent deciding upon the right library/s to use.
The end result is a pam module that can be dropped into the authentication chain for any PAM aware application/service – think SSH, FTP, POP3 etc.

Upon successfully entering your Username/Password the pam_codemein module uses libcurl to send an HTTPS request via Clickatell, my preferred SMS gateway, which then forwards the random Code to your mobile before prompting you to enter the same Code at the prompt to gain access. Of course there are issues with using SMS, such as mobile reception and timeouts, but in testing I didn’t notice any.

If you are concerned over the cost of SMS messages, Clickatell are a bulk SMS provider so rates are good, and if you prefer to be contacted via some other method the code can be adapted to any other service e.g. XMPP via TLS, you could even GPG encrypt the Code in an email if you prefer.

It was only after I had the fun of writing this module that I stumbled across this blog post. Shame as it may have saved me a lot of time, but hey where’s the fun in that? I’ll just have to get cracking on the XMPP method – either that or search deeper within Google. ;)

Have you seen RT 3.8!

It’s been a long time coming but after 2 years in the making the enterprise-grade ticketing system that is RT has had a well earned facelift, and what a difference!!.

Upgrading from 3.6.3 would have been straightforward if it was not for the fact that I also decided to upgrade to MySQL 5.1 at the same time. The final product made the pitfalls worthwhile however and RT is now slicker than ever. Plus I got know RT better along the way – bonus!.

If your thinking of upgrading to RT 3.8 / MySQL 5.1 just remember to use the MyISAM engine for the Attachments table (It’s worked so far for me with around 84k tickets). Failing to do so will result in slow response from the UI on certain actions due to MySQL failing to select the correct index on certain queries:

ALTER TABLE Attachments ENGINE=MyISAM;

It looks like the optimiser is broken for the InnoDB plugin, however if you check out this bug it may have been fixed by now (I was using FreeBSD port: mysql-server-5.1.26).

Did you spot that [Error]?

If only your database would just tell you that replication had failed or that the disk was full…
Ok some database servers do :twisted: but MySQL doesn’t (yet). Another excuse to write a script ;)

In my pursuit for total database visibility I have been searching for a tool that would tell me when something went wrong, that would simulate regular usage, and let me know if anything failed. After all SNMP can only probe so far and if your database is secure the last thing you want to do is open up another port on your server.

Don’t get me wrong there are tools out there that do a decent job of monitoring MySQL. MySQL Entperprise Monitor is one such tool. But if you want to look under the hood or add some functionality specific to your environment things start to get tricky.

So what’s this dbAlerter?

dbAlerter is the name of a project (Script) that I started developing to provide notification of key server events. It’s written in Python; Why?, I wanted something lightweight. Java would have been my first choice but the JVM eats too much ram and felt too heavy for such simple functionality.
Python on the other hand feels lighter and when running a script as a daemon it seems to take up less resources allowing the DB to use more memory and continue doing it’s job. Plus it’s been a while since I wrote anything with Python, variety is the spice of life!

Speaking of Java, if you have ever used tools like JConsole and jmap (and if not why not!) you may not have realised that since JDK 6 Update 7 there’s now one tool to rule them all – VisualVM.

VisualVM VisualVM Memory Consumption

VisualVM pulls together several commandline tools like JConsole, jstat, jinfo, jstack, and jmap to make monitoring and profiling a more visual experience.

Now that the changes from BSD Java have been merged into the OpenJDK and the FreeBSD Foundation have updated the JDK to 1.6.0-7 I’m pretty sure the original concept of write once run anywhere is closer than ever.

Database Change Management

Databases are used by many different disciplines, from your DBA to your Developer, right down to the End User. They can also be viewed from many different perspectives…

DBA’s are usually interested in the server configuration, index usage etc. Developers however are often concerned with retrieval methods, datatypes and occasionally stored procedures. One thing is for sure, your database if used effectively will be changing frequently, and with so many people accessing your database do you know what the last change was? Would you know if someone added an index to a table? (would you care… :twisted: )

Revision Control is often used to track changes to source code and other documents, so why not your database?.

When I first started to think about change control for my database servers one tool sprung to mind, Rancid. If you manage more than one network device you may already be familiar with the Really Awesome New Cisco confIg Differ.

Using a combination of scripts Rancid will connect to your network devices, check for changes by comparing the config with a VCS managed copy and notify you with details of the changes. Why not do the same for your database? Enter dbRecorder.

Rather than extend Rancid I decided to prove the concept by writing a quick Java application that utilised Open Source libraries like SVNKit and jYAML. The features continued to creep and before I knew it I was recording more than just table definitions. Server configuration and grant tables all found their way into my Subversion repository coupled with e-mail notification whenever anything changed – nice huh!.

The aptly named dbRecorder is currently targeted at my database of choice, MySQL. It’s far from a finished product (then again so are most of my ideas) but it’s working to a degree and can only improve over time….

One thing I never got around to was making this site work well with IE6 (or even just splash the screen with some silly message when someone using IE6 tries to connect) and with Firefox 3 soon to be released I am hoping I won’t have to. ;) If you have not tried Firefox 3 already you can visit the site today and pledge your download to help break a world record as soon as it is released!.

Centralised Notification (Aka Informeer)

It’s been a while since I had chance to work on Informeer as my itch was one of multi-user web based password management (AuthStor). Oh and moving house. :)

Now that things are settling down again (Servers back up and running) I decided to take a break from AuthStor and focus on something new – Informeer.

The concept is simple, Centralised Notification.

I am forever configuring notifications from several sources, be it backup alerts, host monitoring notification and even simple applications that send mail via SMTP. When living in a world of change, both software and business, having to visit every application to change an e-mail address or add a new user to a notification schedule can be quite time consuming. Add to that the effort of having to modify firewalls, SMTP servers and XMPP settings etc etc. The idea of a single web interface where all your notifications can be configured is quite appealing. Informeer aims to make that a reality (one day).

While I take my time with the implementation I thought I would post a basic intro to RPC-XML using Perl. The RPC-XML Perl module makes writing your own client/server application a piece of cake, and while not quite point and click, it will give you enough flexibility to centralise your own notifications (or anything else for that matter). It’s not rocket science, but it works!

If you have been looking for a flexible quick and easy fix to the centralised notification problem, or even if you are just looking to push some data from a firewalled site to one of your servers This Tutorial should help get you started.

In between moving house and playing with notifications I found time to upgrade to WordPress 2.5 and MoinMoin 1.6, and wow what an improvement in both camps.
The WordPress dashboard is the most visible improvement – it’s amazingly clean! If you have been waiting for 2.5 to settle down or just cautious about upgrading, I would say take the plunge, you won’t regret it. As for MoinMoin 1.6, there really is no better Wiki engine out there (my opinion) and it just keeps getting better with every release!.

That just leaves me to post a quick MySQL tip that may well be obvious, but happens to catch me out from time to time. :twisted:

MySQL Tip of the month

If you ever get the urge to convert a 1Gig MyISAM table (with 34 million rows) to InnoDB within MySQL, try to avoid the simple ALTER TABLE tablename ENGINE=INNODB; method.
I made the mistake of running that command on a fairly decent server with bags of space and memory only to find the command running over 5 hours later with an InnoDB tablespace at around 4Gig (ok a bit of tuning might have helped) ;)

Your best bet is to dump the table using mysqldump, drop the existing table and re-import the table after modifying the definition to be InnoDB. That worked for me in less than 10 minutes. Alternatively you can create a new InnoDB table and insert directly from the existing table as per MySQL documentation e.g INSERT INTO newtable SELECT * FROM oldtable.

I’m sure I am not the first to make this mistake, and may not be the last…..

Great News for MySQL and Sun!

Sun to Acquire MySQLI’m sure by now you would have read the great news that is Sun Microsystems acquisition of MySQL!

Sun have been forging ahead in the Open Source world with OpenSolaris, an Operating System that scales to Enterprise proportions and is an ideal host for the number one Open Source Database Server that is MySQL.

Whether this will have any impact on the MySQL Linux / FreeBSD / Windows offerings is something I am sure the community will be watching closely, but in my experience Java runs much faster on Solaris as it can take advantage of the MultiThreading libraries that help Solaris set those performance records.
Don’t forget, it was not that long ago that combined with Sun hardware MySQL was able to set it’s own world records!.

With that in mind it should only be a matter of time before we will begin to see the fruits of Sun / MySQL’s labour and I don’t know about you but I can’t wait!.

How this move will affect the future of other database servers such as PostgreSQL and Oracle I cannot begin to imagine.
Personally I never understood how Oracle devoted so much attention to Linux when the Oracle server (and App servers) have such a dependency on Java (which as I say always works better running under Solaris ;) )?
As for PostgreSQL, Sun have always endorsed PostgreSQL on Solaris, will we see this focus switch to MySQL in the near future?.

One thing is for certain, MySQL combined with Solaris makes for one world class package that is going to be hard to beat!!.

Happy New Year!

MySQL 5.1 Cluster DBA CertificationI know it’s a little late, but as this is my first post of 2008 I wanted to start on a high! :)

After receiving my copy of the MySQL 5.1 Cluster DBA book at Christmas, I spent an hour or so each day with my head engrossed in MySQL Cluster technology, so much so that my goal of reading every Perl book I own (cover to cover) has been somewhat put on hold…

The book was much smaller than I expected, in both physical size and pages (266) which was not a bad thing as I could carry it around if needed, and each chapter could be read within 15-20 minutes, just about right for my attention span ;)

I booked the exam a couple of weeks ago thinking I might need some incentive to fully digest MySQL Cluster details. I need not have worried, the book provides a great introduction to MySQL Cluster in easy-to-read chapters bringing you up to speed in no time, much more entertaining than the reference manual!

The exam itself consisted of 70 questions and on this occasion ended with a prompt asking to print to a file……argghhh……I suddenly got worried that the exam had crashed and that all my answers were lost?!, after all you normally get an instant result on screen and a printed record. I knew I should have used my regular testing centre :( Print -> File -> USB Stick -> another PC -> Adobe Distiller -> Print and I finally got the result – Passed – Phew!.

So the holidays are over and I have more time to focus on the fun stuff, like upgrading this site to the latest version of WordPress or adding GnuPG based encryption to AuthStor. If history is anything to go by the next few months are bound to see a spate of version bumps. I am personally looking forward to FreeBSD 7.0!

You never know, I might even find time to finish reading those Perl books before Perl 6 is complete :twisted:

Merry Christmas!!

Merry Christmas From Wave22007 is almost over and what a year this has been for Wave2!

My programming preferences have gone full circle, from beginning the year playing snakes and ladders (Python), I spent the summer drinking coffee (Java) and finally settled down surrounded by Camel’s, Lama’s and Parrots (Perl). Bizarre but never dull!

Steady progress has been made all round and as always the Open Source community has proven a valuable resource. Not a day went by where I did not discover something new or think of a new idea that could be built using Open Source Software. I only wish I had more time in the day!.

My Christmas present came early this year in the form of a MySQL 5.1 Cluster DBA Certification Study Guide. I have been putting off the final MySQL certification while waiting for the book to arrive, and now it is in my hands the only thing preventing me from taking the exam is the lack of free space over the Christmas period. Hehe :twisted:

I also ordered a Nokia N810 (My Techie Present). My laptop is not small enough to carry around with me and I am hoping to capture more development time on this device. Either that or feed my mind. ;)

Anyway I’m off to hit the WarHawk servers before getting ready to see the New Year in Amsterdam – home of the Blender Institute. With projects like AuthStor making great progress and ideas such as Unix Architect and BinaryStor slowly maturing, I cannot wait to see what 2008 holds for Wave2!

Before I head off I have to mention the Catalyst Advent Calendar. Every year they pack 24 days of tutorials and tips into the month of December. If you are looking to get the most of the Catalyst Framework you really must take a look at this resource. I was able to prototype AuthStor in under 2 weeks and enjoyed every minute!

Wave2 Wishes You a Very Merry Christmas and an Open Source New Year!!!