Easy Setup Guide for BlazeDS: Zero to hero in (le

baacloud免费翻墙vpn注册使用


Ever wanted to get started with BlazeDS? A bug bit me yesterday that forced me to sit at my computer for hours on end until I could achieve two things: setting up Amazon's EC2 Webservice and getting up and running with BlazeDS.
I had to do quite a bit of hunting due to my inexperience with a few things, which led me to the conclusion that someone else out there might want to benefit from my Googling and bookmarking.
Anyone who is on a Mac (I'm on Leopard) should be able to follow along fairly easily, and if you're on Windows, it shouldn't be too bad to translate.
Setting up EC2
Shared hosting is soon become something of yesteryear. With resources like Amazon's Web Services, you can set up and have complete control over your own virtual web server with a very reasonable (and sensible) pricing system. It's ultra-scalable. You only pay for the storage, transfer, and server instances that you use. Little use = little money, yet if you find yourself having to scale for whatever reason, Amazon doesn't require you to do anything. You just get the bill for the extra usage that month. Perfect for someone like me.
Step 1: Sign up for EC2
This one's pretty easy, and I won't go into too much detail unless you have great difficulties filling out forms and registering credit card information.
The important part of this is that you'll get two things that are vital for your EC2 setup: a X509 certificate and a private key file. You can access these through the “View Access Key Identifiers” link under “Your Web Services Account.” Your files should look something like this:
# cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CL.pem
# pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
On to the next step.
Step 2: Set up command line tools
For this step, you'll need to start Terminal and have downloaded the command line tools from Amazon. The command line tools are simply some java classes that need to be unzipped to the location of your choice. I unzipped them to this location (.ec2) that I created: /Users/Cahlan/.ec2/
Now we're going to set up some environment variables. This will allow your ec2 command line tools to function. There are only a few, and you input them like so:
export EC2_HOME=/path/to/unzipped/tools
Mine was /Users/Cahlan/.ec2 or ~/.ec2 if you're already in the “Cahlan” folder.
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=~/.ec2/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
This sets our private key file, and
export EC2_CERT=~/.ec2/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
this sets our certificate file.
And since I'm on a Mac, I also have to set the environment variable for JAVA_HOME: JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
Some helpful links for this section:
# EC2 Development Guide
# Jesse Andrews: EC2 Setup
Step 3: Create keypair
One last step before we get dirty. We have to create a keypair so that we can authenticate with the web service. You'll do this with this command “ec2-add-keypair gsg-keypair” which will output the key to the terminal. I tried copying and pasting this into a text file with disastrous results. We'll just store the output to a file, it's a much easier way:
ec2-add-keypair gsg-keypair >> /Users/Cahlan/.ec2/keypair
Now the keypair is stored in a file called “keypair” in our .ec2 folder. We have to make sure the file is protected, or our SSH sessions won't work. Type this command to set the right permissions for your newly-made keypair file:
chmod 600 /Users/Cahlan/.ec2/keypair
Now we'll actually create our virtual server on EC2.
Step 4: Create Server Instance
If you've done everything right up until this point, you should be able to type the command
ec2-describe-images -o amazon
to see all of the available Amazon-supported images that you can use. If that didn't work, you'll need to review the previous steps to find out where you went wrong.
So, now we need to pick an image. I chose a Linux Fedora distro with Apache and MySQL already installed, looks like this: ec2-public-images/fedora-core4-apache-mySQL.manifest.xml
To actually install this image, you'll type a command similar to this:
ec2-run-instances ami-25b6534c -k gsg-keypair
We got that ami code from the previous “describe” command. This will start your instance up and running. You may need to wait a few moments for it to fully initialize, you can check the progress with
ec2-describe-instances
You'll know it's up and running when you see something very similar to this:
RESERVATION r-xxxxxxxx ############ default
INSTANCE i-xxxxxxxx ami-25b6534c ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com running gsg-keypair
Sweet! Now we need to quickly enable some ports:
ec2-authorize default -p 22 for SSH,
ec2-authorize default -p 80 for HTTP, and
ec2-authorize default -p 8400 for Tomcat/BlazeDS.
Test your new setup by navigating to this URL in your web browser: “ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com” replacing of course the “#” with the correct numbers from your ec2-describe-instances statement.
We're halfway there.
Some helpful links for this section:
# Rober Sosinksi: EC2 w/ Mac OSx
# Jesse Andrews: EC2 Setup
Set up BlazeDS
Step 5: Download Java JDK
Now we'll SSH into our server with the following command:
ssh -i /Users/Cahlan/.ec2/keypair root@ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com
If you've done everything right, you'll see some ASCII art and a greeting from Amazon.
Now we need the Java JDK installed. After changing to the root directory and creating a directory called “java” (mkdir java), I executed a wget:
wget -O /java/jdk-6u5-linux-i586.bin http://192.18.108.228/ECom/EComTicketServlet/BEGIN2FCA82FFFBA7733BAEFFC22E660E1F22/
-2147483648/2647525119/1/877946/877802/2647525119/2ts+/westCoastFSEND/
jdk-6u5-oth-JPR/jdk-6u5-oth-JPR:4/jdk-6u5-linux-i586.bin
(line wrapped)
You'll need to verify with the Java website that you get the correct URL. Your URL will probably be similar, or at least as painfully long.
A couple last steps, we'll change the permissions on the bin file and then execute it:
chmod +x /java/jdk-6u5-linux-i586.bin
./java/jdk-6u5-linux-i586.bin
You'll need to agree to the terms displayed in the output and then java will be installed.
Before we move on, let's set the appropriate environment vars for our BlazeDS to work.
export JAVA_HOME=/java/jdk1.6.0_05/bin
Some helpful links for this section:
# JDK Downloads Page
# JDK Install Instructions
Step 6: Download BlazeDS
We're pretty close now. We need to download BlazeDS, doing something very similar to what we did for the JDK:
Go back to root, make a “blaze” directory: cd ../
mkdir blaze
cd blaze
wget http://download.macromedia.com/pub/opensource/blazeds/blazeds_turnkey_3-0-0-544.zip
We're using the turnkey download of BlazeDS because it comes packaged with an integrated Tomcat server.
Now we just need to unzip the file:
unzip blazeds_turnkey_3-0-0-544.zip
Step 7: Startup Tomcat
Finally, we'll start our newly unpacked Tomcat server using this command:
./blaze/tomcat/bin/startup.sh
We should also start the sampledb for the samples app to work correctly:
/blaze/sampledb/startdb.sh
Some helpful links for this section:
# BlazeDS Install Guide
# BlazeDS Release Builds
Step 8: Check it Out
You can now admire and test your newly deployed BlazeDS install by going to http://your.long.url.amazon.com:8400
Not bad for implementing an entire LAMP setup along with Tomcat and BlazeDS in one sitting! See how your boss/clients react when you use all of these buzzwords in a sentence: Amazon EC2, Linux Fedora, Compute Cloud, BlazeDS, Tomcat. Kudos for whoever can make the sweetest sounding sentence with all of these. or maybe some sweet rhyme?

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏