Linux – EC2 EBS AMI Instance stopping/restarting doesn’t start services

amazon ec2amazon-ebscentoslinux

I've recently been moving our instances to EBS instances (CentOS) and still have a bit of confusion on what's happening when I "stop" and instance. I have some of my services with runlevels 345 on but when I start a stopped instance the services don't start. What's actually happening when I issue a stop command to the instance, and how do I get my services to start automatically when I start the instance up again?

Best Answer

Stopping an EBS-backed AMI is the same as shutting it down, and is not some kind of frozen hibernation state.

  • Log in after starting a stopped instance, and run the uptime command. You'll see the server has only been up a short time.
  • Keep an existing ssh session active, then shut down the server from the EC2 Management Console, and you will see the same "The server is going down..." notice you would see if you executed the shutdown command.

Also:

  • STOP commands preserve the root EBS volume, and any attached volumes.
  • Root volumes that are associated with a stopped instance will still show as "in-use" in the Management Console
  • EBS-backed instances can be protected against accidental TERMINATION.
  • EBS volumes are destroyed by TERMINATION by default, but they don't have to be. This is a configurable option in most cases.

After startup, check all the system logs in /var/log to look for any errors from attempts to start services, and execute the dmesg command to see what happened on boot.