Installing Apache Cassandra on Ubuntu
Installing Apache Cassandra on Ubuntu
Apache Cassandra is a distributed, extremely scalable, highly available and fault tolerant NoSQL database initiated by facebook.
Join the DZone community and get the full member experience.Join For Free
RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.
Apache Cassandra is a distributed, extremely scalable, highly available and fault tolerant NoSQL database initiated by facebook, later open sourced as an apache project. Cassandra data model is inspired by Google Bigtable and it's distribution model is inspired by Amazon Dynamo. If you are interested to know more about Cassandra you can refer to the paper written by Facebook.
This post will guide you how to install Cassandra on Ubuntu 12.04.
- Install the new updates using following commands
sudo apt-get update sudo apt-get upgrade
- open /etc/apt/sources.list using the following command
sudo gedit /etc/apt/sources.list
deb http://www.apache.org/dist/cassandra/debian 10x main deb-src http://www.apache.org/dist/cassandra/debian 10x main
- Run update again and you will get the following error. This means you need to add the PUBLIC_KEY. In next step you will understand how to add this PUBLIC_KEY.
GPG error: http://www.apache.org unstable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4BD736A82B5C1B00
- Register and add a PUBLIC_KEY key and update again, note that you may need to change the key accordingly
gpg --keyserver wwwkeys.pgp.net --recv-keys 4BD736A82B5C1B00 sudo apt-key add ~/.gnupg/pubring.gpg sudo apt-get update
- Install Cassandra using the following command
sudo apt-get install cassandra
- Start Cassandra server using the following command
sudo cassandra -f
.... .... .... INFO 12:18:29,140 Listening for thrift clients...
- To stop Cassandra server process first find the Process ID for Cassandra and kill it.
To find the process ID use following command
ps auwx | grep cassandra
root 3595 0.0 0.0 60048 1908 pts/0 S+ 12:18 0:00 sudo cassandra -f
sudo kill [pid]
INFO 13:04:08,663 Stop listening to thrift clients INFO 13:04:08,666 Waiting for messaging service to quiesce INFO 13:04:08,667 MessagingService shutting down server thread.
- Use following command to start Cassandra as a service
sudo /etc/init.d/cassandra start
- Use following command to stop Cassandra service
sudo /etc/init.d/cassandra stop
Installation will create following directories. Uses of them are mentioned within the brackets.
- /var/lib/cassandra (data directories)
- /var/log/cassandra (log directory)
- /var/run/cassandra (runtime files)
- /usr/share/cassandra (environment settings)
- /usr/share/cassandra/lib (JAR files)
- /usr/bin (binary files)
- /etc/cassandra (configuration files)
- /etc/init.d (service startup script)
- /etc/security/limits.d (cassandra user limits)
Installing JNA (Java Native Access) on Linux platforms can improve Cassandra memory usage. To install JNA, download jna.jar from here and add it to /usr/share/cassandra/lib directory.
If you get the following error while you try to start a Cassandra server, means that cassandra is already running in the background somewhere. You will need to kill the process that is running in the background first. You can probably use the above mentioned stop command to stop any Cassandra servers running background.
- Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7199; nested exception is:
- java.net.BindException: Address already in use
Here I have done the packaged installation, alternatively you can install Cassandra binary tarball installation on Ubuntu. Use this link for that.
Published at DZone with permission of Pavithra Gunasekara , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.