marcus welz

MySQL Replication for Offsite Backups

Posted on October 19, 2009

I'm cheap. I tend to run pet projects on shoe string budgets. For one, it's just a good habit. It's easier to increase spending when it's really necessary (after some growth and revenue) than it is to turn off a service that you've come to rely on.

Whatever the case may be, having backups is crucial. Most businesses do not recover from a failure that includes data loss if they don't have backups. I have a production server that is running out there somewhere and if it were to go down, I need to be certain that I don't lose my data. It could go down for any reason at any time. Network issues, hardware failure, ISP going out of business, etc. So I want to be sure that I have all my important data where I need it, backed up at home on media under my direct control.

Although MySQL on my production servers is typically configured to only listen on localhost (127.0.0.1), I use SSH port forwarding to access it remotely.

The command for that is rather easy. On my laptop (runs Linux) I use the following command:

$ ssh user@example.com -L 3300:localhost:3306

Aside from using SSH to log into my server it also means that any connection made to port 3300 on my laptop is forwarded to the server, and on that side it'll connect to localhost port 3306, which is where MySQL is listening. That way I can fire up the MySQL Query Browser on my laptop connect to localhost port 3300 and work on my server's MySQL instance. Everything else is transparent, not to mention encrypted.

So with that in mind, I configure my production machine's MySQL server for replication (turn on binlog). And on the slave side (A headless Linux machine I have sitting under my desk at home) I setup key based authentication and use the following command:

$ while [ 1 ]; do ssh user@example.com -L 3300:localhost:3306 -N; echo "reconnecting..."; done

This will keep reconnecting in case of a connection failure. The MySQL slave will keep retrying to get to the master and I don't really have to worry about much.

Print This Post Print This Post
Tagged as: , , No Comments

Ubuntu 8.04 on a Sony VAIO VGN-FE890

Posted on April 25, 2008

This is a follow-up to my Ubuntu post from a few days ago. I've tried out the final version of 8.04 LTS on my Sony VAIO laptop, and found that it didn't boot. Instead, after the Loading Kernel process bar reaches 100%, the only thing that appears on screen is:

[   42.947514] ACPI: EC: acpi_ec_wait timeout, status 0, expect_event = 1
[   42.947575] ACPI: EC: read timeout, command = 128

And unfortunately that's where it ends. No CTRL+ALT+DEL, the only way to turn off the laptop is to hold down the power button for 5 seconds.
So apparently there's an issue with the ACPI, and indeed, it's something that's already being talked about.
I didn't actually install Ubuntu on the laptop, but I wanted to check it out from the live CD. My workaround is to hit F6 twice in the boot menu — once to get a command line interface to be able to add and modify the options, and the second time you get a popup. From there, conveniently select the first option, which is "acpi=off", by hitting Enter. Press ESC to close the popup, and hit Enter to boot. Of course ACPI will be disabled, but at least you'll be able to get into Ubuntu.

Print This Post Print This Post

Ubuntu 8.04 nearing release

Posted on April 12, 2008

It's getting interesting. Computerworld and ZDNet report a Gartner analyst claiming that "Windows is 'collapsing'". Computerworld is also talking about Ubuntu breathing new life into old hardware.

With that said, The Ubuntu 8.04 release is imminent, and I'm very much looking forward to it. I've been a Ubuntu user on and off pretty much since 4.10, also known as Warty Warthog. 4.10, along with version 5.04 (Hoary Hedgehog) are the only ones with code names that don't follow the letters of the alphabet. There's 5.10 (Breezy Badger), 6.06 (Dapper Drake), 6.10 (Edgy Eft), 7.04 (Feisty Fawn), 7.10 (Gutsy Gibbon), and I was sure 8.04 was going to be named Hungry Hippo, but alas, its code name is Hardy Heron.

8.04 is also a LTS version, with support until 2011 and 2013 for desktops and servers respectively. This is similar to version 6.06 which came out in 2006, and will be supported until 2009 and 2011 respectively.

There's a beta version currently available for early adopters, which I recommend you try if you're into trying new things. A nice feature of Ubuntu is that you can boot from the CD to a fully functional Linux desktop system without having to install anything on your harddrive. Sure, it's not permanent, but it's a great way to try it out before making a commitment.

Print This Post Print This Post

Auto-properties in Subversion

Posted on November 12, 2004

I'm a big fan of Subversion and use it for nearly every project I work on. I work on our software projects in several ways: On the Linux development server directly, which I access from a Windows desktop using UltraEdit (Load/Save via SFTP), WinSCP, PuTTY, and the command line svn client. On my Windows PC, with Apache 2, PHP5, MySQL 4 and PostgreSQL 8 installed, using TortoiseSVN. On my Windows Laptop, also with Apache 2, PHP5 and MySQL 4, and TortoiseSVN installed, so I can develop and test anywhere I am.

Not too long ago I noticed that the auto-properties in Subversion weren't applied when adding new files in TortoiseSVN on my windows machines.

On the development server where I work some of the time the /etc/subversion/config file looks like this:

[miscellany]
enable-auto-props = yes
[auto-props]
*.php = svn:keywords=Id
*.phtml = svn:keywords=Id
*.lx = svn:keywords=Id
*.mysql4 = svn:keywords=Id
*.sql = svn:keywords=Id
*.tlx = svn:keywords=Id
*.txt = svn:keywords=Id
*.css = svn:keywords=Id
*.js = svn:keywords=Id

That config file is used by the commandline svn client and makes sure that all file with the listed extensions have their svn:keywords property set to Id.

On Windows, however, the equivalent (actually, the per-user configuration) file is located at C:/Documents and Settings/<username>/Application Data/Subversion/config. This file has the same format as the UNIX equivalent.

If you're not familiar with keyword substitution or the svn:keyword feature at all, you may want to read up on it. I typically stick the following header into every file:

/*
User Signup page
User Management module
Copyright 2004 Lucidix, Inc. All rights reserved.
$Id: signup.lx 2341 2004-11-01 18:04:01Z marcus $
*/
Print This Post Print This Post