Brent Dax (brentdax) wrote,
Brent Dax

  • Mood:

How to fix a database using as many Linux features as possible!

Task: Repair a damaged database.

Constraint: The server it's residing on doesn't have enough space to repair it. The Linux partitions on the client are too small; there's an NTFS partition with enough space, but Linux cannot change the size of files on such a partition. SMB is far too slow to simply mount the NTFS partition to the server and use it as scratch space--or even to copy the file over, repair it under Windows, and copy it back.

Solution: Create a big file on the NTFS partition (in Windows), put an ext2 filesystem in it, and use the loopback device to mount it. Then copy the file to the scratch filesystem with NFS, repair it, and copy it back.

Step 1: perl -e "open (TEMP, '> c:\temp.ext2'); for(0..5*1024*1024) { print qq(\r), int($_/1024); print TEMP qq(\0) x 1024 or die $! }" (Generates a 5GB file.)
Step 2: Boot into Gentoo
Step 3: emerge nfs
Step 4: ssh navi, then /etc/init.d/apache stop; /etc/init.d/mysql.server stop; emacs /etc/exports; /etc/init.d/nfs start
Step 5: mount navi:/ /mnt/navi
Step 6: mke2fs /mnt/win/temp.ext2
Step 7: mount -o loop /mnt/win/temp.ext2 /mnt/temp
Step 8: cp /mnt/navi/var/mysql/apache/access_log.* /mnt/temp
Step 9: emerge =mysql-4.0.17
Step 10: myisamchk -r /mnt/temp/access_log
Step 11: cp /mnt/temp/access_log.* /mnt/navi/var/mysql/apache
Step 12: ssh navi, then /etc/init.d/mysql start; /etc/init.d/apache start

And it worked, with only minor problems (mainly relating to NFS configuration). It was almost too easy, once I figured out how to do it.

  • Life in five minutes

    Holy shit, I haven't posted here in forever. Okay, here's the story as quickly as possible: New House In it. Adore it. And I have the awesomest…

  • (no subject)

    Came up with something fairly clever to deal with the Internet access problem. Basically, I took a Windows laptop, configured it with Speakeasy's…

  • (no subject)

    From the top half of my bed I can get at the wireless network of one of our neighbors; that's how I'm posting this. AT&T can't restore our…

  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment