How to migrate the local zones from one global zone to another global zone ? Last week, I have migrated the couple of local zones from one global zone to another global zone successfully and here I am sharing the same.In real production environment,you can balance the global zones load by moving few local zones to another global zones.To achieve this , you need to keep the local zones in SAN LUNS and those LUNS should be visible on all the global zones where you may migrate the local zones in future for capacity issues.
Task:Need to move UAZONE1 & UAZONE2 from global zone BL1 to global zone BL2.
Prerequisite:Destination global should have enough free memory and CPU to handle new local zones loads.Another important thing is that both global should be running with same patch level and OS release.
Environment:
Filesystem: ZFS
Operating System:Solaris 10
Storage:SAN
Local zones: Sparse root zone
1. Login to global zone BL1 and halt the local zones which we need to migrate to other global.
UABL1># zoneadm -z UAZONE1 halt
UABL1># zoneadm -z UAZONE2 halt
2.Detach the local zones from BL1.
UABL1># zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
13 UAZONE3 running /export/zones/UAZONE3 native shared
14 UAZONE4 running /export/zones/UAZONE4 native shared
- UAZONE1 installed /export/zones/UAZONE1 native shared
- UAZONE2 installed /export/zones/UAZONE2 native shared
UABL1># zoneadm -z UAZONE1 detach
UABL1># zoneadm -z UAZONE2 detach
UABL1># zpool list |grep UAZONE1
UAZONE1_rpool 1019G 800G 219G 78% ONLINE -
UABL1># zpool list |grep UAZONE2
UAZONE2_rpool 99.5G 30.6G 68.9G 30% ONLINE -
UABL1># zpool export UAZONE2_rpool
UABL1># zpool export UAZONE1_rpool
4.Copy the zone’s configuration files to other blade.(UABL2).
UABL1># cd /etc/zones
UABL1># ls -lrt
total 33
-r--r--r-- 1 root bin 402 Jun 20 2007 SUNWlx.xml
-r--r--r-- 1 root bin 562 Aug 8 2007 SUNWdefault.xml
-r--r--r-- 1 root bin 392 Aug 8 2007 SUNWblank.xml
-r--r--r-- 1 root bin 777 Mar 11 2008 SUNWtsoldef.xml
-rw-r--r-- 1 root other 262 Feb 13 2011 global.xml
-rw-r--r-- 1 root root 457 Aug 15 2012 UAZONE1.xml
-rw-r--r-- 1 root root 457 Aug 15 2012 UAZONE2.xml
-rw-r--r-- 1 root root 457 Aug 15 2012 UAZONE3.xml
-rw-r--r-- 1 root root 457 Aug 15 2012 UAZONE4.xml
-rw-r--r-- 1 root sys 911 Sep 23 04:17 index
UABL1># scp -r UAZONE1.xml UAZONE2.xml 192.168.102.18:/var/tmp/
Password:
UAZONE1.xml 100% |
*************************************************************| 457 00:00
UAZONE2.xml 100% |
*************************************************************| 457 00:00
UABL1>#
5.Login to other global zone where you want to migrate the OSI’s.
UABL1># ssh 192.168.102.18
Password:
Last login: Mon Sep 23 04:20:14 2013 from UABL1.qa.plexxus
Oracle Corporation SunOS 5.10 Generic Patch January 2005
# bash
UABL2># zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
29 UAZONE7 running /export/zones/UAZONE7 native shared
30 UAZONE8 running /export/zones/UAZONE8 native shared
31 UAZONE9 running /export/zones/UAZONE9 native shared
UABL2>#
6.Create a dummy local zones for index file update.
UABL2># zonecfg -z UAZONE2
UAZONE2: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:UAZONE2># create
zonecfg:UAZONE2># set zonepath=/export/zones/UAZONE2
zonecfg:UAZONE2># verify
zonecfg:UAZONE2># commit
zonecfg:UAZONE2># exit
UABL2>#
UABL2># zonecfg -z UAZONE1
UAZONE1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:UAZONE1># create
zonecfg:UAZONE1># set zonepath=/export/zones/UAZONE1
zonecfg:UAZONE1># commit
zonecfg:UAZONE1># exit
UABL2>#
7.Move the zone’s configuration files as zonename.xml.old and Copy the zone’s configuration files to /etc/zones from /var/tmp.
UABL2># cd /etc/zones
UABL2># mv UAZONE1.xml UAZONE1.xml.old
UABL2># mv UAZONE2.xml UAZONE2.xml.old
UABL2># cp /var/tmp/UAZONE1.xml .
UABL2># cp /var/tmp/UAZONE2.xml .
UABL2># ls -lrt
total 41
-r--r--r-- 1 root bin 402 Jun 20 2007 SUNWlx.xml
-r--r--r-- 1 root bin 562 Aug 8 2007 SUNWdefault.xml
-r--r--r-- 1 root bin 392 Aug 8 2007 SUNWblank.xml
-r--r--r-- 1 root bin 777 Mar 11 2008 SUNWtsoldef.xml
-rw-r--r-- 1 root root 262 Jun 19 2012 global.xml
-rw-r--r-- 1 root root 461 Aug 16 2012 UAZONE9.xml
-rw-r--r-- 1 root root 461 Aug 16 2012 UAZONE8.xml
-rw-r--r-- 1 root root 457 Aug 16 2012 UAZONE7.xml
-rw-r--r-- 1 root root 457 Sep 23 04:22 UAZONE2.xml.old
-rw-r--r-- 1 root root 457 Sep 23 04:23 UAZONE2.xml
-rw-r--r-- 1 root root 457 Sep 23 04:31 UAZONE1.xml.old
-rw-r--r-- 1 root sys 1110 Sep 23 04:31 index
-rw-r--r-- 1 root root 457 Sep 23 04:32 UAZONE1.xml
UABL2>#
8.Verify the zone’s configuration.
UABL2># zonecfg -z UAZONE1 info
zonename: UAZONE1
zonepath: /export/zones/UAZONE1
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.102.67/24
physical: e1000g0
defrouter not specified
UABL2>#
UABL2># zonecfg -z UAZONE2 info
zonename: UAZONE2
zonepath: /export/zones/UAZONE2
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.102.73/24
physical: e1000g0
defrouter not specified
UABL2>#
UABL2># zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
29 UAZONE7 running /export/zones/UAZONE7 native shared
30 UAZONE8 running /export/zones/UAZONE8 native shared
31 UAZONE9 running /export/zones/UAZONE9 native shared
- UAZONE2 configured /export/zones/UAZONE2 native shared
- UAZONE1 configured /export/zones/UAZONE1 native shared
UABL2>#
9.Import the zpools.
UABL2># zpool import UAZONE2_rpool
UABL2># zpool list UAZONE2_rpool
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
UAZONE2_rpool 99.5G 30.6G 68.9G 30% ONLINE -
UABL2># df -h /export/zones/UAZONE2
Filesystem size used avail capacity Mounted on
UAZONE2_rpool/rpool 98G 31G 67G 32% /export/zones/UAZONE2
UABL2>#
UABL2># zpool import UAZONE1_rpool
UABL2># zpool list UAZONE1_rpool
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
UAZONE1_rpool 1019G 800G 219G 78% ONLINE -
UABL2>#
10.Attach the local zones.
UABL2># zoneadm -z UAZONE2 attach
These packages installed on the source system are inconsistent with this system:
SUNWlwact: not installed
(3.3)
SUNWpsn: not installed
(1.1.4,REV=2008.04.25.10.21)
These patches installed on this system were not installed on the source system:
138194-04
UABL2>#
Note:Some of the packages and patches are not installed on source system where you have those in destination global zone. Now its up to you how you want to proceed.
If you use “zoneadm -z zonename attach -U ” will sync the packages and patches with this global zone and it will attach it. If you do this , then you can’t move the local zones back to BL1 unless until you install those missing packages and patches.
Here i have requirement to move the zones back to BL1 after sometime. I will attach the zones forcefully without syncing the packages and patches since those missing packages/patches are related to application level not at the kernel level patches.
10.Attach the local zones forcefully.
UABL2># zoneadm -z UAZONE2 attach –F
UABL2># zoneadm -z UAZONE1 attach –F
UABL2># zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
29 UAZONE7 running /export/zones/UAZONE7 native shared
30 UAZONE8 running /export/zones/UAZONE8 native shared
31 UAZONE9 running /export/zones/UAZONE9 native shared
- UAZONE2 installed /export/zones/UAZONE2 native shared
- UAZONE1 installed /export/zones/UAZONE1 native shared
UABL2>#
11.Boot the local zones and perform the system health check.
UABL2># zoneadm -z UAZONE2 boot
UABL2># zoneadm -z UAZONE1 boot
UABL2># zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
29 UAZONE7 running /export/zones/UAZONE7 native shared
30 UAZONE8 running /export/zones/UAZONE8 native shared
31 UAZONE9 running /export/zones/UAZONE9 native shared
34 UAZONE2 running /export/zones/UAZONE2 native shared
37 UAZONE1 running /export/zones/UAZONE1 native shared
UABL2>#
UABL2># echo '::memstat' | mdb -k
Page Summary Pages MB %Tot
------------ ---------------- ---------------- ----
Kernel 2948991 11519 14%
ZFS File Data 10796628 42174 51%
Anon 5815335 22716 28%
Exec and libs 98165 383 0%
Page cache 83595 326 0%
Free (cachelist) 95703 373 0%
Free (freelist) 1128775 4409 5%
Total 20967192 81903
Physical 20400209 79688
UABL2>#
UABL2># vmstat 1 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s1 s2 s1 s1 in sy cs us sy id
0 0 0 47814936 6409492 14 1834 1 0 0 0 3 2 2 0 0 4055 6614 4001 0 0 99
0 0 0 48117572 3503096 273 647 0 0 0 0 0 0 0 0 0 40099 12201 24369 2 4 94
0 0 0 48116244 3502860 0 4 0 0 0 0 0 0 0 0 0 50037 9740 30074 2 6 92
0 0 0 48116244 3502860 0 0 0 0 0 0 0 0 0 0 0 55833 9173 31013 2 6 92
0 0 0 48115740 3502340 0 128 8 0 0 0 0 0 0 0 0 40015 8980 24770 2 4 93
UABL2>#
If the system is using ZFS filesystem, then you can’t calculate the free memory using vmstat or top commands. By default ,ZFS has no restriction to use the physical memory as ZFS ARC cache. So always you need to check “memstat” output to find the free system memory by calculating ZFS file data.
Here we are having around 40GB~ as ZFS arc. So we can consider this as free physical memory. It will be released automatically whenever system/application required.
Please leave a comment if you have any doubt on this . I will get back to you .
Thank you for visiting UnixArena.
vanmeeganathn says
Thanks for sharing , my system is using ufs filesystem . can you explain same .
Vanmeeganathan Balasubramaniam says
thanks to sharing , can you provide steps for UFS file systems .
Harikishan says
Thank you so much, very important info.
Naresh says
I am trying to migrate zone..On target node after copied xml file,zone was not able to boot.See below errors.
-bash-3.2# zoneadm -z myzone attach
zoneadm: zone ‘myzone’: can’t stat /myzone/root: No such file or directory
zoneadm: zone ‘myzone’: call to zoneadmd failed
zlogin: login allowed only to running zones (myzone is ‘installed’).
zoneadm: zone ‘myzone’: ‘detach’ failed with exit code 1.
Cannot generate the information needed to attach this zone.
-bash-3.2# zoneadm -z myzone boot
zoneadm: zone ‘myzone’: can’t stat /myzone/root: No such file or directory
zoneadm: zone ‘myzone’: call to zoneadmd failed
-bash-3.2#