helio.loureiro.eng.br
  • Home
  • Unix
  • Linux
  • Blog
  • Python
  • Programação
  • Tudo
  • Suécia
  1. You are here:  
  2. Home
  3. Unix
  4. Solaris

Os artigos mais lidos de 2024

  • linux-br.org num ritmo mais lento
  • Criando um serviço de relay de DNS-over-HTTPS
  • Minha palestra sobre a história do Unix na IX BSD Day
  • Pedal forte de 2023 em dados do Google
  • Linux vs GNU/Linux

Criando máquinas virtuais no solaris com zoneadm

Details
Written by: Helio Loureiro
Category: Solaris
Published: May 18, 2013
Hits: 11698

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.

Modificando o hostid

Details
Written by: Helio Loureiro
Category: Solaris
Published: December 19, 2012
Hits: 8966

 

Invariavelmente eu preciso trocar o hostid de uma máquina com Solaris para realizar testes.  O objetivo não é pirataria, ou algo assim, mas testes de verificação de aplicativos com licença de uso, que são amarrados ao hostid da máquina.

Eu conhecia um programa para fazer isso, mas essa semana topei com uma explicação bem legal de como fazer manualmente a mudança, disponível aqui: 

How to Change the Hostid of a Sun Solaris Machine?

Baseado nessa explicação, montei um programa em perl pra conseguir fazer a mesma coisa de forma mais simplificada, o hostid.pl.


#! /usr/bin/perl

$HOSTID = "/usr/bin/hostid";
$SAVEORIG = "/etc/hostid.orig";
$ADB = "/usr/bin/adb";
$ADBOPTS = "-w -k /dev/ksyms /dev/mem";


sub Usage() {
  print "Use: $0 \n";
  print "\t note: hostid must be 8 chars long\n";
  exit(1);
}

if ($ENV{"USER"} ne "root") {
  print "This must be run as root.\n";
  exit(1);
}

$newhostid = $ARGV[0];
if (length($newhostid) != 8) {
  Usage();
}

if (! -f "$SAVEORIG") {
  print "Saving original hostid into $SAVEORIG\n";
  open(SAVE,">$SAVEORIG") or die "Impossible to save original hostid: $!\n";
  print SAVE `$HOSTID`;
  close SAVE;
}

$myhex = eval("0x".$newhostid);
$mystr = sprintf("%s", $myhex);

$i = 0;
$parts[$i] = substr($mystr, $i, 4);
$parts[$i + 1] = substr($mystr, $i + 4, 4);
$parts[$i + 2] = substr($mystr, $i + 8, 4);

for ($i = 0; $i <= 3; $i++) {
  foreach $p (split(//,$parts[$i])) {
	$hwserial[$i] .= ($p + 30);
  }
}
$hwserial[2] .= "0000";

$msg = "$ADB $ADBOPTS << EOF > /dev/null

hw_serial/W 0x".$hwserial[0]."
hw_serial+4/W 0x".$hwserial[1]."
hw_serial+8/W 0x".$hwserial[2]."
END

EOF
";
print "Applying hostid change into memory\n";
system($msg);
print "Enforcing new hostid across system\n";
system("/etc/rc2.d/S20sysetup");

Too many authentication failures - parte 2

Details
Written by: Helio Loureiro
Category: Solaris
Published: December 08, 2011
Hits: 8780

Finalmente cheguei à conclusão do motivo das falhas de SSH.  Eu não tinha me dado conta, mas o problema surgiu depois do upgrade do Ubuntu que estou usando no laptop, para a versão 11.10 (Oneiric).

Como fui conectar em um outro servidor e tive o mesmo erro, vi que não era problema do Solaris, mas sim do cliente ssh.  Então tentei uma conexão em modo de debug:


helio@shibboleet:~$ ssh -C -v slowlaris
OpenSSH_4.2p1 Debian-4.sesarge.2, OpenSSL 0.9.7m 23 Feb 2007 debug1: Reading configuration data /home/helio/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to slowlaris [1.2.3.103] port 22. debug1: Connection established. debug1: identity file /home/helio/.ssh/identity type 0 debug1: identity file /home/helio/.ssh/id_rsa type 1 debug1: identity file /home/helio/.ssh/id_dsa type 2 debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1.3 debug1: no match: Sun_SSH_1.1.3 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.2p1 Debian-4.sesarge.2 debug1: Unspecified GSS failure.  Minor code may provide more information Credentials cache file '/tmp/krb5cc_1000' not found debug1: Unspecified GSS failure.  Minor code may provide more information Credentials cache file '/tmp/krb5cc_1000' not found debug1: Unspecified GSS failure.  Minor code may provide more information debug1: Unspecified GSS failure.  Minor code may provide more information debug1: Unspecified GSS failure.  Minor code may provide more information SPNEGO cannot find mechanisms to negotiate debug1: Offering GSSAPI proposal: (null) debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 zlib debug1: kex: client->server aes128-cbc hmac-md5 zlib debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'slowlaris' is known and matches the RSA host key. debug1: Found key in /home/helio/.ssh/known_hosts:4 debug1: ssh_rsa_verify: signature correct debug1: Enabling compression at level 6. debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure.  Minor code may provide more information Credentials cache file '/tmp/krb5cc_1000' not found
debug1: Trying to start again debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering public key: /home/helio/.ssh/id_rsa debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Offering public key: /home/helio/.ssh/id_dsa Received disconnect from 1.2.3.103: 2: Too many authentication failures for minsat

Dessa vez olhei com mais atenção a saída do comando.  Notei vários erros com a mensagem "Unspecified GSS failure.  Minor code may provide more information" e uma referência aos tipos de autenticação "gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive".  Então busquei pelos erros de ssh com gssapi na Internet e... BINGO!  Achei uma opção simples para desativar o mesmo, que deve ter mudado com o upgrade do openssl.  Basta passar o parâmetro "-o GSSAPIAuthentication=no".


helio@shibboleet:~$ ssh -C -v -o GSSAPIAuthentication=no slowlaris
OpenSSH_4.2p1 Debian-4.sesarge.2, OpenSSL 0.9.7m 23 Feb 2007
debug1: Reading configuration data /home/helio/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for * debug1: Connecting to slowlaris [1.2.3.103] port 22. debug1: Connection established. debug1: identity file /home/helio/.ssh/identity type 0 debug1: identity file /home/helio/.ssh/id_rsa type 1 debug1: identity file /home/helio/.ssh/id_dsa type 2 debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1.3 debug1: no match: Sun_SSH_1.1.3 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.2p1 Debian-4.sesarge.2 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 zlib debug1: kex: client->server aes128-cbc hmac-md5 zlib debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'slowlaris' is known and matches the RSA host key. debug1: Found key in /home/helio/.ssh/known_hosts:4 debug1: ssh_rsa_verify: signature correct debug1: Enabling compression at level 6. debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering public key: /home/helio/.ssh/id_rsa debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Offering public key: /home/helio/.ssh/id_dsa debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive debug1: Next authentication method: keyboard-interactive Password:  debug1: Authentication succeeded (keyboard-interactive). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 debug1: Remote: Channel 0 set: LANG=en_US.UTF-8 Last login: Tue Dec  6 11:30:56 2011 from 1.2.3.7 Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
You have new mail.
[helio@slowlaris ~]> 

Para evitar digitar essa opção em todas as conexões, simplesmente adicionei o parâmetro em ".ssh/config".  E fim dos problemas.

Fonte: http://www.walkernews.net/2009/04/06/how-to-fix-scp-and-ssh-login-prompt-is-very-slow-in-linux/

Too many authentication failures

Details
Written by: Helio Loureiro
Category: Solaris
Published: December 07, 2011
Hits: 8437

Hoje fui brindado com essa mensagem ao tentar acessar por ssh uma workstation Sun Ultra 10 que tenho por aqui.  Simplesmente não conseguia conectar por ssh.


helio@shibboleet:~$ ssh ultra10
  Received disconnect from 1.2.3.241: 2: Too many authentication failures for helio

Felizmente o acesso por telnet estava disponível.  Não encontrei nada relacionado à ssh que pudesse estar bloqueando meu acesso.  Mas como estava rodando um programa que testava acesso via ssh para outra máquina, que abria várias threads, imaginei que isso tivesse matado todo os meus max_files_open disponíveis.

Mas mesmo matando todos os processos ssh, continuei com esse problema.


ultra10{root} #: ps -ef | grep -i ssh | awk '{print $2}' | xargs kill -9

Tentei parar o serviço e abrir o ssh em modo de debug: 


ultra10{root} #: svcadm disable ssh
ultra10{root} #: /usr/lib/ssh/sshd -f -dd

Mas também sem nenhuma ajuda claro.  Olhando na Internet achei que era possível arrumar isso alterando o parâmetro " MaxAuthTries".  Editei então o arquivo "/etc/ssh/sshd_config" e deixei as entrada da seguinte forma:


MaxAuthTries    60
MaxAuthTriesLog 30

O ssh voltou a funcionar.  Resta agora descobrir como meu programa com expect e threads causou isso.

Sun T5240 - máquina de gente grande

Details
Written by: Helio Loureiro
Category: Solaris
Published: June 07, 2009
Hits: 8367

Uma das vantagens de trabalhar em empresas multinacionais (incluindo gigantes da área de telecomunicações) é a possibilidade de brincar com máquinas de gente grande. T5240 da Sun é uma delas: 98 GB de RAM, 64 CPUs... Só roda Solaris 10, e da versão 10/08 (setembro de 2008) em diante.


T5240, No Keyboard 
Copyright 2008 Sun Microsystems, Inc. All rights reserved. 
OpenBoot 4.30.0, 98080 MB memory available, Serial #00112233. 
Ethernet address 0:21:28:cc:bb:aa, Host ID: 01234567.

Alguns desses gigantes será a base de dados de assinantes pré-pago (uns 3 milhões). Dois para redundância. Outro, um sistema de administração de VPN, para telefonia. Nada relacionado com VPN criptográfica, com túneis, etc de redes de computadores.

  1. Curso básico de Unix
  2. Atualizando pacotes no Solaris 10

Page 1 of 2

  • 1
  • 2

Estatísticas

  • Users 2
  • Articles 457
  • Articles View Hits 3237670

Imagem aleatória