I just switched my mail, web, and database service from NetBSD/i386 2.1 to NetBSD/macppc 3.0_STABLE. Here's how I did it with minimal downtime.
Prepare new server
- Build and install NetBSD 3.0_STABLE.
- Build and install pkgsrc packages.
Vet old server
- With
file(1), find binary files with telltale signs of endianness such as “byte-order” and “native” and the like. (Berkeley DB is one such format.) If they're important databases, figure out the commands for dumping and restoring them. For instance, for each user with a trained SpamAssassin:
oldmachine$ sa-learn --backup > spamassassin.txt newmachine$ sa-learn --restore spamassassin.txt
And for all MySQL databases on the system:
oldmachine# mysqldump -u root -p --all-databases > mysql.txt newmachine# mysql -u root -p < mysql.txt newmachine# mysqladmin -u root -p flush-privileges
- With
grep(1), find text files in/homeand/etccontaining occurrences of theoldmachinehostname. Store a list of the resulting files for later.
Move
- Leave
oldmachineonline, in place, and serving normally. - Carefully merge
/etcfromoldmachinetonewmachine. - On
newmachine, temporarily enable root login insshd(8). - Start an initial gigantic
rsync(1)of/home, then go do something else for a good long while:
oldmachine# rsync -avz /home newmachine:/
- When it finishes, do a followup run:
oldmachine# rsync -auvz --delete /home newmachine:/
- Stop network services and
crononoldmachine. (If you needsshd, open as many shells as you need, thentouch /etc/nologin.) - Copy
/var/cron/tabstonewmachine. - On
oldmachine, check thatmailqis empty or contains nothing of importance to anyone. - Dump MySQL, SpamAssassin, and any other important databases.
- Do another followup
rsyncrun. (This time, the source won't be getting changed while it's being copied). - And do it one last time to convince yourself that
newmachinereally has an identical/home. - Unplug the network cable from
oldmachine. - On
newmachine, re-disable root login insshd. - Load MySQL, SpamAssassin, and your other dumped databases.
- Edit that list of text files and replace
oldmachinewithnewmachinein each. - On
newmachine, edit/etc/rc.confto manually configure the same IP addressoldmachinehad been using, and add an entry fornewmachineto/etc/hosts. - Reboot
newmachine. Wait a few minutes for the nearest router to notice the new MAC address and start sending traffic your way. - Watch the system logs for errors until you're convinced nothing has gone horribly wrong.
Beer
- Technically, this can be done in parallel with earlier steps.
Leisurely finishing touches
- Send a request to
hostmasterto keep the static IP already allocated to you in DHCP, but update the hostname and MAC address associated with it. - When that's been done, re-edit
/etc/rc.confto switch todhclient(8), and remove the temporary entry from/etc/hosts.
