, ,

I am going to use utility called csshx which allow me to type on multiple machine concurrently, you can see how to install it on this web site:http://www.unixmen.com/how-to-manage-multiple-ssh-sessions-using-cluster-ssh-and-pac-manager/

In my example, I am setting up 4 virtualbox centos 6.7 machine:

Machine:                            IP Address:

See below the windows of all my machines:


1) Setup firewall: we have to verify these ports open and available:

How to Configure Ubuntu’s Built-In Firewall: http://www.howtogeek.com/115116/how-to-configure-ubuntus-built-in-firewall/
How to Configure Centos ’s Built-In Firewall: http://msvaljek.blogspot.com/2015/01/setting-up-cassandra-cluster-in-virtual.html

2) User resource limits:

view the current limits using the ulimit -a command. DataStax recommends making the changes permanent:
Packaged installs: following settings are included in the /etc/security/limits.d/cassandra.conf file:

- memlock unlimited
- nofile 100000
- nproc 32768
- as unlimited

Tarball installs: settings are included in the /etc/security/limits.conf file:

- memlock unlimited
- nofile 100000
- nproc 32768
- as unlimited

For CentOS, RHEL, OEL systems, also set the nproc limits in /etc/security/limits.d/90-nproc.conf:

- nproc 32768

For all installations, add the following line to /etc/sysctl.conf:

vm.max_map_count = 131072

To make the changes take effect, reboot the server or run the following command:

$ sudo sysctl -p

3) Update the package:

sudo yum update

4) Installing vim:

sudo yum install vim

5) Installing JDK:

Install latest Java 7 release:Oracle JDK 1.7+ required for Cassandra 2.0+, 64 bit Oracle Java 7 preferred
We can use the shell script below to download and install Java
downloading the oracle JDK:

sudo wget --no-check-certificate --no-cookies --header "Cookie:oraclelicense=accept-securebackup-cookie"

we can also use this shell script (source:https://gist.github.com/P7h/9741922

Installing Oracle JDK on RHEL-based Systems:

Link : https://docs.datastax.com/en/cassandra/2.0/cassandra/install/installJdkRHEL.html

make a directory: mkdir -p /usr/java/latest
sudo mv jdk-8u51-linux-x64.tar.gz /usr/java/latest
cd /usr/java/latest ;sudo tar -zxf jdk-8u51-linux-x64.tar.gz
sudo /usr/sbin/alternatives --install "/usr/bin/java" "java" "/usr/java/latest/jdk1.8.0_51/bin/java" 1
sudo /usr/sbin/alternatives --config java
java -version
[hduser@base ~]$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Oracle JDK on Debian or Ubuntu Systems :

See this link:https://docs.datastax.com/en/cassandra/2.0/cassandra/install/installJdkDeb.html

• Configure JAVA_HOME on Centos:


• Install Java Native Access (JNA) libraries (prior to C*2.1) :

required for production systems
Installing the JNA on RHEL or CentOS Systems: see the link: https://docs.datastax.com/en/cassandra/2.0/cassandra/install/installJnaRHEL.
install jna:

sudo yum install jna

Installing the JNA on Debian or Ubuntu Systems:


6) Synchronize clocks on each node system:use NTP or similar tool

See this link: http://www.rackspace.com/knowledge_center/article/using-ntp-to-sync-time
All machines will have the same time

7) Disable Swap:

sudo swapoff -all

In production environment, the operating system could swap up if we don’t disable it, it can be difficult to reproduce.

8) Add the DataStax Community repository to the /etc/yum.repos.d/datastax.repo:

name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0

Install the packages:

$ sudo yum install dsc22
$ sudo yum install cassandra22-tools     ## Installs optional utilities

9) Now cassandra is running :

[hduser@base ~]$ ps -ef|grep java
475 1571 1 1 00:58 ? 00:19:44 /usr/lib/java/jdk1.8.0_40/bin/java -ea -javaagent:/usr/share/cassandra/lib/jamm-0.3.0.jar 
-XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1483M -Xmx1483M -Xmn200M -XX:
+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:
+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 
-XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -XX:+PerfDisableSharedMem -XX:
CompileCommandFile=/etc/cassandra/conf/hotspot_compiler -XX:CMSWaitDuration=10000 -XX:+CMSParallelInitialMarkEnabled 
-XX:+CMSEdenChunksRecordAlways -XX:CMSWaitDuration=10000 -XX:+UseCondCardMark -Djava.net.preferIPv4Stack=true 
-Dcassandra.jmx.local.port=7199 -XX:+DisableExplicitGC -Djava.library.path=/usr/share/cassandra/lib/sigar-bin 
-Dlogback.configurationFile=logback.xml -Dcassandra.logdir=/var/log/cassandra -Dcassandra.storagedir= 
-Dcassandra-pidfile=/var/run/cassandra/cassandra.pid -cp /etc/cassandra/conf:/usr/share/cassandra/lib/airline-0.6.jar:

We have to stop all Cassandra:

sudo service Cassandra stop

Then delete all directory of Cassandra :

cd /var/lib/Cassandra/
ls -ltr *
[hduser@base cassandra]$ ls -ltr
total 12
drwxr-xr-x 8 cassandra cassandra 4096 30 déc.  21:33 data
drwxr-xr-x 2 cassandra cassandra 4096  3 janv. 20:47 saved_caches
drwxr-xr-x 2 cassandra cassandra 4096  3 janv. 23:54 commitlog


rm -Rf    */*

10) Configuration of cassandra.yaml :

cd   /etc/cassandra/conf

See all configuration files :

Open the cassandra.yaml file :

sudo vi Cassandra.yaml

Change cluster_name, for example I put Training_Cluster on all nodes.

Setting listen_address: can be the IP address for each machine:

Setting rpc_address: can be the IP address for each machine:

Setting the seeds: my seeds list here will be the IP address of the node and node, then all nodes will have the same seeds.

11) Now we can start Cassandra on all node via cssh if it is install or on each node:

[hduser@base cassandra]$ sudo service cassandra start
Starting Cassandra: OK

12) To verify the status on cassandra on all nodes:

[hduser@base cassandra]$ sudo service cassandra status
cassandra (pid  3968) is running...

13) To verify the status on all nodes:

nodetool status
[hduser@base cassandra]$ nodetool status
Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
--  Address        Load       Tokens       Owns    Host ID                               Rack
UN  40.21 MB   256          ?       5ddb3532-70de-47b3-a9ca-9a8c9a70b186  rack1
UN  50.88 MB   256          ?       ea5286bb-5b69-4ccc-b22c-474981a1f789  rack1
UN  48.63 MB   256          ?       158812a5-8adb-4bfb-9a56-3ec235e76547  rack1
UN  48.52 MB   256          ?       a42d792b-1620-4f41-8662-8e44c73c38d4  rack1