Skip to content

Standalone EC2 Deployment

jappy edited this page Oct 26, 2011 · 1 revision

AMI To Use

Choose the latest Elastic Beanstalk Tomcat 6 ami:

  • ElasticBeanstalk-Tomcat6-32bit
  • ElasticBeanstalk-Tomcat6-64bit

Note that on these instances deployed war files can only access files within the app-server... the path to the files in their war file can be found with the following path:

webapps/ROOT/

The WEB-INF directory is here:

webapps/ROOT/

On the local file system it is here:

/usr/shared/tomcat6/webapps/ROOT

You can make a symbolic link to the webapps directory from your /home/ec2-user/ directory like so:

cd
ln -s /usr/share/tomcat6/webapps ~/webapps

This way you can deploy new war files by scp'ing them into that directory.

Configuration Preparation

Setting Java Options

sudo vi /usr/share/tomcat6/conf/tomcat6.conf

Change the Java VM Options as you see fit:

JAVA_OPTS="-server -Xms=1400m -Xmx=1400m"

Starting & Stopping Tomcat

When you startup an ElasticBeanstalk Tomcat instance the httpd and tomcat6 processes are not running.

[ec2-user@domU-12-31-39-0A-30-04 tomcat6]$ ps -A
  PID TTY          TIME CMD
    1 ?        00:00:00 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
    5 ?        00:00:00 watchdog/0
    6 ?        00:00:00 events/0
    7 ?        00:00:00 cpuset
    8 ?        00:00:00 khelper
   11 ?        00:00:00 netns
   12 ?        00:00:00 async/mgr
   17 ?        00:00:00 xenwatch
   18 ?        00:00:00 xenbus
   64 ?        00:00:00 sync_supers
   66 ?        00:00:00 bdi-default
   67 ?        00:00:00 kintegrityd/0
   68 ?        00:00:00 kblockd/0
   75 ?        00:00:00 kseriod
  111 ?        00:00:00 khungtaskd
  112 ?        00:00:00 kswapd0
  113 ?        00:00:00 ksmd
  164 ?        00:00:00 aio/0
  168 ?        00:00:00 crypto/0
  248 ?        00:00:00 khvcd
  291 ?        00:00:00 kstriped
  299 ?        00:00:00 kjournald
  308 ?        00:00:00 khubd
  321 ?        00:00:00 kauditd
  369 ?        00:00:00 udevd
  739 ?        00:00:00 dhclient
  768 ?        00:00:00 syslogd
  771 ?        00:00:00 klogd
  816 ?        00:00:00 udevd
  817 ?        00:00:00 udevd
  863 ?        00:00:00 sshd
  874 ?        00:00:00 ntpd
  890 ?        00:00:00 sendmail
  898 ?        00:00:00 sendmail
  907 ?        00:00:00 crond
  922 ?        00:00:00 atd
  942 ?        00:00:00 yum-updatesd
  944 ?        00:00:00 gam_server
  955 tty1     00:00:00 mingetty
  956 tty2     00:00:00 mingetty
  958 ?        00:00:00 sshd
  960 ?        00:00:00 sshd
  961 pts/0    00:00:00 bash
20566 pts/0    00:00:00 ps

Starting httpd

First go to the /etc/init.d directory:

cd /etc/init.d
[ec2-user@domU-12-31-39-12-34-56 init.d]$ sudo ./httpd start
Starting httpd:                                            [  OK  ]
[ec2-user@domU-12-31-39-12-34-56 init.d]$ ps -A
  PID TTY          TIME CMD
    1 ?        00:00:00 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
    5 ?        00:00:00 watchdog/0
    6 ?        00:00:00 events/0
    7 ?        00:00:00 cpuset
    8 ?        00:00:00 khelper
   11 ?        00:00:00 netns
   12 ?        00:00:00 async/mgr
   17 ?        00:00:00 xenwatch
   18 ?        00:00:00 xenbus
   64 ?        00:00:00 sync_supers
   66 ?        00:00:00 bdi-default
   67 ?        00:00:00 kintegrityd/0
   68 ?        00:00:00 kblockd/0
   75 ?        00:00:00 kseriod
  111 ?        00:00:00 khungtaskd
  112 ?        00:00:00 kswapd0
  113 ?        00:00:00 ksmd
  164 ?        00:00:00 aio/0
  168 ?        00:00:00 crypto/0
  248 ?        00:00:00 khvcd
  291 ?        00:00:00 kstriped
  299 ?        00:00:00 kjournald
  308 ?        00:00:00 khubd
  321 ?        00:00:00 kauditd
  369 ?        00:00:00 udevd
  739 ?        00:00:00 dhclient
  768 ?        00:00:00 syslogd
  771 ?        00:00:00 klogd
  816 ?        00:00:00 udevd
  817 ?        00:00:00 udevd
  863 ?        00:00:00 sshd
  874 ?        00:00:00 ntpd
  890 ?        00:00:00 sendmail
  898 ?        00:00:00 sendmail
  907 ?        00:00:00 crond
  922 ?        00:00:00 atd
  942 ?        00:00:00 yum-updatesd
  944 ?        00:00:00 gam_server
  955 tty1     00:00:00 mingetty
  956 tty2     00:00:00 mingetty
  958 ?        00:00:00 sshd
  960 ?        00:00:00 sshd
  961 pts/0    00:00:00 bash
20592 ?        00:00:00 httpd
20594 ?        00:00:00 httpd
20595 ?        00:00:00 httpd
20596 ?        00:00:00 httpd
20597 ?        00:00:00 httpd
20598 ?        00:00:00 httpd
20599 ?        00:00:00 httpd
20600 ?        00:00:00 httpd
20601 ?        00:00:00 httpd
20602 ?        00:00:00 flush-202:1
20603 pts/0    00:00:00 ps

Starting tomcat6

First go to the /etc/init.d directory:

cd /etc/init.d

When starting tomcat you should see something similar to the following:

[ec2-user@domU-12-31-39-12-34-56 init.d]$ sudo ./tomcat6 start
Starting tomcat6:                                          [  OK  ]
[ec2-user@domU-12-31-39-12-34-56 init.d]$ tail -f -n 1000 /usr/share/tomcat6/logs/*
==> /usr/share/tomcat6/logs/catalina.out <==
/usr/sbin/tomcat6: line 60: /usr/share/tomcat6/logs/catalina.out: Permission denied

==> /usr/share/tomcat6/logs/monitor_catalina.log <==

==> /usr/share/tomcat6/logs/monitor_catalina.log.lck <==

==> /usr/share/tomcat6/logs/tail_catalina.log <==

==> /usr/share/tomcat6/logs/tail_catalina.log.lck <==

==> /usr/share/tomcat6/logs/tail_catalina.log <==
Oct 26, 2011 6:46:37 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
Oct 26, 2011 6:46:37 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Oct 26, 2011 6:46:38 AM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 26, 2011 6:46:38 AM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
Oct 26, 2011 6:46:38 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3249 ms
Oct 26, 2011 6:46:38 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 26, 2011 6:46:38 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
Oct 26, 2011 6:46:38 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ROOT.war
Oct 26, 2011 6:46:40 AM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 26, 2011 6:46:40 AM org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
Oct 26, 2011 6:46:40 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1938 ms

Now verify that a java process is running (your tomcat instance):

[ec2-user@domU-12-31-39-12-34-56 init.d]$ ps -A
  PID TTY          TIME CMD
    1 ?        00:00:00 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
    5 ?        00:00:00 watchdog/0
    6 ?        00:00:00 events/0
    7 ?        00:00:00 cpuset
    8 ?        00:00:00 khelper
   11 ?        00:00:00 netns
   12 ?        00:00:00 async/mgr
   17 ?        00:00:00 xenwatch
   18 ?        00:00:00 xenbus
   64 ?        00:00:00 sync_supers
   66 ?        00:00:00 bdi-default
   67 ?        00:00:00 kintegrityd/0
   68 ?        00:00:00 kblockd/0
   75 ?        00:00:00 kseriod
  111 ?        00:00:00 khungtaskd
  112 ?        00:00:00 kswapd0
  113 ?        00:00:00 ksmd
  164 ?        00:00:00 aio/0
  168 ?        00:00:00 crypto/0
  248 ?        00:00:00 khvcd
  291 ?        00:00:00 kstriped
  299 ?        00:00:00 kjournald
  308 ?        00:00:00 khubd
  321 ?        00:00:00 kauditd
  369 ?        00:00:00 udevd
  739 ?        00:00:00 dhclient
  768 ?        00:00:00 syslogd
  771 ?        00:00:00 klogd
  816 ?        00:00:00 udevd
  817 ?        00:00:00 udevd
  863 ?        00:00:00 sshd
  874 ?        00:00:00 ntpd
  890 ?        00:00:00 sendmail
  898 ?        00:00:00 sendmail
  907 ?        00:00:00 crond
  922 ?        00:00:00 atd
  942 ?        00:00:00 yum-updatesd
  944 ?        00:00:00 gam_server
  955 tty1     00:00:00 mingetty
  956 tty2     00:00:00 mingetty
  958 ?        00:00:00 sshd
  960 ?        00:00:00 sshd
  961 pts/0    00:00:00 bash
20592 ?        00:00:00 httpd
20594 ?        00:00:00 httpd
20595 ?        00:00:00 httpd
20596 ?        00:00:00 httpd
20597 ?        00:00:00 httpd
20598 ?        00:00:00 httpd
20599 ?        00:00:00 httpd
20600 ?        00:00:00 httpd
20601 ?        00:00:00 httpd
20602 ?        00:00:00 flush-202:1
20959 ?        00:00:04 java
20983 pts/0    00:00:00 ps

To Stop:

cd /etc/init.d
sudo ./tomcat6 stop
sudo ./httpd stop

To tail logs:

tail -f -n 1000 /usr/share/tomcat6/logs/catalina.out