Running Hazelcast node on an Amazon EC2 instance
In this little tutorial I will show how simple it is to run an Hazelcast instance on an Amazon EC2 node.
The first thing we will do is launching a new EC2 node.
For doing this go to your AWS Management Console and select the Amazon EC2 tab.
On the Dashboard you will see a fancy really big (Launch Instance) button. Click on it and follow the instructions. For this tutorial I suppose to choose the following kind of an EC2 node:
- Basic 32-bit Amazon Linux AMI 1.0
- Instance Type: Micro (t1.mircro, 613 MB)
After doing this, the new instance is started.
Make sure that you safe the key file, which was produced during this process.
So now we can connect to the new Linux (EC2) instance via SSH.
If you’re already working on a UNIX system, you can use in a terminal
[sourcecode language="bash" light="true"]
~# ssh -i {path to your keyfile} ec2-user@{public DNS of EC2 node}
[/sourcecode]
If you’re using Windows, then you can use PuTTY following this tutorial
http://www.powercram.com/2009/07/connecting-to-aws-ec2-instance-linux.html
Now you should be connected with your EC2 instance. The next thing we will do is installing Hazelcast.
So first we have to download the actual version which can be found here.
Just start
[sourcecode language="bash" light="true"]
~# wget http://www.hazelcast.com/files/hazelcast-1.9.zip
[/sourcecode]
Then do the execute the following commands
[sourcecode language="bash" light="true"]
~# unzip -x hazelcast-1.9.zip
~# rm hazelcast-1.9.zip
~# cd hazelcast-1.9/bin/
[/sourcecode]
Now we’ll have to modify the configuration file of Hazelcast hazelcast.xml
Here I made the easiest config I could imagine.
[sourcecode language="xml"]
<hazelcast>
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<network>
<port auto-increment="true">5701</port>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<interface>{master_ip_here}</interface>
</tcp-ip>
</join>
<interfaces enabled="false">
<interface>10.*.*.*</interface>
</interfaces>
</network>
<map name="default">
<backup-count>1</backup-count>
<eviction-policy>NONE</eviction-policy>
<max-size>0</max-size>
<eviction-percentage>25</eviction-percentage>
</map>
</hazelcast>
[/sourcecode]
For the first time you can copy this configuration, but you have to edit this line to point at your Hazelcast master node
[sourcecode language="xml" light="true"]<interface>{master_ip_here}</interface>[/sourcecode]
If your gonna running Hazelcast on a single instance you can leave this blank or filling it with 127.0.0.1
After doing this be sure that your master node is already running.
So now you can start you Hazelcast instance like this
[sourcecode language="bash" light="true"]~/hazelcast-1.9/bin# sh run.sh[/sourcecode]
This is the output
[sourcecode language="bash" light="true"]
10.12.2010 15:50:02 com.hazelcast.config.XmlConfigBuilder
INFO: Using configuration file at /root/hazelcast-1.9/bin/hazelcast.xml
10.12.2010 15:50:03 com.hazelcast.system
INFO: [dev] Hazelcast 1.9 (20100912) starting at Address[xxx.xxx.xxx.xxx:5701]
10.12.2010 15:50:03 com.hazelcast.system
INFO: [dev] Copyright (C) 2008-2010 Hazelcast.com
10.12.2010 15:50:03 com.hazelcast.impl.LifecycleServiceImpl
INFO: [dev] Address[10.10.1.1:5701] is STARTING
10.12.2010 15:50:04 com.hazelcast.impl.Node
INFO: [dev]
Members [2] {
Member [{master_ip}:5071]
Member [10.10.1.1:5701] this
}
10.12.2010 15:50:04 com.hazelcast.impl.LifecycleServiceImpl
INFO: [dev] Address[85.214.131.218:5701] is STARTED
hazelcast[default] >
[/sourcecode]
Congratulation your Hazelcast node is running