How To : Install Cassandra on CentOS 6.5

I think its time to learn new technologies aside from Oracle. currently we are on the process of looking in moving our Oracle DB’s to other platform.

1. Install Oracle Java Runtime from Oracle. it is recommended to you Oracle Java instead of Open Java.

[cassandra@cassandra01lnx ~]$ sudo rpm -ivh jre-7u60-linux-x64.rpm
Preparing...                ########################################### [100%]
   1:jre                    ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
[cassandra@cassandra01lnx ~]$ cd /usr/java
[cassandra@cassandra01lnx java]$ ls -lrt
total 8
drwxr-xr-x. 8 root root 4096 Jun 12 16:02 jdk1.7.0_51
lrwxrwxrwx. 1 root root   16 Jun 12 16:02 default -> /usr/java/latest
drwxr-xr-x. 6 root root 4096 Jun 12 16:07 jre1.7.0_60
lrwxrwxrwx. 1 root root   21 Jun 12 16:07 latest -> /usr/java/jre1.7.0_60

[cassandra@cassandra01lnx jre1.7.0_60]$ sudo alternatives --install /usr/bin/java java /usr/java/jre1.7.0_60/bin/java 20000
[cassandra@cassandra01lnx jre1.7.0_60]$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

[cassandra@cassandra01lnx jre1.7.0_60]$ sudo alternatives --config java

There are 5 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/java/jdk1.7.0_51/bin/java
   4           /usr/java/jdk1.7.0_51/jre/java
   5           /usr/java/jre1.7.0_60/bin/java
Enter to keep the current selection[+], or type selection number: 5

[cassandra@cassandra01lnx jre1.7.0_60]$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
[cassandra@cassandra01lnx jre1.7.0_60]$ 

2. Install JNA using YUM

[cassandra@cassandra01lnx jre1.7.0_60]$ sudo yum install jna
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.mirror.secureax.com
 * extras: centos.mirror.secureax.com
 * updates: centos.mirror.secureax.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package jna.x86_64 0:3.2.4-2.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================================
 Package                                  Arch                                        Version                                           Repository                                 Size
========================================================================================================================================================================================
Installing:
 jna                                      x86_64                                      3.2.4-2.el6                                       base                                      232 k
Transaction Summary
========================================================================================================================================================================================
Install       1 Package(s)
Total download size: 232 k
Installed size: 298 k
Is this ok [y/N]: y
Downloading Packages:
jna-3.2.4-2.el6.x86_64.rpm                                                                                                                                       | 232 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : jna-3.2.4-2.el6.x86_64                                                                                                                                               1/1
  Verifying  : jna-3.2.4-2.el6.x86_64                                                                                                                                               1/1
Installed:
  jna.x86_64 0:3.2.4-2.el6                                                                                                                                                             
Complete!
[cassandra@cassandra01lnx jre1.7.0_60]$ 

3.Configure System Parameters

- Set system limits
add below the end of /etc/security/limits.conf
*       soft nofile             32768
*       hard nofile             32768
root    soft nofile             32768
root    hard nofile             32768
*       soft memlock            unlimited
*       hard memlock            unlimited
root    soft memlock            unlimited
root    hard memlock            unlimited
*       soft as                 unlimited
*       hard as                 unlimited
root    soft as                 unlimited
root    hard as                 unlimited

- Set Virtual memory
[root@cassandra01lnx lib]# sysctl -w vm.max_map_count=13172
vm.max_map_count = 13172

- Disable swap
[root@cassandra01lnx lib]# swapoff --all
[root@cassandra01lnx lib]# 

-Set read ahead to 512
[root@cassandra01lnx lib]# blockdev --report /dev/sda1
RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   256   512  1024       2048       524288000   /dev/sda1
[root@cassandra01lnx lib]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_linux64base-lv_root
                       18G  3.1G   14G  19% /
tmpfs                 495M   76K  495M   1% /dev/shm
/dev/sda1             485M   56M  404M  13% /boot
[root@cassandra01lnx lib]# blockdev --setra 512 /dev/sda1
[root@cassandra01lnx lib]# blockdev --report /dev/sda1
RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   512   512  1024       2048       524288000   /dev/sda1
[root@cassandra01lnx lib]#

4.Install Cassandra using YUM

[cassandra@cassandra01lnx apache-cassandra-1.2.16-src]$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
[cassandra@cassandra01lnx ~]$ cd
[cassandra@cassandra01lnx ~]$ sudo vi /etc/yum.repos.d/datastax.repo
[cassandra@cassandra01lnx ~]$ cat /etc/yum.repos.d/datastax.repo
[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0
[cassandra@cassandra01lnx ~]$
[cassandra@cassandra01lnx ~]$ sudo yum install dsc12-1.2.10-1 cassandra12-1.2.10-1
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.mirror.secureax.com
 * extras: centos.mirror.secureax.com
 * updates: centos.mirror.secureax.com
datastax                                                                                                                                                         |  951 B     00:00    
datastax/primary                                                                                                                                                 |  24 kB     00:00    
datastax                                                                                                                                                                        123/123
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package cassandra12.noarch 0:1.2.10-1 will be installed
---> Package dsc12.noarch 0:1.2.10-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================================
 Package                                        Arch                                      Version                                     Repository                                   Size
========================================================================================================================================================================================
Installing:
 cassandra12                                    noarch                                    1.2.10-1                                    datastax                                     13 M
 dsc12                                          noarch                                    1.2.10-1                                    datastax                                    1.5 k
Transaction Summary
========================================================================================================================================================================================
Install       2 Package(s)
Total download size: 13 M
Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): cassandra12-1.2.10-1.noarch.rpm                                                                                                                           |  13 MB     00:54    
(2/2): dsc12-1.2.10-1.noarch.rpm                                                                                                                                 | 1.5 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                   240 kB/s |  13 MB     00:56    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : cassandra12-1.2.10-1.noarch                                                                                                                                          1/2
  Installing : dsc12-1.2.10-1.noarch                                                                                                                                                2/2
  Verifying  : dsc12-1.2.10-1.noarch                                                                                                                                                1/2
  Verifying  : cassandra12-1.2.10-1.noarch                                                                                                                                          2/2
Installed:
  cassandra12.noarch 0:1.2.10-1                                                                 dsc12.noarch 0:1.2.10-1                                                               
Complete!
[cassandra@cassandra01lnx ~]$ 

5.Start and Verify the newly installed cassandra.
– ISSUES ENCOUNTERED!!

a.The stack size specified is too small, Specify at least 228k
[cassandra@cassandra01lnx jre1.7.0_60]$ sudo service cassandra status
cassandra dead but pid file exists
[cassandra@cassandra01lnx jre1.7.0_60]$ cassandra -f
xss =  -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms494M -Xmx494M -Xmn123M -XX:+HeapDumpOnOutOfMemoryError -Xss180k
The stack size specified is too small, Specify at least 228k
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

edit /etc/cassandra/default.conf/cassandra-env.sh and update below line
if [ "`uname`" = "Linux" ] ; then
    # reduce the per-thread stack size to minimize the impact of Thrift
    # thread-per-client.  (Best practice is for client connections to
    # be pooled anyway.) Only do so on Linux where it is known to be
    # supported.
    # u34 and greater need 180k
    JVM_OPTS="$JVM_OPTS -Xss180k"   <<—— change to 256k
fi

b.Local host name unknown: java.net.UnknownHostException: cassandra01lnx: cassandra01lnx
[cassandra@cassandra01lnx jre1.7.0_60]$ sudo service cassandra start
Starting Cassandra: OK
[cassandra@cassandra01lnx jre1.7.0_60]$ sudo service cassandra status
cassandra dead but pid file exists
[cassandra@cassandra01lnx jre1.7.0_60]$ cassandra -f
xss =  -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms494M -Xmx494M -Xmn123M -XX:+HeapDumpOnOutOfMemoryError -Xss256k
Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: cassandra01lnx: cassandra01lnx
[cassandra@cassandra01lnx jre1.7.0_60]$

edit /etc/hosts and add the server hostname then start again.

[cassandra@cassandra01lnx jre1.7.0_60]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.166cassandra01lnx
[cassandra@cassandra01lnx jre1.7.0_60]$ 

After fixiing the two above issue my cassandra starts.

[cassandra@cassandra01lnx ~]$ sudo service cassandra start
Starting Cassandra: OK

[cassandra@cassandra01lnx ~]$ sudo service cassandra status
cassandra (pid  8152) is running...

[cassandra@cassandra01lnx ~]$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Owns   Host ID                               Token                                    Rack
UN  127.0.0.1  14.03 KB   100.0%  51931ed5-4917-4154-abd2-d24a6f41a18b  -8210771774288386087                     rack1

[cassandra@cassandra01lnx ~]$ cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 3.1.7 | Cassandra 1.2.10 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Use HELP for help.
cqlsh> use system;
cqlsh:system> describe keyspaces;
system  system_traces

cqlsh:system> describe tables;

HintsColumnFamily  Migrations  batchlog  peer_events  schema_columnfamilies
IndexInfo          NodeIdInfo  hints     peers        schema_columns      
LocationInfo       Schema      local     range_xfers  schema_keyspaces    

cqlsh:system> select * from peers;
cqlsh:system>

6.Create New Keyspace and test table and Insert data.


[cassandra@cassandra01lnx ~]$ cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 3.1.7 | Cassandra 1.2.10 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Use HELP for help.
cqlsh> create schema testschema
   ... with replication = {'class':'SimpleStrategy', 'replication_factor':1};
cqlsh> describe keyspaces;

system  testschema  system_traces
cqlsh> use testschema;
cqlsh:testschema> create table user (
              ... user_id varchar primary key,
              ... first varchar,
              ... last varchar,
              ... age int
              ... );
              ... user_id varchar primary key,
              ... first varchar,
              ... last varchar,
              ... age int
              ... );
cqlsh:testschema> 
cqlsh:testschema> insert into user (user_id, first, last, age) values ('rfroncois', 'ronn', 'francois', 20);
cqlsh:testschema> select * from user;
 user_id  | age | first | last
-----------+-----+-------+----------
 rfroncois |  20 |  ronn | francois
cqlsh:testschema> 

thanks for visiting..

Advertisements

One thought on “How To : Install Cassandra on CentOS 6.5

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s