Thursday, July 31, 2008

One line to backup your MySQL database

I'm helping a friend setup a cron job to backup his MySQL database. For your reference, here are some one liners to do that:

Backup to a text file:
mysqldump -u root --password=PASSWORD MY_DB_NAME > MY_DB_NAME.sql

Backup to a compressed text file (replace gzip with zip or bzip2 or your favorite compression format):
mysqldump -u root --password=PASSWORD MY_DB_NAME | gzip > MY_DB_NAME.sql.gz

Tuesday, July 22, 2008

My software RAID 1 swap partition failed!

Tonight I went to do the simple task of adding some more memory to the one production Linux box for which I am fully responsible. (Running CentOS 3.9 currently) It was to be a simple addition of 2x1GB sticks bumping this poor machine from 512MB of RAM. I figured it would be pretty quick and painless. I even had no problems with the normally very temperamental fingerprint scanner at the data center. It worked on the first try. I was off to a good start.

I did have to fight with some cables to get a keyboard and monitor hooked up once I got into the rack but that was expected. It is worse because this particular system isn't as deep as the others above and below it making plugging things in very difficult. What I didn't expect though was what I saw when I got the monitor connected. It appeared that one of the drives in the software RAID 1 I have setup failed.

I don't remember the exact errors but since the system was still running and had been for quite a while, I wasn't really worried about downtime. I was just annoyed that I would have to make another late night or weekend trip out to the data center. So I upgraded the memory and made sure everything else was back up before looking into the RAID failure.

The first thing I checked was /proc/mdstat which is "the current information for multiple-disk, RAID configurations".

[root@host raidinfo]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
Event: 3
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md2 : active raid1 sda2[0]
1052160 blocks [2/1] [U_]

md1 : active raid1 sdb3[1] sda3[0]
76967296 blocks [2/2] [UU]

unused devices: <>
So there it is. md2 which is made up of the partitions sda2 and sdb2 is missing sdb2. Fortunately there is just an underscore there meaning it is just not connected. An F would mean it has failed. I was pretty sure that md2 was also the swap partition which is much less of a big deal and makes the most sense. After the upgrade from 512MB of ram to 2.5GB, the box was idling at 754GB so before the upgrade it must have been using that swap partition A LOT!

To double check, I checked to see what was mounted on each virtual disk:
[root@liquidcs raidinfo]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 73G 21G 49G 30% /
/dev/md0 99M 85M 8.9M 91% /boot
none 1.3G 0 1.3G 0% /dev/shm
Knowing that I only have a root, boot and swap partition I knew for sure by process of elimination I was dealing with the swap.

So next I wanted to see what the system logs had to say about md2:
[root@host raidinfo]# cat /var/log/message* | grep md2
Jul 22 22:19:36 host kernel: md: created md2
Jul 22 22:19:36 host kernel: md2: removing former faulty sdb2!
Jul 22 22:19:36 host kernel: md2: max total readahead window set to 124k
Jul 22 22:19:36 host kernel: md2: 1 data-disks, max readahead per data-disk: 124k
Jul 22 22:19:36 host kernel: raid1: md2, not all disks are operational -- trying to recover array
Jul 22 22:19:36 host kernel: raid1: raid set md2 active with 1 out of 2 mirrors
Jul 22 22:19:36 host kernel: md2: no spare disk to reconstruct array! -- continuing in degraded mode
Jul 22 22:19:36 host kernel: md: md2 already running, cannot run sdb2
Jul 22 22:19:37 host kernel: md: md2 already running, cannot run sdb2
Jul 5 07:01:21 host kernel: md2: no spare disk to reconstruct array! -- continuing in degraded mode
Jun 4 06:46:44 host kernel: md: created md2
Jun 4 06:46:44 host kernel: md2: max total readahead window set to 124k
Jun 4 06:46:44 host kernel: md2: 1 data-disks, max readahead per data-disk: 124k
Jun 4 06:46:44 host kernel: raid1: raid set md2 active with 2 out of 2 mirrors

So it had failed a over a month ago, ugh. Again, at least it was swap. I am still not sure what happened though. Restoring it turned out to be a simple task. I just ran raidhotadd to add the partition back to the array and waited about a minute. (This was just a small swap partition. Another guy at the data center chatted with me for a few minutes while I was there as he was waiting 3 more hours for a 500GB RAID array to finish rebuilding.)

[root@host raidinfo]# raidhotadd /dev/md2 /dev/sdb2
[root@host raidinfo]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
Event: 5
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[0]
1052160 blocks [2/1] [U_]
[>....................] recovery = 1.8% (20088/1052160) finish=0.8min speed=20088K/sec
md1 : active raid1 sdb3[1] sda3[0]
76967296 blocks [2/2] [UU]

unused devices: <>

[root@host raidinfo]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
Event: 5
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[0]
1052160 blocks [2/1] [U_]
[=================>...] recovery = 88.3% (930124/1052160) finish=0.1min speed=10303K/sec
md1 : active raid1 sdb3[1] sda3[0]
76967296 blocks [2/2] [UU]

unused devices: <>

And then just over a minute later, we are back in business!!

[root@host raidinfo]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
Event: 6
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[1] sda2[0]
1052160 blocks [2/2] [UU]

md1 : active raid1 sdb3[1] sda3[0]
76967296 blocks [2/2] [UU]

unused devices:

Crisis avoided. Thanks to the RAID HowTo guide and this page on recovering from the failure. I really should setup some monitoring and brush up on my RAID knowledge.

Monday, July 21, 2008

I hate Linux too!

Somehow this weekend I stumbled on the Linux Hater's Blog and it is quite a gem. It is not written by your average Microsoft or Mac zealot but, as I assume, a true and very frustrated Linux user. The Linux Hater's Blog discusses the many shortcomings of Linux that we all know are there but often don't want to admit. The author does this with a technical understanding that is far beyond your average Linux user too.

Some of the posts I have found most relevant so far have been the discussion on how having many, many choices is not better, the pain felt when upgrading Ubuntu and why my next box will likely have an NVidia card despite the open source ATI and Intel video drivers. (I wished I had an NVidia card when setting up Big Desktop.) I'm generally of the mindset of "it works" is greater than "it sort of works but here is the source if you want to try and make it work". I still respect the ideaology though.

Linux certainly has come a long way but it still has many shortcomings left to overcome. (Just read how much trouble ESR had setting up a printer on Linux in 2006.) I think we need more people sharing their pain and frustrations when using Linux to get those things fixed (so does this guy). After all, the squeaky wheel gets the grease. So come on fellow Linux users, get to complaining!

P.S. - A good place to complain about Ubuntu is, of course, the forums but also the Brainstorm site.

Saturday, July 12, 2008

Linux in the real world - in the wild

We all know that computers are everywhere in todays world. They are ATM machines, in your car, kiosks, cash registers, running factories, your cell phone, and the list could go on forever. You may not have thought about it but even these computers need an operating system. Many scarily run Windows, others run an embedded OS like QNX, VxWorks, or even plain old DOS. Most though, without you knowing it, probably run Linux. Embdedded Linux market share is high and on the rise.

I got to thinking about this again recently thanks to a Digg post: Vatican Runs Linux Yes, apparently they run Linux behind the scenes for some TVs in the gift shop. I wonder where else the Vatican is using Linux. This also makes me want to know where else have you seen or known Linux to be running? If it is embedded, you likely don't know that you have seen a device running Linux but maybe you've seen a Linux desktop somewhere like your local library, school, or in my case a hotel in Berlin.

Some companies are open about their products running Linux (and generally they have to be thanks to the GPL). Sometimes hackers just make Linux run on the device. Here are some:

Despite the high Linux usage, Windows is easier to spot in the wild though. Let me show you some proof:

At the McDonald's drive through

At the ATM

In Vegas


Piccadilly Circus in London

At the Gas Station

At the airport

Times Square in NYC and here too

Then there is the impressive showing at Toronto's The Bay department store. I could show you examples, after examples, after examples, after examples, after examples. So it is good to not "see" Linux running like this.

So back to my original question. Where do you know of Linux running in the wild? Do you have any pictures?

Friday, July 4, 2008

Firefox 3, Making awesome software and world records

If you haven't noticed (I don't think any one hasn't), Firefox 3 has been out for just over 2 weeks now (June 17, 2008). On the release day they also had a push to create a Guinness World Record for the most software downloaded in one day and despite some initial issues, they (we) did it!

Thanks to the support of the always amazing Mozilla community, we now hold a Guinness World Record for the most software downloaded in 24 hours. From 18:16 UTC on June 17, 2008 to 18:16 UTC on June 18, 2008, 8,002,530 people downloaded Firefox 3 and are now enjoying a safer, smarter and better Web.
I've been running some of the betas for a while now and despite some crashes in those pre-releases, this is definitely the best release yet. It feels faster, looks better, uses less memory and the awesome bar truly is awesome. If you have been running Ubuntu 8.04, you too have been running beta 5. So go get your download day certificate and enjoy the new browser.

Wow, I haven't posted in over a month!

Sorry to anyone (if there is anyone) who follows this blog regularly. I haven't posted in over a month now for a lot of very good reasons.

First, my hard drive crashed to the point that it was completely unreadable. I ran SpinRite on the drive for about 2 days straight and it was only 0.002% done scanning the drive with nothing recovered. Ouch! I had some backups but I realize I need a better system. Dual booting makes it harder to backup too because I have data on separate partitions and worse 2 different operating systems that need to perform backups but do it differently. Before the crash I was spenging most of my time in Linux but only had a backup system in place on Windows. Hopefully I will have more on that later when I find a solution.

A little over a week later, I went on vacation for just over 2 weeks (Italy and the Normandy region of France). I blogged some about my travels but saw very little Linux and Open Source related to blog about. I did see a few things I might touch on later but nothing super exciting.

Now that I have been back for a little over a week, I am finally starting to catch up and get my computer restored. I still want to finish blogging about my trip and in a few more weeks I will be moving and I still have to find a place to live. So... I've got some ideas for some new posts and hopefully I can get to writing them soon but I am not sure.

Enough of the personal updates, now back to the regular content...