AWS
29 Aug 2013

Restarting an AWS EC2 Instance

I find that I will shutdown EC2 instances that I don't need for some period of time. However, on restart, some of the settings are dynamically assigned, requiring additional steps to enable access.

On restart of the EC2 instance, a new public DNS and IP address.

SSH

Before you can connect to your re-started server with it's new name and IP address using ssh, you'll also need to know the public DNS name for your EC2 instance.
- Go to the EC2 console
- Click on the name associated with the app you just created
- Scroll down to the bottom of the page and you'll find the Public DNS field. It will be something like ec2-54-212-82-123.us-west-2.compute.amazonaws.com.

Now that you know the name of your server, you can connect to it with ssh using that name and the key pair you downloaded earlier. I'm using the Linux ssh command but you could also use putty. Here's the Linux command to login:

ssh ec2-user@ec2-54-212-82-123.us-west-2.compute.amazonaws.com -i ~/myssh.pem

Tomcat

To install and start Tomcat, SSH into the server and enter the commands:

sudo yum install tomcat7 tomcat7-webapps mcat7-docs-webapp tomcat7-admin-webapps
sudo service tomcat7 start

You should now be able to browse to your Tomcat server at http://<public DNS>:8080. You're public DNS address can be found under the Instances tab.

Tomcat Administration

You'll find the Tomcat logs in the directory

/var/log/tomcat7
/usr/share/tomcat7

To restart Tomcat:

sudo service tomcat7 restart
sudo chkconfig tomcat7 on

To access the Tomcat server from your web browser

http://<public DNS>:8080

To access your Grails app hosted on the server:

http://<public DNS>:8080/<appname>

Build & Re-Deploy Your Grails App

If you've been deploying to a local server, you may have to change your config.groovy settings:

tomcat.deploy.username="greg"
tomcat.deploy.url="http://ec2-54-213-13-21.us-west-2.compute.amazonaws.com:8080/manager/text"

and your datasource.groovy settings:

username = "root"
 password = "password"
 pooled = true
 dbCreate = "create-drop"
 driverClassName = "com.mysql.jdbc.Driver"
 url = "jdbc:mysql://aa1tci17q167sol.cpasdfe.us-west-2.rds.amazonaws.com:3306/ebdb?user=root&password=tourneycard"
 dialect = org.hibernate.dialect.MySQL5InnoDBDialect
 properties {
 validationQuery = "SELECT 1"
 testOnBorrow = true
 testOnReturn = true
 testWhileIdle = true
 timeBetweenEvictionRunsMillis = 1000 * 60 * 30
 numTestsPerEvictionRun = 3
 minEvictableIdleTimeMillis = 1000 * 60 * 30
 }
 }

With the Tomcat plugin installed, the following command will build and deploy the war file to your Tomcat server:

grails prod tomcat undeploy
grails prod tomcat deploy

 


Tags:
0 comments