Creating a web application using Cassandra.
Description:
Use one Cassandra cluster object ,one session object, and 4 Cassandra nodes
Pre-Requisites:
1. Acquired
VMware Fusion (to be able to create a virtual machine).
2. Acquired
Ubuntu ISO disk image (to have an operating system as a base for creating a
virtual machine).
3. Used
VMware Fusion to create a virtual machine from the disk image.
4. Installed
vim (a text editor) on the virtual machine.
5. Installed
curl (for referencing URLs on the command line).
6. Installed
Oracle JDK (to be able to create and run Java applications).
7. Installed
Apache Maven (for managing dependencies when developing an application).
8. Installed
Eclipse (to have a development environment for writing a Java application).
9. Installed
Tomcat (to be able to host and serve a Java application).
10. Downloaded
Apache Cassandra to the virtual machine.
Step by Step ( in a nutshell):
4. restart vm
9. Run the code ( right click on the code, Run As, Run on server)
10. Result will display on web browser
1. Create VM for each of the node
2. For each vm, specify a static IP address and
set the host name
- a. sudo vim /etc/hostname
3. for each vm, add the 4 IP address and host name
to the list of hosts
- a. sudo vim /etc/hosts
4. restart vm
5. for each vm, edit the cassandra.yaml file to
specify the listen_address, rpc_address, and seed nodes (vm1, vm2, vm3, and
vm4)
- a. vim /conf/cassandra.yaml
- a. listen address: IP address of the vm
- b. rpc_addres: IP address of the vm
- c. seeds: IP address of other nodes
6. Start cassandra on vms, use nodetool status to
watch it join the cluster, and then use nodetool cleanup for other vms
- a. startup: bin/cassandra -f
- b. check status: bin/nodetool status
- c. cleanup: bin/nodetool -h ip_address_of_node cleanup
7. At VM1, use eclipse to create a dynamic web project
- a. Create a servlet file for the new project
- b. Acquire the DataStax Java Driver file
- inside the doGet function, add the following code:
PrintWriter out = response.getWriter();
out.println("Web Project using Cassandra");
9. Run the code ( right click on the code, Run As, Run on server)
10. Result will display on web browser



No comments:
Post a Comment