Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

How to RUN a much heavier Java web app top-of AWS EC2 Micro-Instance for almost FREE :-)


 *for DEMO purpose only (not suitable for production)


Amazon EC2 provides Free tire for Micro instances (which is a totally awesome almost free service), So thats a very cheap way to host Java Web App and checkout online! However the some biggie web apps seems like little bit heavier to tolerate on AWS micro instance (with 613MB of RAM) under default configurations. But there's a workaround to make it happen, by adding some more swap space (1GB) to Linux system. Follow the instructions here: https://forums.aws.amazon.com/thread.jspa?messageID=221044


After that do these stuff as well for more safety! (to get rid of: java.lang.OutOfMemoryError: PermGen space issue)
http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/


Connecting into EC2 instace using Filezilla FTP

If you don't like commandline tool, you can use Filezilla instead. Download and install Filezilla client.  Lauch Filezilla. Click Edit -> Settings and select SFTP under Connction. Click Add Keyfile to add the private key file you use for putty connection. Click OK.


Click File -> Site Manager, Click New Site, enter your AWS EC2's public DNS or IP in Host field. Choose SFTP, enter ec2-user in User field and click Connect.

Now you are connected to your EC2 instance with FileZilla.


If you still want to set up an FTP server on your AWS EC2. Below are steps to install VSFTP.
  1. login to  your AWS management console.
    • Go to EC2 and click the Security Groups link.
    • Then choose the default group and switch to the inbound tab (at the bottom of the page)
    • Add the port ranges as above (20-21 and 40000-41000) and apply the rule changes
  2. connect to your instance with putty.
  3. login as ec2-user
  4. sudo yum install vsftpd
  5. change the conf file. sudo vi /etc/vsftpd/vsftpd.conf. Add

  6. pasv_max_port=41000
    pasv_min_port=40000
    port_enable=YES
    pasv_enable=YES
    

  7. Add an FTP user (see instruction here)
  8. Start the FTP server. service vsftpd start 
______________________
Reference : http://lzw-programmingjourney.blogspot.com/2011/12/set-up-ftp-server-on-amazon-aws-ec2.html


Installing JDK on Amazon EC2, f*ck yea Oracle! xD

Today, I had to install the SunOracle JDK on some servers, so I visited the JDK download page to retrieve the direct download link for wget on each server:
$ wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm
After launching the command, the server redirects me to a 5K HTML file:
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
WAIT, WHAT? I can’t download the file if I don’t visit their download page to accept the OTN license.
Challenge accepted, I’m going to play with requests… What happens when I click on the archive link?
First request:
Request URL:http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm
Request Method:GET
Cookie:s_nr=some_integer; s_cc=true; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u3-download-1501626.html; s_sq=%5B%5BB%5D%5D
Okay, trying to play with cookie values (I deleted the useless values):
$ wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u3-download-1501626.html;" http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm

--2012-04-12 18:47:58--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm
Resolving download.oracle.com (download.oracle.com)... 24.29.138.48, 24.29.138.40
Connecting to download.oracle.com (download.oracle.com)|24.29.138.48|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm [following]
--2012-04-12 18:47:59--  https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm
Resolving edelivery.oracle.com (edelivery.oracle.com)... 2.18.222.174
Connecting to edelivery.oracle.com (edelivery.oracle.com)|2.18.222.174|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm?AuthParam=THEIR_AUTHPARAM [following]
--2012-04-12 18:48:00--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm?AuthParam=THEIR_AUTHPARAM
Connecting to download.oracle.com (download.oracle.com)|24.29.138.48|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 67667318 (65M) [application/x-redhat-package-manager]
Saving to: `jdk-7u3-linux-x64.rpm'
Fuck Yea.

More information

You can set what you want in gpw_e24, I think it’s a kind of referer. As for me, I’m using the download page URL.
According to the OTN BCL document for Java SE:
BY SELECTING THE “ACCEPT LICENSE AGREEMENT” (OR THE EQUIVALENT) BUTTON AND/OR BY USING THE SOFTWARE YOU ACKNOWLEDGE THAT YOU HAVE READ THE TERMS AND AGREE TO THEM.
Enjoy it!
Bonus

__________
REF:http://blog.kdecherf.com/2012/04/12/oracle-i-download-your-jdk-by-eating-magic-cookies/