Posts Tagged ‘howto’

Share Database Migration Tips

Saturday, October 25th, 2008

Database Server Icon - Visio Moving database servers is a nontrivial task that requires planning and forethought. This guide provides some tips for planning a migration of a small to midsize databases, but not yet data-warehousing in the 5Gb – 500Gb size. Of course the process will work for smaller databases, and even larger as well. Ultimately your mileage may vary. Depending on the software you’re running your database on, there may be alternate paths, such as replication, available to you. Spend time researching your options before embarking on this type of backup. They can save time and frustration.

This document will not help with sizing your systems, however, completing the “Prepwork” will get you thinking in the right direction as to what you’ll ultimately need to purchase. I highly recommend reading Refactoring SQL Applications by Stéphane Faroult before buying hardware for capacity reasons alone.

Prepwork

Possibly the most important thing you’ll do during the migration is the preparation work. Spend some time looking at what your moving and where you’re moving to up front, it will cause you to answer some questions earlier than later which results in not making rash decisions in the heat of the moment.

1. Inventory and Audit

It’s time to find all the dirty laundry. User’s with inappropriate access (like ‘sa’ or ‘root’) for running queries are obvious examples. While it’s tempting to do all of your house cleaning up front, don’t. Document it all so it can be shopped around your organization.

  • Look at your user accounts on the RDBMS. Are all of them still currently used? Can any be removed?
  • Take a look at the schemas (databases). Are all of them still necessary? Can any be removed?
  • Take a look at the tables within each schema. Make note of large objects, you’ll want to do further investigation on these to ensure they’re really serving their intended purpose.
  • Make sure you’re backups are running with the intended frequency (and that they’re actually being generated).
  • Understand the underlying sub-system design and architecture you currently have.
  • Document the pain points you’re experiencing (assuming this is a capacity based move).
  • Pick a downtime window for the cutover and ensure you build in some extra time. The length of your downtime can be estimated using your Soggy run.

Armed with this data, you can begin identifying garbage that doesn’t need to move. An example from my experience is a ColdFusion client storage database running on Microsoft SQL Server. This database holds 2 tables CDATA and CGLOBAL each with ~680K rows. With transactional logs etc, the footprint of the database swelled to 7.5Gb. Let alone for a minute that keeping transactional logs on this table was overkill, we were also making significant changes to the application servers. All of this was irrelevant because of other infrastructure changes that were being made concurrently and the database was able to be dropped. This is a singular example of how some research early on can save time later. Moving chunks of data, to disk or over the wire, still takes time – as does the restoration process.

2. Plan the actual steps required to move

1Tb External iBook Hard Drive This is a page out of David Allen’s GTD. Obvious right? Backup the data and move it to the new server, restore it… done! Well, sure that’s one way to do it, but make sure you’ve got details hashed out on the “move it” bit. If you’re doing this change in a major metro area at rush hour, you’re opening some huge risks into your timeline. But, forgetting traffic; is it best for your environment and your technology? Can you handle the downtime? Consider the following options when flushing out your plan.

  • Replication, if available to you, is an ideal way to minimize the downtime. However, you’ll still need to push all data over the wire (or via disk) at some point to get the new equipment to the correct point in time for the log files to begin replication of data effectively.
  • Sending up to 20Gb of binary data over the wire is pretty quick, but after that, it may be faster to consider other options for moving data, including moving data via USB/Firewire/eSATA/(insert your favorite external storage method here) or even a whole server.
  • Physical data moving takes time and requires coordination, possibly at a datacenter (or multiple datacenters) and may require access be setup ahead of time.

Write down your execution plan, be optimized… you’ll run against this later to keep the noise out of your head.

When moving a large MySQL database between two geographically separated systems, you’re at the mercy of the public internet. Obviously, finding a time that the throughput for your route is best is ideal, but not always an option. After completing a full backup of an entire MySQL database, I pushed the 75Gb over the wire to the new equipment. That process took nearly 2 hours. Armed with the database footprint from your audit, you can use a download calculator to calculate a best case scenario for the transfer time. Keep in mind network congestion, route traffic and latency could increase this time – and those will all increase with distance.

Spring Cleaning

Grab a baseline of your performance. This is a great way to validate that the new solution will do what you expect it to. It’s always nice to see an increase in performance, but it’s better to have a quantified value of just how much increase you get per dollar spent. If you’ll be doing any re-factoring as part of the spring cleaning, be sure to benchmark after you finish that process again.

Begin your house cleaning list by truncating or dropping unnecessary data, tables and schemas. Clean out all of those old user accounts and get your house in order. Ensure you backup proccess has been generating good files and your ready to use those for a Soggy run.

If all has gone well with your process so far, you may be considering just keeping the equipment you’ve got! But if not, and a move is still in your future… get ready to do a Soggy run – note quite the real thing, but not a “dry” run either, because we want to time our process.

Soggy Run

Make note of the time… and get moving – stick to the script. Should you deviate (in order or adding additional steps) be sure to note it on the script so you’ll be prepared for the final run. Also note time deltas at intervals so you’ll know if somethings taking too long and your window might need to be extended. It’s possible if you’ll be using replication to manage the transfer, that you won’t need to execute this again, but if you do, it’ll be nice to have the actual steps you’ve taken.

  • Make your backups
  • Begin your plan for transfering the data
  • Ensure you’ve got all the tools, scripts, and equipment you need in the right place in the right order.
  • Restore the data
  • Validate that EVERYTHING worked. Don’t just look at numbers of databases, but spot check a few (if there are too many to check them all) and ensure the data you’re expecting to be there is there!
    If you are using replication, can you start it, does it work. Trying validating a database or two to ensure everything is right – after the migration is no time to realize you’ve missed data.
  • Try your environment against the database and ensure it performs as expected, not just from an accuracy standpoint, but from a performance one as well.
  • If your not using replication to handle the next steps, drop all databases from your server. The system will need to drop them when you re-create them and this takes time especially for large databases.
  • Make note of the final time. Add some padding to it and set that as your downtime window. Doubling it is safest, but 20% may be sufficient.

D-Day

It’s been rehearsed, the pitfalls discovered, and the process documented – it’s now down to simple execution steps. Ensure you have access, either via phone, or in person to people who can assist with the migration should something go wrong. It’s nice to have resources available to call on. Gather necessary materials and get going.

  • Make sure you’re well rested. Nothing is worse than trying to make good decisions when extremely tired.
  • Begin your planned downtime window with a clear head. Disable the necessary systems and put up any necessary messaging. Now is the time to ensure your data is perfect and not being altered.
  • Run the playbook you’ve created…
  • Bring the systems back online!
  • Once you’re done with the plan – validate that it’s all working and point your apps, users and the world at your newly completed creation.
  • Benchmark! Quantify the improvements you’ve made with similar load to what you’d been running before if possible.

Share Memcached with PHP on Mac OS X

Saturday, October 18th, 2008

Nate Haug provides a great script for installing memcached along with some very detailed instructions on setting up a sandbox environment. I’m not using his MAMP sandbox, instead opting for the built in PHP / Apache install, so I needed to change a few things from his tutorial. My system is a fully updated Intel MacBook Pro running OS X 10.5.5 with the Xcode tools installed – YMMV. PHP is currently reporting version 5.2.6.

  1. I added my revised start script for memcached.
  2. The PHP version that ships with OS X doesn’t have PECL, so I downloaded the source and compiled manually.
    phpize; configure; make; sudo make install
  3. Edit to /etc/php.ini: Changed: extension_dir = /usr/lib/php/extensions/no-debug-non-zts-20060613/
  4. Edit to /etc/php.ini: Added: extension=memcache.so

You can skip his Apache scripts. Restart apache by restarting Web Sharing in the System Preferences.

The major changes I made from Nate’s memcached startup script were the singular instance and binding the service to localhost (127.0.0.1) only. This keeps memcached slightly more secure by only having it listen on the loopback adapter. If you need more space, just change the -m attribute to be higher; it’s measured in MB.

# /bin/sh
memcached -m 1 -l 127.0.0.1 -p 11211 -d

NOTE: As with any other service running on your system, opening a web server exposes your system to potential attack and worse. Be sure to keep production data away from your test environment. Someone at Starbucks, sharing your WiFi connection, may be surfing your development site too. Consider yourself warned!

Share AT&T LaptopConnect First Impression

Thursday, June 5th, 2008

AT&T Logo Despite my initial reaction to the contract, I decided to bite the bullet and purchase a laptop connect card from AT&T. The modem arrived early this morning via DHL express thanks to the complementary 2 day shipping that came with this modem. I opted for the Option GT Ultra Express 3G device which of course comes with limited Apple OS X support. I read the reviews on AT&T’s site about how the card stuck out 2 inches from the side of the computer. I found it to be slightly less, but it’s flush with the top surface of the 15″ MacBook Pro, so I was happy. With the antenna all the way out it extends just over 2 1/2″ but your milage may vary for the most accurate placement of the antenna. There’s also a port for an external antenna should you happen to have one. The other negative I had read about the modem was the blinking light was so bright they needed to put tape over it. While it is slightly distracting, it’s hardly blinding and I find it reassuring to know I’m connected – again YMMV.

LaptopConnect PackagingFor folks using a Mac, you’ll need to download the correct version of your software from Option. It’s a small file (1.1Mb) and downloads quickly – but don’t forget to do it before you head off into the land of non-access. You’ll get little help from the paper that comes in the box with the modem. Download the installation manual from Option as well. It’s not linked from the 10.4.11 and 10.5.x download page. Apple has the device listed in it’s configuration files so I’ll be spending some time looking for connection scripts to see if I can bypass the GlobeTrotter Connect software all together.

LaptopConnect Card Installed I was unsatisfied with the SIM card insertion – there’s nothing but friction holding it in. I have a feeling over time it will fall out. The other connection that felt weak is the actual slot in the Mac. I’m not sure if this is a issue with the card or the laptop’s ExpressCard/34 slot. The old style PC Cards seemed to have a more solid connection and the handy eject button that popped out let you know if it was in all the way or not.

I found it frustrating to have to create a new Network location instead of having it inserted in with my Airport/Ethernet etc settings. This also means I’m going to have to create all of my Parallels configuration again so I can use the network with Windows and WiFi and Ethernet so I can share the connection on vacation. I followed the instructions and set the APN value to isp.cingular as instructed in the 3G/EDGE/GPRS tab in settings. It never did connect although it may have been my lack of patience with the device’s initial network registration process. After removing that value it connected just fine – so it may be ignored anyway.

GlobeTrotter Connect Screenshot

From my home office I had pretty dismal download numbers for the portion of the test that was able to complete. I tested via Speedtest using their recommended connection in Kansas City, MO. With the default configuration set to prefer 3G but use what was available. I was able to achieve a peak of 17kbps and then it slowed to 6kbps and then stopped 17% of the way into the test. The ping test yeilded 349ms which I feel was reasonable. I’d read that setting the device to only use 3G and not switch to EDGE as needed can improve this performance. I reconnected and sure enough I was able to hit 700kbps but averaged 650kbps download before the test failed at 76% completed. I ran one last test to my closest physical location, the Twin Cities and hit 900kbps before the test failed at 56% I’m unclear why the tests continue to fail before completion – but that’s for another day.

Twin Cities Speedtest Screenshot

Option GT Ultra Express My last test was to upload a few photos (in fact the ones I took for this post) just to see how that all performed. My expectations were pretty low given the issues with the download test. I was able to upload all of these photos (~204Kb) in about 10 seconds which I actually found reasonable. The larger screenshot above (~188Kb) uploaded in about 4 seconds which was even faster. My conclusion is that this certainly won’t be replacing my broadband cable modem for daily internet access (not to mention there’s a data cap on the service) but it’s a viable alternative to going without and for those who travel sufficiently, it’s a cheaper alternative to pay as you go WiFi in airports and hotels.

© 1998-2008 AF-Design, All rights reserved.