Veja os comandos ec2stop
/ ec2-stop-instances
que fazem parte das ferramentas da AWS
edit : este parece ser um problema específico da AMI que estou tentando desativar. Outras AMIs educadamente fechadas com o comando "sudo poweroff".
O objetivo é que uma instância do EC2 se desligue. Todas as minhas instâncias são Ubuntu 10.10.
Eu costumava ser capaz de executar o comando "sudo poweroff -n -f" e a instância seria encerrada. No entanto, agora as instâncias param de responder e localizam suas CPUs em 50%.
Eu tentei todas as combinações possíveis de shutdown / halt / poweroff e todas elas:
Detalhes adicionais / cenários exatos:
Executar sudo poweroff
: recebo o normal "O sistema está inativo para desligar agora!" mensagem. Então sou devolvido ao shell. O sistema não desliga. Se eu executar "sudo poweroff" novamente , o sistema parece desligar (conexões ssh terminadas), no entanto a AMI não desliga e permanece em um estado "em execução" com 50% constantes Uso da CPU (conforme monitorado no console de gerenciamento da AWS.
Executar sudo shutdown now
: recebo o normal "O sistema está em processo de manutenção AGORA!" mensagem, mas nada acontece. O sistema continua funcionando normalmente. Caçando o syslog vejo as seguintes mensagens:
-
Dec 21 16:24:36 ip-10-212-177-30 init: ssh main process (599) terminated with status 255
Dec 21 16:24:36 ip-10-212-177-30 init: rc main process (677) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: tty4 main process (678) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: tty5 main process (682) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: tty2 main process (685) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: tty6 main process (688) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: cron main process (692) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: irqbalance main process (701) killed by TERM signal
Dec 21 16:24:36 ip-10-212-177-30 init: tty3 main process (686) killed by TERM signal
Todas as mensagens de log depois de chamar "sudo poweroff"
sudo poweroff
==> auth.log <==
Dec 21 21:39:37 ip-10-244-74-146 sudo: ubuntu : TTY=pts/1 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/sbin/poweroff
==> wtmp <==
02~~~runlevel2.6.35-28-virtualR?N??
Broadcast message from ubuntu@ip-10-244-74-146
(/dev/pts/1) at 21:39 ...
The system is going down for power off NOW!
==> boot.log <==
init: Disconnected from system bus
init: dbus main process (663) killed by TERM signal
hostname: the specified hostname is invalid
o sistema ainda está em execução, sem alteração
sudo poweroff
==> wtmp <==
~~~shutdown2.6.35-28-virtual)R?N^?
não há mais arquivos de log, sistema trava, não é possível entrar no SSH, CPU gira a 50%
sudo halt -p --verbose
ubuntu@ip-10-2-22-35:~$ /sbin/runlevel
N 2
ubuntu@ip-10-2-22-35:~$ sudo halt -p --verbose
Calling shutdown
Broadcast message from ubuntu@ip-10-2-22-35
(/dev/pts/1) at 17:31 ...
The system is going down for power off NOW!
ubuntu@ip-10-2-22-35:~$ /sbin/runlevel
2 0
ubuntu@ip-10-2-22-35:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.1 2892 1732 ? Ss 17:21 0:00 /sbin/init
root 2 0.0 0.0 0 0 ? S 17:21 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 17:21 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 17:21 0:00 [migration/0]
root 5 0.0 0.0 0 0 ? S 17:21 0:00 [watchdog/0]
root 6 0.0 0.0 0 0 ? S 17:21 0:00 [events/0]
root 7 0.0 0.0 0 0 ? S 17:21 0:00 [cpuset]
root 8 0.0 0.0 0 0 ? S 17:21 0:00 [khelper]
root 9 0.0 0.0 0 0 ? S 17:21 0:00 [netns]
root 10 0.0 0.0 0 0 ? S 17:21 0:00 [async/mgr]
root 11 0.0 0.0 0 0 ? S 17:21 0:00 [pm]
root 12 0.0 0.0 0 0 ? S 17:21 0:00 [xenwatch]
root 13 0.0 0.0 0 0 ? S 17:21 0:00 [xenbus]
root 14 0.0 0.0 0 0 ? S 17:21 0:00 [sync_supers]
root 15 0.0 0.0 0 0 ? S 17:21 0:00 [bdi-default]
root 16 0.0 0.0 0 0 ? S 17:21 0:00 [kintegrityd/0]
root 17 0.0 0.0 0 0 ? S 17:21 0:00 [kblockd/0]
root 18 0.0 0.0 0 0 ? S 17:21 0:00 [ata_aux]
root 19 0.0 0.0 0 0 ? S 17:21 0:00 [ata_sff/0]
root 20 0.0 0.0 0 0 ? S 17:21 0:00 [khubd]
root 21 0.0 0.0 0 0 ? S 17:21 0:00 [kseriod]
root 22 0.0 0.0 0 0 ? S 17:21 0:00 [kmmcd]
root 24 0.0 0.0 0 0 ? S 17:21 0:00 [khungtaskd]
root 25 0.0 0.0 0 0 ? S 17:21 0:00 [kswapd0]
root 26 0.0 0.0 0 0 ? SN 17:21 0:00 [ksmd]
root 27 0.0 0.0 0 0 ? S 17:21 0:00 [aio/0]
root 28 0.0 0.0 0 0 ? S 17:21 0:00 [ecryptfs-kthrea]
root 29 0.0 0.0 0 0 ? S 17:21 0:00 [crypto/0]
root 35 0.0 0.0 0 0 ? S 17:21 0:00 [khvcd]
root 36 0.0 0.0 0 0 ? S 17:21 0:00 [kstriped]
root 37 0.0 0.0 0 0 ? S 17:21 0:00 [kmpathd/0]
root 38 0.0 0.0 0 0 ? S 17:21 0:00 [kmpath_handlerd]
root 39 0.0 0.0 0 0 ? S 17:21 0:00 [ksnapd]
root 40 0.0 0.0 0 0 ? S 17:21 0:00 [kondemand/0]
root 41 0.0 0.0 0 0 ? S 17:21 0:00 [kconservative/0]
root 143 0.0 0.0 0 0 ? S 17:21 0:00 [xfs_mru_cache]
root 144 0.0 0.0 0 0 ? S 17:21 0:00 [xfslogd/0]
root 145 0.0 0.0 0 0 ? S 17:21 0:00 [xfsdatad/0]
root 146 0.0 0.0 0 0 ? S 17:21 0:00 [xfsconvertd/0]
root 148 0.0 0.0 0 0 ? S 17:21 0:00 [xfsbufd/sda1]
root 149 0.0 0.0 0 0 ? S 17:21 0:00 [xfsaild/sda1]
root 150 0.0 0.0 0 0 ? S 17:21 0:00 [xfssyncd/sda1]
root 177 0.0 0.0 0 0 ? S 17:21 0:00 [flush-202:1]
root 183 0.0 0.0 2560 988 ? S 17:21 0:00 /sbin/plymouthd --mode=boot --attach-to-session
root 187 0.0 0.0 4484 1260 ? S 17:21 0:00 mountall --daemon
daemon 382 0.0 0.0 1968 536 ? Ss 17:22 0:00 portmap
root 413 0.0 0.0 2304 252 ? Ss 17:22 0:00 dhclient3 -e IF_METRIC=100 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp3/dhclient.eth0.leases eth0
statd 593 0.0 0.0 2104 824 ? Ss 17:22 0:00 rpc.statd -L
root 607 0.0 0.0 0 0 ? S 17:22 0:00 [kjournald]
root 624 0.0 0.0 0 0 ? S 17:22 0:00 [rpciod/0]
root 627 0.0 0.0 0 0 ? S< 17:22 0:00 [kslowd000]
root 628 0.0 0.0 0 0 ? S< 17:22 0:00 [kslowd001]
root 639 0.0 0.0 0 0 ? S 17:22 0:00 [nfsiod]
ganglia 684 0.0 0.0 4260 1644 ? Ss 17:22 0:00 /usr/sbin/gmond
root 723 0.0 0.1 52988 3168 ? Ss 17:22 0:00 php-fpm: master process (/etc/php5/fpm/main.conf)
www-data 724 0.0 0.1 52972 2536 ? S 17:22 0:00 php-fpm: pool www
www-data 725 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 726 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 727 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 728 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 729 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 730 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 731 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 732 0.0 0.1 52972 2540 ? S 17:22 0:00 php-fpm: pool www
www-data 733 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 734 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 735 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 736 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 737 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 738 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 739 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 740 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 741 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 742 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 743 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 744 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 746 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 747 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 748 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 750 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 751 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 753 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 754 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 755 0.0 0.1 52972 2652 ? S 17:22 0:00 php-fpm: pool www
www-data 756 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 757 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 758 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 759 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 760 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 761 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 762 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 763 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 764 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 765 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
www-data 766 0.0 0.1 52972 2656 ? S 17:22 0:00 php-fpm: pool www
root 1240 0.0 0.1 8848 3116 ? Ss 17:31 0:00 sshd: ubuntu [priv]
ubuntu 1334 0.0 0.0 8848 1368 ? S 17:31 0:00 sshd: ubuntu@pts/1
ubuntu 1335 0.5 0.3 9016 6048 pts/1 Ss 17:31 0:01 -bash
root 1373 0.0 0.0 1904 512 ? Ss 17:31 0:00 /bin/sh /etc/init.d/rc 0
root 1375 0.0 0.0 3000 1304 ? S 17:31 0:00 /bin/bash /etc/rc0.d/K01unregister stop
root 1394 0.0 0.1 5144 1952 ? S 17:31 0:00 ssh -i /XXXX [email protected] sudo sh -c 'sed -e "/10.2.22.35 fb?"-//W3C//DTD??lang="e
ubuntu 1400 0.0 0.0 4280 1088 pts/1 R+ 17:34 0:00 ps aux
última saída do console VMS depois de duas chamadas para interromper -p (em estado suspenso de 50% cpu)
init: tty2 main process (679) killed by TERM signal
init: tty3 main process (680) killed by TERM signal
init: tty6 main process (682) killed by TERM signal
init: hwclock-save main process (881) terminated with status 1
init: Disconnected from system bus
init: dbus main process (618) killed by TERM signal
hostname: the specified hostname is invalid
[ 52.346590] System halted.
Obrigado!
Veja os comandos ec2stop
/ ec2-stop-instances
que fazem parte das ferramentas da AWS
Por padrão, quando você encerra / suspende uma instância de inicialização do EBS, ela simplesmente é movida para o estado "interrompido". Isso deixa a instância disponível para reinicialização. Você não está mais pagando por horas de instância, mas continuará pagando uma taxa mínima pelos volumes do EBS.
Você pode alterar esse comportamento para que um shutdown / halt termine a instância definindo o comportamento de shutdown iniciado por instância como "terminate".
Eu escrevi um pouco sobre isso aqui:
Three Ways to Protect EC2 Instances from Accidental Termination and Loss of Data
http://alestic.com/2010/01/ec2-instance-locking
Você desejará executar a instância com a opção:
--instance-initiated-shutdown-behavior terminate
Com este sinalizador definido, um dos comandos a seguir terminará a instância do EC2:
sudo shutdown -h now
# or
sudo halt
Você também pode "Alterar o comportamento do desligamento" por meio do console da AWS para executar instâncias (clique com o botão direito do mouse).
Você já tentou:
echo o > /proc/sysrq-trigger
Dependendo do kernel que deve causar um poweroff imediato. Não há desligamento normal neste caso, mas se você não precisar da imagem novamente e começar de novo a cada vez, isso não importará.
Algum material de referência aqui: link