Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cassandra Installation Guide and Example Lecturer : Prof. Kyungbaek Kim Presenter : I Gde Dharma Nugraha.

Similar presentations


Presentation on theme: "Cassandra Installation Guide and Example Lecturer : Prof. Kyungbaek Kim Presenter : I Gde Dharma Nugraha."— Presentation transcript:

1 Cassandra Installation Guide and Example Lecturer : Prof. Kyungbaek Kim Presenter : I Gde Dharma Nugraha

2 Cassandra Environment VMWare Player/Oracle VirtualBox Ubuntu 12.04 LTS 64bits Java Version 1.7 (Oracle version) Cassandra Version 2.1.2 http://mirror.apache-kr.org/cassandra/2.1.2/apache- cassandra-2.1.2-bin.tar.gz

3 Preparing Java Java development kit $sudo add-apt-repository ppa:webupd8team/java $sudo apt-get update $sudo apt-get install oracle-java7-installer Check success installation, run: $java –version Automatically setting java environment variables $sudo apt-get install oracle-java7-set- default

4 Preparing Cassandra Code This exercise uses Cassandra 2.1.2 Get apache-cassandra-2.1.2-bin.tar.gz $wget http://apache.tt.co.kr/Cassandra/2.1.2/apache- cassandra-2.1.2-bin.tar.gz http://apache.tt.co.kr/Cassandra/2.1.2/apache- cassandra-2.1.2-bin.tar.gz $tar xvf apache-cassandra-2.1.2-bin.tar.gz $mv apache-cassandra-2.1.2 cassandra Run single mode Cassandra $cd cassandra/bin $./cassandra –f (running Cassandra in the foreground and log gratuitously to the console). Stop Cassandra Press “Control-C” in the same window with the command above.

5 Cassandra Single Mode Run single mode Cassandra $cd cassandra/bin $./cassandra –f Screenshot:

6 Cassandra Single Mode Check Cassandra Node Open new Terminal Window Type command $cd cassandra/bin $./nodetool status Screenshot

7 Cassandra Multiple Node Mode Preparation Make two new VM. Repeat the step for preparing the environment with Java 7. Download apache-cassandra-2.1.2-bin.tar.gz and repeat Cassandra preparation step for each new VM. Setting the IP for all the VM with the same IP Network to perform LAN. For this exercise: Node 1 : 192.168.159.128 Node 2 : 192.168.159.129 Node 3 : 192.168.159.130

8 Cassandra Multiple Node Mode Configuration for all VM Enter conf folder $cd cassandra/conf Edit cassandra.yaml and configure with the setting below cluster_name: ‘MyCassandraCluster’ num_tokens: 256 seed_provider: class_name: org.apache.cassandra.locator.SimpleSeedProv ider Parameters: seeds: “192.168.159.128” listen_address: 192.168.159.128 or listen_interface: eth0 rpc_address: 0.0.0.0 broadcast_rpc_address: 192.168.159.128 endpoint_snitch: GossipingPropertyFileSnitch

9 Cassandra Multiple Node Mode Run Cassandra in each VM First empty cassandra/data directory $cd cassandra/data $rm –rf * $cd cassandra/bin $./cassandra -f

10 Cassandra Multiple Node Mode This screenshot shows that all nude have UP.

11 Cassandra Multiple Node Mode To make sure, run Nodetool command in new terminal window. $./nodetool status

12 Cassandra Interaction Interaction with Cassandra, use cqlsh (CQL Shell) Type command below to run cqlsh $cd cassandra/bin $./cqlsh

13 Practical Example (1) Interaction using CQL Source : http://www.planetcassandra.org Running cqlsh from installation_tarball/cassandra/bin directory.

14 Practical Example (1) Cont’d Interaction using CQL Create keyspace then use the new keyspace.

15 Practical Example (1) Cont’d Interaction using CQL Create user table within demo keyspace.

16 Practical Example (1) Cont’d Interaction using CQL Show schema

17 Practical Example (1) Cont’d Interaction using CQL Insert Data Select Data

18 Practical Example (1) Cont’d Interaction using CQL Update Data and show the result Delete Data

19 Practical Example (1) Cont’d Inside Cassandra Data Directory

20 Practical Example (2) Simple Java Application with Cassandra Java Driver Preparation Download Cassandra java driver $wget http://downloads.datastax.com/java-driver/cassandra- java-driver-2.1.2.tar.gzhttp://downloads.datastax.com/java-driver/cassandra- java-driver-2.1.2.tar.gz $tar xvf cassandra-java-driver-2.1.2.tar.gz $mv cassandra-java-driver-2.1.2 cassandrajava Download slf4j $wget http://www.slf4j.org/dist/slf4j-1.7.7.tar.gzhttp://www.slf4j.org/dist/slf4j-1.7.7.tar.gz $tar xvf slf4j-1.7.7.tar.gz $mv slf4j-1.7.7 slf4j Make java file with filename GettingStarted.java

21 Practical Example (2) Cont’d Simple Java Application with Cassandra Java Driver GettingStarted.java

22 Practical Example (2) Cont’d Simple Java Application with Cassandra Java Driver GettingStarted.java

23 Practical Example (2) Cont’d Simple Java Application with Cassandra Java Driver Compile GettingStarted.java $javac –classpath $HOME_PATH/cassandrajava/cassandra- driver-core-2.1.2.jar:. GettingStarted.java Run GettingStarted $java –classpath $HOME_PATH/cassandrajava/*:$HOME_PATH/cassandrajava/li b*:$HOME_PATH/slf4j/slf4j-nop-1.7.7.jar:. GettingStarted The Result

24 Practical Example (3) Integrate Hadoop and Cassandra Integrating Hadoop and Cassandra perform big analytic tools. Cassandra will be the data source and Hadoop will be the processor. Requirements for integrate Hadoop and Cassandra: Isolate Cassandra and Hadoop nodes in separate data centers. Disable virtual nodes (vnodes) Set num_tokens to 1 in the cassandra.yaml file. Uncomment the initial_token property and set it to 1 or the value of a generated token for a multimode cluster. Start the cluster for the first time.

25 Practical Example (3) Cont’d Integrate Hadoop and Cassandra Preparation Download source code and library $wget https://www.dropbox.com/s/2778132fgjmod2i/CassandraWordCoun t.tar.gz?dl=0 https://www.dropbox.com/s/2778132fgjmod2i/CassandraWordCoun t.tar.gz?dl=0 $mv CassandraWordCount.tar.gz?dl=0 CassandraWordCount.tar.gz $tar xvf CassandraWordCount.tar.gz Create keyspace in Cassandra, name : test cqlsh>CREATE KEYSPACE test WITH REPLICATION = { ‘class’ : ‘SimpleStrategy’, ‘replication_factor’ : 2}; cqlsh>USE test; cqlsh>CREATE TABLE documents(id uuid, content text, primary key (id)); Insert sample data.

26 Practical Example (3) Cont’d Integrate Hadoop and Cassandra Compile $javac -classpath $HADOOP_HOME/hadoop-core- 1.0.3.jar:/home/hduser/CassandraWordCount/lib/cassandra- driver-core- 2.1.2.jar:/home/hduser/cassandra/lib/*.jar:/home/hduser/Cas sandraWordCount/lib/cassandra-all-2.1.1.jar -d bin src/WordCount.java $cd bin $jar –cvf wordcount.jar *.class

27 Practical Example (3) Cont’d Integrate Hadoop and Cassandra Run Run Hadoop Run Cassandra Run apps using command: hadoop jar wordcount.jar WordCount -libjar /home/hduser/CassandraWordCount/lib/cassandra-all- 2.1.1.jar,/home/hduser/CasssandraWordCount/lib/cassandra- driver-core- 2.1.2.jar,/home/hduser/CassandraWordCount/lib/cassandra- thrift-2.0.3.jar,/home/hduser/CassandraWordCount/lib/google- collect-1.0.jar,/home/hduser/CassandraWordCount/lib/jamm- 0.2.4.jar,/home/hduser/CassandraWordCount/lib/libthrift- 0.9.2.jar,/home/hduser/CassandraWordCount/lib/metrics-core- 3.0.2.jar,/home/hduser/CassandraWordCount/lib/netty.jar - Dinput=localhost -Doutput=/user/hduser/out31

28 Practical Example (3) Cont’d WordCount mapper

29 Practical Example (3) Cont’d WordCount reducer

30 Practical Example (3) Cont’d WordCount run

31 Practical Example (3) Cont’d


Download ppt "Cassandra Installation Guide and Example Lecturer : Prof. Kyungbaek Kim Presenter : I Gde Dharma Nugraha."

Similar presentations


Ads by Google