Migrating a Zone from Primary Server to Secondary Server in Nexenta

From Docupedia

Contents

Background

I have a couple systems running nexentaCP. This is a minimum subset of both the opensolaris kernel and the gnu user land. One of the nicest features is that it supports zfs under the hood but also fun stuff like apt-get. This how-to will follow through the steps required to migrate a zone that is running on a primary server to a backup server. I'm using the process to consolidate 3 different machines running zones into a single zone host. This will free up the additional hardware for a couple cluster related howto's. This is a very good process for migrating production zones from an older server(primary) to a newer one(backup).

What you need

Two systems running some version of nexenta. For this howto its going to be done on a nexentaCP base. The backup server in this example is running a newer version of nexentaCP installed from the Beta 1 testing 4 cd. This iso wasn't released to the public due to nexenta going commercial but we gots the hookups. The Primary machine pushing the zones however are an older install of nexenta. It's running the Alpha 7 testing 2 release. Thats right baby I'm so confident in nexenta that I will run their Alpha releases in production!! Put that in your pipe and smoke it.

The process

I'm making a couple assumptions here. Firstly that all your zones exist inside a filesystem in a zpool called /data/zones/. I'm also assuming that each zone has its own zfs filesystem that may or may not have snapshots taken of it. There is other ways to make this whole thing happen but this is the way I've chosen to support. The process in a one liner should roughly be as follows:

#On Primary Machine
halt the zone
detach the zone
tar it up preserving permissions
scp the tarball to the new host
#On Backup Machine
use zonecfg to prep for zone attachment
create a zfs filesystem to hold extracted tarball contents
extract the tarball
attach the zone
boot that baby!

A little more detail

I will now give a little more detailed explanation for each of the steps listed above. I just like to have it in my head what sequence of events I'm going to attempt to do before I do it.

#On Primary Machine
$> sudo zoneadm -z zone1 halt
$> sudo zoneadm -z zone1 detach
$> suod zonecfg -z zone1 export > /data/zones/zone1.conf
$> sudo tar cpf /data/zones/zone1.tar /data/zones/zone1/
$> sudo scp /data/zones/zone1.tar backupserver:/data/zones/
$> sudo scp /data/zones/zone1.conf backupserver:/data/zones/
#On Backup Machine
#Create the zfs filesystem to hold the zone
$> sudo zfs create /data/zones/zone1
#Import zonecfg if everything stays the same
$> sudo zonecfg -z zone1 -f /data/zones/zone1.conf
#Alternately you could remake the new config incase you want to change anything
#Don't do this if you used the import command above.
$> sudo zonecfg -z zone1
jsmith@sol01:~$ sudo zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/data/zones/zone01
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add net
zonecfg:zone1:net> set address=192.168.1.200
zonecfg:zone1:net> set physical=e1000g0
zonecfg:zone1:net> end
zonecfg:zone1> add attr
zonecfg:zone1:attr> set name=comment
zonecfg:zone1:attr> set type=string
zonecfg:zone1:attr> set value="zone1.domain.com"
zonecfg:zone1:attr> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
$> sudo vi /etc/zones/zone1.xml
#Make sure you match all the mounts. I usually only do:
# <inherited-pkg-dir directory="/platform"/>
$> sudo tar xf /data/zones/zone1.tar
#Wait a long time
$> sudo zoneadm -z zone1 attach
$> sudo zoneadm -z zone1 boot

#I found it took a full reboot for the zones to come up fresh
$> sudo zlogin zone1
[Connected to zone 'zone1' pts/3]
Last login: Sat Dec  8 12:14:17 on pts/3
root@zone1:~# reboot
#After that all services came up correctly.


For more info on installing zones in nexenta check out: http://docs.alkaloid.net/index.php/Installing_Zones_on_Nexenta