Latest Publications

Point-in-Time recovery with a mylvmbackup snapshot

Your database crashed, but fortunately you run mylvmbackup and got a tarball ready for the recovery. But how do you get a point-in-time recovery from this backup? I’ll show you how.

I assume you have the binary log enabled in MySQL and that the MySQL server is not currently running. The binary log is required for the point-in-time recovery of your database.

Find your tarball, unpack it, and replace the content of the backup directory with your MySQL data directory. Normally this would be /var/lib/mysql.

# cd /var/backup/mylvmbackup/
# tar zxf backup-20090511_030002_mysql.tar.gz 
# mv /var/lib/mysql /var/lib/mysql.crash 
# cp -a backup/* /var/lib/mysql/.
#

Now you need to find the binary log position from the backup. You will find this in a file under the backup-pos directory.

# cat backup-pos/backup-20090511_030002_mysql.pos 
Master:File=mysql-bin.000021
Master:Position=657184
Master:Binlog_Do_DB=
Master:Binlog_Ignore_DB=
#

Start the MySQL server.

# /etc/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
#

Run the mysqlbinlog utility on the binary log. You want to set the start-position to the position we got from the backup. The stop-position should be self-explanatory. Read the mysqlbinlog(1) man page if you need more information on it. You can also use the –start-datetime and –stop-datetime options to mysqlbinlog to specify exact an datetime in the binary log that you want to start and stop at.

# mysqlbinlog --start-position=657184 --stop-position=782260 /var/log/mysql/mysql-bin.000021 | mysql
#

This is it! Your database should now be up and recovered to a functional state. Read the mylvmbackup(1) man page for more information on mylvmbackup.

First impressions on Ubuntu 9.04

We are just one day away from the final release of Ubuntu 9.04 Jaunty Jackalope. I have been trying out the beta and release candidate on my laptops the last few weeks. The first thing that made me an impression is the boot speed. It is really fast, even when I am running with my disk encrypted. An important change from the latest version, is the linux 2.6.28 kernel and the option of installing the new ext4 filesystem. It is not the default filesystem, but the Ubuntu crew will consider making it the default filesystem in the next release based on the feedback from users. To be short and quick, I made the conclusion that Ubuntu 9.04 really is a great update from the last version. I guess we are all waiting for the final release.

HAProxy - Rewriting to a Zope VirtualHostMonster

HAProxy is a great load balancer for a site running multiple Zope backends. The option reqrep in HAProxy enables you to replace a regular expression with a string in a HTTP request line. The reqrep function takes two options, the search regular expression and the full replace string. POSIX regular expression is used.

A VirtualHostMonster placed within a folder in Zope would normally look something like this.

/VirtualHostBase/http/www.example.org/path/to/webroot/VirtualHostRoot/

So if www.example.org was a website running on the Zope application server and a VirtualHostMonster is used, we would need our frontend (HAProxy) to rewrite all requests to this path.

The first option we pass to HAProxy is the regular expression search. A request line could look like this.

GET /plone/about

We need to write a regular expression that saves the request type and the request path in two different variables. A regular expression like this would do that work.

^([^ ]*) /(.*)

The next option we send to reqrep is the replace string. The two grouped expressions can be refered to in the replace string as 1 and 2. The second option would give us something like this.

1 /VirtualHostBase/http/www.example.org/path/to/webroot/VirtualHostRoot/2

Below is a full example of how a backend definition in HAProxy could look like.

backend backend_plone
  balance roundrobin
 
  reqrep ^([^ ]*) /(.*) 1 /VirtualHostBase/http/www.example.org/path/to/webroot/VirtualHostRoot/2
 
  server zope_01 127.0.0.1:8010 check
  server zope_02 127.0.0.1:8020 check
  server zope_03 127.0.0.1:8030 check
  server zope_04 127.0.0.1:8040 check

Hello world!

It’s 2009 and this is my first public blog post. Did I miss anything? Probably not. What can you expect to read on this blog? You can expect this to be a blog about things I spend much of my work and spare time with, internet services and general linux and unix stuff.