Apesar do Linux hoje ser o "mainstream" dos Unixes¹, eu gosto muito do Solaris e da sua elegância em resolver algumas coisas. Existe o sistema de arquivo deles, o ZFS - Zeta File System, mas também tem o zoneadm, para criação rápida e fácil de máquinas virtuais.
A maior vantagem é a facilidade mesmo de replicar uma nova máquina dentro do sistema. Invariavelmente preciso fazer testes, e essa possibilidade me permite ter uma máquina guest solaris dentro do próprio solaris em apenas alguns minutos.
É preciso criar o diretório, ou zonas como é chamado pelo Solaris, onde os sistemas hospedados ficarão. Eu sigo uma receita de bolo da Oracle/Sun e sempre utilizo o diretório "/zones", mas é preciso verificar a possibilidade de espaço antes.
A permissão é sempre 700 para evitar que outros usuários do sistema host possam ver os arquivos dos sistemas guests.
Na criação do sistema, é preciso definir seu caminho, IP e qual interface física conectada. Eu tentei utilizar a loopback, mas verifiquei que só funciona mesmo com a interface de rede.
Esse são os passos de exemplo pra criação da máquina virtual "fake-solaris":
[root@solaris ~]# mkdir /zones # chmod 700 /zones # zonecfg -z fake-solaris fake-solaris: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:fake-solaris> create zonecfg:fake-solaris> set zonepath=/zones zonecfg:fake-solaris> set autoboot=true zonecfg:fake-solaris> add net zonecfg:fake-solaris:net> set address=192.168.0.1 zonecfg:fake-solaris:net> set physical=lo0 zonecfg:fake-solaris:net> end zonecfg:fake-solaris> verify zonecfg:fake-solaris> commit zonecfg:fake-solaris> exit
Em seguida é preciso usar o zoneadm para máquina virtual recém-criada para instalar o sistema operacional.
[root@solaris ~]# zoneadm -z fake-solaris install Preparing to install zone . Creating list of files to copy from the global zone. Copying files to the zone.
Tanto a instalação quanto a remoção do sistema podem ser conseguidos facilmente com o zoneadm.
[root@solaris ~]# zoneadm -z fake-solaris uninstall Are you sure you want to uninstall zone fake-solaris (y/[n])? y
Utilizando o comando "zoneadm list" é possível verificar as máquinas virtuais instaladas e seus estados correntes.
[root@solaris ~]# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - fake-solaris incomplete /zones native shared
A máquina se encontra como "incompleta" pois falta fazer sua instalação. Seguida da instalação, é preciso fazer o "boot" da nova máquina, do contrário a mesma ficará no estado de "instalada" mas não no de "rodando", que é o estado da máquina virtual totalmente em funcionamento.
[root@solaris ~]# zoneadm -z fake-solaris install Preparing to install zone . Creating list of files to copy from the global zone. Copying files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize packages on the zone. Initialized packages on zone. Zone is initialized. Installation of these packages generated errors: Installation of packages was skipped. Installation of these packages generated warnings: The file contains a log of the zone installation. [root@solaris ~]# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - fake-solaris installed /zones native shared You have new mail in /var/mail//root [root@solaris ~]# zoneadm -z fake-solaris boot [root@solaris ~]# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared 1 fake-solaris running /zones native shared
É preciso então conectar na máquina como se fosse via console. Para isso existe o comando "zlogin". O parâmetro "-C" é para justamente definir a conexão como se fosse via console (ILOM/ALOM) e eu utilizo o "-e" para definir "#" para sair da sessão, do contrário o padrão fica como "~", o que em geral mata minha sessão ssh.
A definição de saída é para definir a tecla de "escape", que deve ser usada junto com ".". A sequência de saída do "zlogin" fica como "#." então.
O que se segue no restante das telas é o mesmo que uma instalação normal de solaris. O único ponto é que o nome da máquina virtual (zona) não precisa ser o mesmo hostname da máquina.
[root@solaris ~]# zlogin -C -e '#' fake-solaris [Connected to zone 'fake-solaris' 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. (en_US.ISO8859-1) 4. U.S.A. (en_US.ISO8859-15) 5. Go Back to Previous Screen Please make a choice (0 - 5), or press h or ? for help: 3
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: 1 Creating new rsa public/private host key pair Creating new dsa public/private host key pair Configuring network interface addresses:.
─ Host Name ──────────────────────────────────────────────────────────────────── 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 fake-solaris ──────────────────────────────────────────────────────────────────────────────── Esc-2_Continue Esc-6_Help
─ Confirm Information ────────────────────────────────────────────────────────── > Confirm the following information. If it is correct, press F2; to change any information, press F4. Host name: fake-solaris ──────────────────────────────────────────────────────────────────────────────── 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 ────────────────────────────────── - [ ] Africa │ [X] Americas │ [ ] Antarctica │ [ ] Arctic Ocean │ [ ] Asia │ [ ] Atlantic Ocean │ [ ] Australia │ [ ] Europe v [ ] Indian Ocean ──────────────────────────────────────────────────────────────────────────────── Esc-2_Continue Esc-6_Help
─ Country or Region ──────────────────────────────────────────────────────────── > To make a selection, use the arrow keys to highlight the option and press Return to mark it [X]. Countries and Regions ───────────────────────────────── - [ ] United States │ [ ] Anguilla │ [ ] Antigua & Barbuda │ [ ] Argentina │ [ ] Aruba │ [ ] Bahamas │ [ ] Barbados │ [ ] Belize │ [ ] Bolivia │ [ ] Bonaire Sint Eustatius & Saba │ [X] Brazil │ [ ] Canada v [ ] Cayman Islands ──────────────────────────────────────────────────────────────────────────────── Esc-2_Continue Esc-6_Help
─ Time Zone ──────────────────────────────────────────────────────────────────── > To make a selection, use the arrow keys to highlight the option and press Return to mark it [X]. Time zones ────────────────────────────────────────────────────── - [ ] Atlantic islands │ [ ] Amapa, E Para │ [ ] NE Brazil (MA, PI, CE, RN, PB) │ [ ] Pernambuco │ [ ] Tocantins │ [ ] Alagoas, Sergipe │ [ ] Bahia │ [X] S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS) │ [ ] Mato Grosso do Sul │ [ ] Mato Grosso │ [ ] W Para │ [ ] Rondonia v [ ] Roraima ──────────────────────────────────────────────────────────────────────────────── Esc-2_Continue Esc-6_Help
─ Confirm Information ────────────────────────────────────────────────────────── > Confirm the following information. If it is correct, press F2; to change any information, press F4. Time zone: S & SE Brazil (GO, DF, MG, ES, RJ, SP, P> (Brazil/East) ──────────────────────────────────────────────────────────────────────────────── 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-09 64-bit Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved. Hostname: fake-solaris [root@solaris ~]# zlogin -C -e '#' fake-solaris [Connected to zone 'fake-solaris' console]
Eu sempre sigo o site da Oracle para referência na criação e gerenciamento de máquinas virtuais:
Solaris 10: Zone Creation for Dummies
[1] Linux não é derivado do Unix, como o FreeBSD. Ele é um projeto que se baseia no Minix.