viernes, 9 de marzo de 2012

Zonas Solaris 10 (Clonacion)

Cuando hablamos de virtualización por particionamiento del sistema operativo, es necesario hablar de zonas en solaris 10, antes había hecho mención a este tipo de  instancias del sistema operativo dentro del mismo en otro post. En esta oportunidad voy a hablar de como clonar zonas, pero antes, un repaso de como crear una zona en solaris.
El tema es bastante amplio, ya que a nivel de configuración es mucho lo que se puede hacer, en resumen hay tres comandos:
zonecfg: Permite configurar una zona (todos los parametros).
zoneadm: Instalar, borrar, clonar, arrancar, apagar, etc.
zlogin: Administra como entrar en la zona.

Creemos una zona basica y luego clonamos:
bash-3.2# zonecfg -z zona2
zona2: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zona2> create
zonecfg:zona2> set autoboot=true
zonecfg:zona2> set zon
set zonename=  set zonepath= 
zonecfg:zona2> set zonepath=/export/zona2
zonecfg:zona2> add net
zonecfg:zona2:net> set address=192.168.230.223
zonecfg:zona2:net> set physical=e1000g0
zonecfg:zona2:net> end
zonecfg:zona2> commit
zonecfg:zona2> verify
zonecfg:zona2> exit
bash-3.2#

Recomendación: Para colocar la dirección ip de la zona, debemos fijarnos previamente en la dirección ip de la zona global o del equipo huesped (ifconfig -a es el comando indicado).

Ahora instalemos la zona:
bash-3.2# zoneadm -z zona2 install
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <2889> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1200> packages on the zone.
Initialized <1200> packages on zone.                                
Zone is initialized.
The file contains a log of the zone installation.
bash-3.2#


Arrancamos la zona:
bash-3.2# zoneadm -z zona2 boot
bash-3.2# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   2 zona1            running    /export/zona1                  native   shared
   3 zona2            running    /export/zona2                  native   shared
   - zona7            installed  /export/zona7                  native   shared
bash-3.2#


Entramos en la zona y culminamos su instalación:
bash-3.2# zlogin -C zona2
[Connected to zone 'zona2' console]
Select a Language

  0. English
  1. es
  2. fr

Please make a choice (0 - 2), or press h or ? for help: 0
Select a Locale

  0. English (C - 7-bit ASCII)
  1. Canada (English) (UTF-8)
  2. Canada-English (ISO8859-1)
  3. U.S.A. (UTF-8)
  4. U.S.A. (en_US.ISO8859-1)
  5. U.S.A. (en_US.ISO8859-15)
  6. Go Back to Previous Screen

Please make a choice (0 - 6), or press h or ? for help: 5
What type of terminal are you using?
 1) ANSI Standard CRT
 2) DEC VT52
 3) DEC VT100
 4) Heathkit 19
 5) Lear Siegler ADM31
 6) PC Console
 7) Sun Command Tool
 8) Sun Workstation
 9) Televideo 910
 10) Televideo 925
 11) Wyse Model 50
 12) X Terminal Emulator (xterms)
 13) CDE Terminal Emulator (dtterm)
 14) Other
Type the number of your choice and press Return: 3

-Host Name for e1000g0:2 -----------------------------------------------------------------------
  Enter the host name which identifies this system on the network.  The name
  must be unique within your domain; creating a duplicate host name will cause
  problems on the network after you install Solaris.

  A host name must have at least one character; it can contain letters,
  digits, and minus signs (-).
             Host name for e1000g0:2 zona2                          
--------------------------------------------------------------------------------------------------------------
    F2_Continue    F6_Help
- Confirm Information for e1000g0:2 -----------------------------------------------------------------------

  > Confirm the following information.  If it is correct, press F2;
    to change any information, press F4.
 

                          Host name: zona2--------------------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-4_Change    Esc-6_Help
- Configure Security Policy: -----------------------------------------------------------------------

  Specify Yes if the system will use the Kerberos security mechanism.

  Specify No if this system will use standard UNIX security.
----------------------------------------------------------------------------------------------------
      Configure Kerberos Security

      [ ] Yes
      [X] No
--------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-6_Help
- Confirm Information -----------------------------------------------------------------------

  > Confirm the following information.  If it is correct, press F2;
    to change any information, press F4.

        Configure Kerberos Security: No
--------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-4_Change    Esc-6_Help-
- Name Service -----------------------------------------------------------------------------------

  On this screen you must provide name service information.  Select the name
  service that will be used by this system, or None if your system will either
  not use a name service at all, or if it will use a name service not listed
  here.

  > To make a selection, use the arrow keys to highlight the option
    and press Return to mark it [X].


      Name service
--------------------------------------------------------------------------------------------------------
      [ ] NIS+
      [ ] NIS
      [ ] DNS
      [ ] LDAP
      [X] None
---------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-6_Help
- Confirm Information ---------------------------------------------------------------------------
  > Confirm the following information.  If it is correct, press F2;
    to change any information, press F4.

                       Name service: None
------------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-4_Change    Esc-6_Help
- NFSv4 Domain Name ---------------------------------------------------------------------------

  NFS version 4 uses a domain name that is automatically derived from the
  system's naming services. The derived domain name is sufficient for most
  configurations. In a few cases, mounts that cross domain boundaries might
  cause files to appear to be owned by "nobody" due to the lack of a common
  domain name.

  The current NFSv4 default domain is: ""


      NFSv4 Domain Configuration
 
------------------------------------------------------------------------------------------------------------
      [X] Use the NFSv4 domain derived by the system
      [ ] Specify a different NFSv4 domain
-------------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-6_Help
- Confirm Information for NFSv4 Domain ---------------------------------------------------

  > Confirm the following information.  If it is correct, press F2;
    to change any information, press F4.


                 NFSv4 Domain Name:  << Value to be derived dynamically >


--------------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-4_Change    Esc-6_Help
-Time Zone --------------------------------------------------------------------------------------------

  On this screen you must specify your default time zone.  You can specify a
  time zone in three ways:  select one of the continents or oceans from the
  list, select other - offset from GMT, or other - specify time zone file.

  > To make a selection, use the arrow keys to highlight the option and
    press Return to mark it [X].

      Continents and Oceans
-----------------------------------------------------------------------------------------------------------
  ^   [ ] Arctic Ocean
  x   [ ] Asia
  x   [ ] Atlantic Ocean
  x   [ ] Australia    
  x   [ ] Europe       
  x   [ ] Indian Ocean 
  x   [ ] Pacific Ocean
  x   [x] other - offset from GMT
  -   [ ] other - specify time zone file
------------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-6_Help
- Offset From GMT -----------------------------------------------------------------------
  Specify the number of hours of difference between Greenwich Mean Time (also
  called Coordinated Universal Time) and your time zone.  If you are west of
  Greenwich, England, enter a positive number 12 through 1; if you are east of
  Greenwich, England enter a negative number -1 through -13.


     -6
-------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-5_Cancel    Esc-6_Help
- Confirm Information -------------------------------------------------------------------------
  > Confirm the following information.  If it is correct, press F2;
    to change any information, press F4.


                          Time zone: -6
--------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-4_Change    Esc-6_Help
- Root Password --------------------------------------------------------------------------------

  Please enter the root password for this system.

  The root password may contain alphanumeric and special characters.  For
  security, the password will not be displayed on the screen as you type it.

  > If you do not want a root password, leave both entries blank.


                     Root password:  ****
                     Root password:  ****           
---------------------------------------------------------------------------------------------------------
    Esc-2_Continue    Esc-6_Help
rebooting system due to change(s) in /etc/default/init


[NOTICE: Zone rebooting]


SunOS Release 5.10 Version Generic_147441-01 32-bit
Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved.
Hostname: zona2

zona2 console login:
Password:
]Mar  9 05:23:16 zona2 login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
#
# bash
bash-3.2# hostname
zona2
bash-3.2#
zona2 console login: ~.
[Connection to zone 'zona2' console closed]
bash-3.2#


Ahora para clonar, necesitamos, apagar la zona:
bash-3.2# zoneadm -z zona2 halt

Crear una plantilla (un template):
bash-3.2# zonecfg -z zona2 export -f /export/plantilla

Cuando editamos la plantilla, tiene los datos de la zona que usamos como plantilla de clonación:
bash-3.2# vi /export/plantilla
create -b
set zonepath=/export/zona2
set autoboot=true
set ip-type=shared
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 net
set address=192.168.230.223
set physical=e1000g0
end


Modificamos los datos para nuestra nueva zona (direccion ip, nombre, ruta):
create -b
set zonepath=/export/zona4
set autoboot=true
set ip-type=shared
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 net
set address=192.168.230.224
set physical=e1000g0
end

Usamos el comando zonecfg para crear nuestra nueva zona:
bash-3.2# zonecfg -z zona4 -f /export/plantilla

Ahora es necesario clonar de la zona original:
bash-3.2# zoneadm -z zona4 clone zona2

Ahora arrancamos nuestras dos zonas, la zona de plantilla y nuestra nueva zona:
bash-3.2# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   2 zona1            running    /export/zona1                  native   shared
   - zona2            installed  /export/zona2                  native   shared
   - zona7            installed  /export/zona7                  native   shared
   - zona4            installed  /export/zona4                  native   shared
bash-3.2#
bash-3.2# zoneadm -z zona2 boot
bash-3.2# zoneadm -z zona4 boot
bash-3.2# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   2 zona1            running    /export/zona1                  native   shared
   6 zona2            running    /export/zona2                  native   shared
   7 zona4            running    /export/zona4                  native   shared
   - zona7            installed  /export/zona7                  native   shared


Ahora entramos en la zona y terminamos de establecer los parametros de instalación (los omito ya que son la misma instalacion anterior) y voila!!!!!:
bash-3.2# zlogin -C zona4

zona4 console login:
Password:
Last login: Fri Mar  9 05:23:16 on console
Mar  9 05:41:48 zona4 login: ROOT LOGIN /dev/console
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# bash
bash-3.2# hostname
zona4
bash-3.2#



Enjoy!!!

2 comentarios:

  1. Este comentario ha sido eliminado por un administrador del blog.

    ResponderEliminar
  2. Este comentario ha sido eliminado por un administrador del blog.

    ResponderEliminar