Wise people learn when they can; fools learn when they must - Arthur Wellesley

Saturday, 27 December 2014

ZONES-6 [MOVE / CLONE NGZ]


ZONES-6 [MOVE / CLONE NGZ]

What we are about to learn,

·         Move the NGZ within same system
·         Changing hostname of NGZ
·         Move the NGZ to other system
·         Clone the NGZ


Well, King has accommodated his all 4 rentals. And now it’s time to relax

But suddenly one PG [tzone2] came and told the king that I don’t want to live in
That room and also I want new name for my room, but I want new room within same building

King was surprised with this demand but he agreed on the same and told the PG
OK… just stop all of your work then inform me,

root@sol-test-1:>/# zoneadm -z tzone2 halt

root@sol-test-1:>/# zoneadm -z tzone2 move /export/zones/newzone

root@sol-test-1:>/# zonecfg -z tzone2
zonecfg:tzone2> set zonename=newzone
zonecfg:newzone> verify
zonecfg:newzone> commit
zonecfg:newzone> exit

root@sol-test-1:>/# zoneadm -z newzone boot
root@sol-test-1:>/# zlogin -C newzone
[Connected to zone 'newzone' console]

tzone2 console login: root
Password:
Last login: Tue Dec 23 18:46:03 on console
Dec 23 18:54:34 tzone2 login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# hostname
tzone2

We need to change the hostname manually…

bash-3.2# vi /etc/hosts
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
192.168.234.201 newzone loghost



bash-3.2# vi /etc/ nodename
"/etc/nodename" 1 line, 7 characters
newzone


Possibly the hostname will change with these two, otherwise create a file

bash-3.2# vi /etc/hostname.e1000g0:1
newzone

bash-3.2# reboot

newzone console login:root
Password:
Last login: Tue Dec 23 19:12:53 on console
Dec 23 19:14:43 newzone login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# hostname
newzone
#

=================MOVING NGZ ON TO SAME SYSTEM-DONE HERE================

Well, it’s time to relax for king

But suddenly PG tzone3 came and told that I don’t want to stay here, I will find some other place to live.

King was very kind and generous person, he told its ok that u do not stay here
But you should first check that the place u r going is compatible to u or not, and also you had invested so much in your room like interior and other things.

Tzone3 remembered that, before few days he added a FS from GZ

root@sol-test-1:>/# zonecfg -z tzone3
zonecfg:tzone3> add fs
zonecfg:tzone3:fs> set dir=/testdir
zonecfg:tzone3:fs> set special=/dev/dsk/c1t2d0s1
zonecfg:tzone3:fs> set raw=/dev/rdsk/c1t2d0s1
zonecfg:tzone3:fs> set type=ufs
zonecfg:tzone3:fs> end
zonecfg:tzone3> verify
zonecfg:tzone3> commit
zonecfg:tzone3> exit

he liked this idea very much and generated a BLUEPRINT of the room and matches with his new room, It suited. Then he came to king and informed this news.

King told…good, now first u halt your work and then detach from here,
And one more thing that I know your new owner so if u agree then I can arrange transportation for your belongings otherwise u can move by yourself also.

Tzone3 agreed for transportation,

Well… take a breadth here, and lets understand what happened.

·         Tzone3 has to be move on other system
·         Compatible means both systems should be identical
·         Tzone3 needs to be halted then detached from GZ
·         Blueprint term is referred for pre validate of zone config on other system
·         Transportation means via ssh or can be any other medium

OK… let’s do these

root@sol-test-1:>/# zoneadm -z tzone3 detach -n >manifest

We can find this file under /

root@sol-test-1:>/# scp /manifest 192.168.234.134:/
Password:
manifest             100% |******************************************************|  3297 KB    00:00

root@sol-tst-2:>/# zoneadm attach -n /manifest

Now … we can proceed

root@sol-test-1:>/# zoneadm -z tzone3 halt

root@sol-test-1:>/# zoneadm -z tzone3 detach
root@sol-test-1:>/# cd /export/zones/
root@sol-test-1:>/export/zones# tar -cvf tzone3.tar tzone3

root@sol-test-1:>/export/zones# scp tzone3.tar sol-tst-2:/zone@sol-test2/zones/
Password:
tzone3.tar           100% |******************************************************|   113 MB    00:10

Now work at sol-test-1 is over, 

At new system

root@sol-tst-2:>/# cd /zone@sol-test2
root@sol-tst-2:>/zone@sol-test2# chmod 700 zones
root@sol-tst-2:>/zone@sol-test2# cd zones/
root@sol-tst-2:>/zone@sol-test2/zones# ls -l
total 232208
-rw-r--r--   1 root     root     118812160 Dec 23 20:09 tzone3.tar

root@sol-tst-2:>/zone@sol-test2/zones# tar -xf tzone3.tar


root@sol-tst-2:>/zone@sol-test2/zones# ls -l
total 232210
drwx------   4 root     root         512 Dec 23 20:04 tzone3
-rw-r--r--   1 root     root     118812160 Dec 23 20:09 tzone3.tar

root@sol-tst-2:>/# zonecfg -z tzone3
tzone3: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:tzone3> create -a /zone@sol-test2/zones/tzone3
zonecfg:tzone3> commit
zonecfg:tzone3> verify
zonecfg:tzone3> exit

root@sol-tst-2:>/# zoneadm -z tzone3 attach
zoneadm: zone 'tzone3': fsck of '/dev/rdsk/c1t2d0s1' failed with exit status 34; run fsck manually
zoneadm: zone 'tzone3': call to zoneadmd failed
zlogin: login allowed only to running zones (tzone3 is 'installed').
zoneadm: zone 'tzone3': 'detach' failed with exit code 1.
Cannot generate the information needed to attach this zone.


Well from here the game begins….

New owner was not generous as King, he called the tzone3 and said you are a big cheater you had stolen things from your previous owner, it cannot be tolerable. You must have to throw all stolen stuffs then only you are allowed here,

Now tzone3 was very ashamed and he submitted the list of belongings to new owner

root@sol-tst-2:>/# zonecfg -z tzone3
zonecfg:tzone3> info
zonename: tzone3
zonepath: /zone@sol-test2/zones/tzone3
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: exclusive
hostid:
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
fs:
        dir: /cdrom
        special: /cdrom
        raw not specified
        type: lofs
        options: []
fs:
        dir: /testdir
        special: /dev/dsk/c1t2d0s1
        raw: /dev/rdsk/c1t2d0s1
        type: ufs
        options: []
net:
        address not specified
        physical: e1000g1
        defrouter not specified
device
        match: /dev/rmt/0
zonecfg:tzone3>exit

New owner told that first of all you get rid of /testdir then come to me, let’s see what I can do

root@sol-tst-2:>/# zonecfg -z tzone3
zonecfg:tzone3> remove fs dir=/testdir
zonecfg:tzone3> commit
zonecfg:tzone3> exit

Then new owner has checked all the stuffs again,

e1000g1         = I have the same, so I can provide this
/cdrom          = I can also provide the same
/dev/rmt/0      = This can also be provided
/testdir        = This is already removed

Now I can allow tzone3 to reside here,

root@sol-tst-2:>/# zoneadm -z tzone3 attach

HERE I want to show something more, so I moved the same zone tzone3 on other system, and removed fs then I tried to attach

-bash-3.2# hostname
sol-test-4
-bash-3.2# zoneadm -z tzone3 attach
zoneadm: zone 'tzone3': WARNING: unable to hold network interface 'e1000g1'.: Invalid argument
zoneadm: zone 'tzone3': WARNING: unable to hold network interface 'e1000g1'.: Invalid argument

OK… means this system has only one interface, so it refuses to attach tzone3 with e1000g1


-bash-3.2# dladm show-dev
e1000g0         link: up        speed: 1000  Mbps       duplex: full

Now we need to remove this interface,

-bash-3.2# zonecfg -z tzone3
zonecfg:tzone3> set ip-type=shared
zonecfg:tzone3> remove net
zonecfg:tzone3> info
zonename: tzone3
zonepath: /export/zones/tzone3
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
fs:
        dir: /cdrom
        special: /cdrom
        raw not specified
        type: lofs
        options: []
device
        match: /dev/rmt/0
zonecfg:tzone3> add net
zonecfg:tzone3:net> set address=192.168.234.205
zonecfg:tzone3:net> set physical=e1000g0
zonecfg:tzone3:net> end
zonecfg:tzone3> commit
zonecfg:tzone3> verify
zonecfg:tzone3> exit

NOW… again try to attach,

-bash-3.2# zoneadm -z tzone3 attach
zoneadm: zone 'tzone3': is already installed.
-bash-3.2# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - tzone3           installed  /export/zones/tzone3           native   shared
-bash-3.2# zoneadm -z tzone3 boot
-bash-3.2# zlogin -C tzone3
[Connected to zone 'tzone3' console]

tzone3 console login: root
Password:
Last login: Tue Dec 23 19:37:33 on console
Dec 23 13:52:14 tzone3 login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# hostname
tzone3
# ifconfig -a
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.234.205 netmask ffffff00 broadcast 192.168.234.255
# ping 192.168.234.133
192.168.234.133 is alive

OK… its good but still I did not get what I wanted to show,

No problem, I will try to illustrate without getting that mess.

When we try to do this

-bash-3.2# zoneadm -z tzone3 attach

And got something like that

“Packages installed on the source system are inconsistent with this system……
……………………………………………………………….. blah blah blah”

What does this mean?

Suppose on the system where tzone3 was previously installed having 100 packages,
And now I moved that zone to new system where either 98 or 110 packages.
We get almost same error in vice-versa case

So what is the solution?

It depends on situation that why we moved our zone on other system,

a)  If the NGZ is going to permanently reside on new system
                     OR
b)  Just temporarily moved for some maintenance activity going on previous system

If the requirement is (a) then we need to update this NGZ with its new GZ


root@sol-tst-2:>/# zoneadm -z tzone3 attach –U
 -U will update/sync the NGZ pkgs with new GZ

If the requirement is (b) then we need to stick with pkgs what NGZ have

root@sol-tst-2:>/# zoneadm -z tzone3 attach –F
 -F will forcefully attach the NGZ to new GZ without considering the differences in pkgs, b’coz we do not want to stay here permanently.

    
======================MOVING NGZ TO OTHER SYSTEM-DONE HERE===============

Now, the last part of story…

CLONE a NGZ,

Well… what does the clone means?

Simply it means that twin brothers with everything same except name.

I will do this on same sol-test-1 with “tzone3”

Tzone3 is already halted, if not then we need to halt the zone first which is to be cloned

#zoneadm –z tzone3 halt

root@sol-test-1:>/# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   1 tzone4           running    /export/zones/tzone4           native   excl
   9 newzone          running    /export/zones/newzone          native   shared
   - tzone3           configured /export/zones/tzone3           native   excl

Prepare for cloning of zone

root@sol-test-1:>/# mkdir /export/zones/clonedZone

I had created a new folder named clonedZone under /export/zones which will be root path for cloned zone I am about to create

root@sol-test-1:>/# chmod 700 /export/zones/clonedZone

Changed the perm to 700

root@sol-test-1:>/# touch /export/zones/master

The file I created here is master, can be of any name

root@sol-test-1:>/# zonecfg -z tzone3 export -f /export/zones/master

Here I had export the config of tzone3 to file master, now we need to edit this file according to our requirement

root@sol-test-1:>/# vi /export/zones/master
"/export/zones/master" 33 lines, 464 characters
create -b
set zonepath=/export/zones/tzone3
set autoboot=true
set ip-type=exclusive
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add fs
set dir=/cdrom
set special=/cdrom
set type=lofs
end
add fs
set dir=/testdir
set special=/dev/dsk/c1t2d0s1
set raw=/dev/rdsk/c1t2d0s1
set type=ufs
end
add net
"/export/zones/master" 33 lines, 464 characters

THIS is the actual o/p …. Now we need to alter

Rootpath
Remove exclusive IP settings & add shared IP parameters
Remove /testdir

Rest is ok with me, Now see after changing how this file look

root@sol-test-1:>/# cat /export/zones/master
create -b
set zonepath=/export/zones/clonedZone ç altered
set autoboot=true
set ip-type=shared                   ç altered
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add fs
set dir=/cdrom
set special=/cdrom
set type=lofs
end
add net
set physical=e1000g0                 ç altered
set address=192.168.234.206                ç new entry
end
add device
set match=/dev/rmt/0
end
root@sol-test-1:>/#

And the complete entry of /testdir is removed


root@sol-test-1:>/# zonecfg -z clonedZone -f /export/zones/master

Now the entries in master file are copied to clonedZone

root@sol-test-1:>/# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   1 tzone4           running    /export/zones/tzone4           native   excl
   9 newzone          running    /export/zones/newzone          native   shared
   - tzone3           configured /export/zones/tzone3           native   excl
   - clonedZone       configured /export/zones/clonedZone       native   shared

root@sol-test-1:>/# zoneadm -z clonedZone install
Preparing to install zone <clonedZone>.
Creating list of files to copy from the global zone.
Copying <2923> files to the zone.

root@sol-test-1:>/# zoneadm -z clonedZone boot
root@sol-test-1:>/# zlogin -C clonedZone
[Connected to zone 'clonedZone' console]

============answer all the questions==========

clonedZone console login: root
Password:
Dec 23 21:59:50 clonedZone login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# ifconfig -a
lo0:2: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.234.206 netmask ffffff00 broadcast 192.168.234.255
# ping 192.168.234.134
192.168.234.134 is alive

SO…. We are done here…


No comments:

Post a Comment