1.6. Create a Fabric Server on EC2
What is a Fabric Server?
The first step in creating a new fabric in the cloud is to create a Fabric Server instance. A Fabric Server is a container with a Fabric Registry Agent deployed inside it (there must be at least one Fabric Server in a fabric). You can think of it as a seed for the rest of the fabric.
What happens when you create a Fabric Server?
The
fabric:container-create-cloud
console command, which creates the Fabric Server, is a powerful command that does a lot of things:
- Using the JClouds library, it connects to the AWS and creates a new compute instance in the cloud.
- It uploads your SSH public key to the compute instance.
- It installs all of the basic prerequisites for provisioning and running a Red Hat JBoss Fuse container in the compute instance (for example, by installing JDK 1.6).
- It installs JBoss Fuse in the compute instance.
- It starts up the JBoss Fuse container and deploys a Fabric Registry Agent into the container, so that it functions as a Fabric Server.
- It modifies the EC2 firewall settings for the compute instance (if necessary, creating a new EC2 security group).
Creating a Fabric Server on a micro instance
To create a Fabric Server on a micro instance,
t1.micro
(in Amazon's free usage tier) using a Red Hat Enterprise Linux (RHEL) 6.4 image, enter the following console command:
JBossFuse:karaf@root> fabric:container-create-cloud --name aws-ec2 --ensemble-server --new-user admin --new-user-password admin --zookeeper-password admin --hardwareId t1.micro --os-family rhel --os-version 6.4 registry
This command creates a container called
registry
and the --ensemble-server
option makes the new container a Fabric Server. This command can take a minute or two to complete. If it is successfully, you should see output like the following:
Looking up for compute service. Creating 1 nodes on aws-ec2. It may take a while ... Node fabric-dcfaa2fd has been succesfully created. Installing fabric agent on container registry. It may take a while... Overriding resolver to publichostname. [id] [container] [registry password] [public addresses] [status] us-east-1/i-dcfaa2fd registry admin [54.224.255.118] success
Tip
In a production environment, you would need to allocate a permanent IP address to the Fabric Server. By default, when you restart an instance in EC2, the IP address is automatically re-allocated.
Creating a Fabric Server on a small instance
The amount of memory available in a micro instance is a bit limited for a Red Hat JBoss Fuse container instance. If you want to create a fabric for a production deployment, it is typically better to use at least a small instance,
m1.small
. You can create a small instance, as follows:
JBossFuse:karaf@root> fabric:container-create-cloud --name aws-ec2 --ensemble-server --new-user admin --new-user-password admin --zookeeper-password admin --hardwareId m1.small --os-family rhel --os-version 6.4 registry
Important
An
m1.small
instance is not covered by the Amazon free usage tier and incurs an hourly usage charge (until the instance is terminated).
SSH login to the new instance
It should now be possible to log on to the new compute instance using SSH. Open a new command prompt and enter the following command:
ssh 50.19.18.91
Where you provide the compute instance's public IP address as the argument to the
ssh
command (you could also use the compute instance's public hostname). The ssh command uses the default RSA private key as credentials.
If you did not put your SSH key pair in the default location, you can specify the private key location explicitly, as follows:
ssh -i PrivateKeyFile 50.19.18.91
Hardware list
If you want to see all of the hardware options available, use the
jclouds:hardware-list
console command:
karaf@root> jclouds:hardware-list [id] [ram] [cpu] [cores] cc1.4xlarge 23552 32.0 8.0 cg1.4xlarge 22528 32.0 8.0 cc2.8xlarge 61952 88.0 16.0 hi1.4xlarge 61952 35.0 16.0 hs1.8xlarge 119808 35.0 16.0 g2.2xlarge 15360 26.0 8.0 t1.micro 630 1.0 1.0 c1.medium 1740 5.0 2.0 c1.xlarge 7168 20.0 8.0 c3.xlarge 7168 14.0 4.0 c3.2xlarge 15360 28.0 8.0 c3.4xlarge 30720 55.0 16.0 c3.8xlarge 61440 108.0 32.0 i2.xlarge 31232 14.0 4.0 i2.2xlarge 62464 27.0 8.0 i2.4xlarge 124928 53.0 16.0 i2.8xlarge 249856 104.0 32.0 m1.large 7680 4.0 2.0 m1.small 1740 1.0 1.0 m1.medium 3750 2.0 1.0 m1.xlarge 15360 8.0 4.0 m2.xlarge 17510 6.5 2.0 m2.2xlarge 35020 13.0 4.0 m2.4xlarge 70041 26.0 8.0 m3.medium 3840 3.0 1.0 m3.large 7680 6.5 2.0 m3.xlarge 15360 13.0 4.0 m3.2xlarge 30720 26.0 8.0
Image list
If you want to find out what machine images are available on Amazon EC2, enter the following console command:
JBossFuse:karaf@root> jclouds:image-list
Groups and security
Fabric automatically configures an Amazon EC2 security group for the new containers (default is the
jclouds#fabric
security group). All of the containers in a fabric should belong to the same security group. By default, Fabric adds all of the cloud containers to the fabric
group. If necessary, you can specify the group explicitly by specifying the --group
option on the fabric:container-create-cloud
command.