Friday, December 28, 2012

Cassandra - installing on Ubuntu 12.04 Amazon EC2

> sudo apt-get update

> sudo vi /etc/apt/sources.list

Add the following lines:
deb http://www.apache.org/dist/cassandra/debian 12x main
deb-src http://www.apache.org/dist/cassandra/debian 12x main
> sudo apt-get update

You would get 
W: GPG error: http://www.apache.org 10x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4BD736A82B5C1B00
Request the public key. You may need to change the public key (bold text above) when doing a gpg.

> gpg --keyserver wwwkeys.pgp.net --recv-keys 4BD736A82B5C1B00
> sudo apt-key add ~/.gnupg/pubring.gpg
> sudo apt-get update

> sudo apt-get install cassandra

> ps auwx | grep cassandra

> kill -9 {pid_of_cassandra}

Change the data, log locations:

> sudo vi /etc/cassandra/cassandra.yaml

Change the following locations if needed. (Cassandra does not run well on EBS - refer to the Apache Cassandra Document)
data_file_directories - (/var/lib/cassandra/data)
commitlog_directory -  (/var/lib/cassandra/commitlog)
saved_caches_directory - (/var/lib/cassandra/saved_caches)


Start Cassandra with:
> sudo /etc/init.d/cassandra start

Stop Cassandra with:
> sudo /etc/init.d/cassandra stop

Note: If you see the following, that means Cassandra is already started
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
> netstat -tulpn

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:8005          0.0.0.0:*               LISTEN      20358/java    
tcp        0      0 127.0.0.1:9160          0.0.0.0:*               LISTEN      5996/jsvc.exec
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      18848/mysqld  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      20358/java    
tcp        0      0 0.0.0.0:47697           0.0.0.0:*               LISTEN      5996/jsvc.exec
tcp        0      0 0.0.0.0:50324           0.0.0.0:*               LISTEN      5996/jsvc.exec
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      619/sshd      
tcp        0      0 127.0.0.1:7000          0.0.0.0:*               LISTEN      5996/jsvc.exec
tcp        0      0 0.0.0.0:7199            0.0.0.0:*               LISTEN      5996/jsvc.exec
tcp6       0      0 :::22                   :::*                    LISTEN      619/sshd      
udp        0      0 0.0.0.0:68              0.0.0.0:*                           431/dhclient3  

If Cassandra is running, you should see, port 9160, 7000 and 7199 being in used

> sudo service cassandra status
This should return the status of Cassandra

No comments:

Post a Comment