How to install cassandra

Facebook의 NoSQL인 Cassandra를 설치하는 방법에 대해 포스팅 합니다.

현재 Facebook, Twitter, Digg, Reddit, Rackspace, Cloudkick, Cisco 등등 많은 곳에서 Cassandra를 사용하고 있습니다.

또한 Ruby, Perl, Python, Scala, Java, PHP, C++, C# 등의 프로그래밍 언어에서도 사용가능 합니다.

 

java.dzone.com에서 NoSQL의 제품선호도 조사를 했는데 Cassandra가 많은 지지율을 받고 있습니다.

 

1. JAVA 설치 및 설정

Cassandra를 사용하기 위해선 JAVA가 설치 되어야 합니다. (버전 1.6이상)

JDK를 다운로드 하고 PATH를 설정합니다.

http://www.oracle.com/technetwork/java/javase/downloads/index.html

[root@yongbok ~]# wget http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz

[root@yongbok ~]# tar xzvf  jdk-7-linux-i586.tar.gz

[root@yongbok ~]# mv jdk1.7.0 /usr/local/jdk1.7.0

[root@yongbok ~]# echo ‘export JAVA_HOME=/usr/local/jdk1.7.0′ >> /etc/profile

[root@yongbok ~]# echo ‘export PATH=$PATH:/usr/local/bin:$JAVA_HOME/bin’ >> /etc/profile

[root@yongbok ~]# bash

[root@yongbok ~]# echo $JAVA_HOME

/usr/local/jdk1.7.0

 

2. Cassandra 설치

바이너리를 제공 하므로 apache-cassandra-version-bin.tar.gz 를 다운로드 합니다.

http://cassandra.apache.org/download/

[root@yongbok ~]# wget http://apache.yongbok.net/cassandra/0.8.7/apache-cassandra-0.8.7-bin.tar.gz

[root@yongbok ~]# tar xzvf apache-cassandra-0.8.7-bin.tar.gz

[root@yongbok ~]# mv apache-cassandra-0.8.7 /usr/local/cassandra-0.8.7

 

로그가 저장될 곳을 생성 및 권한을 부여합니다. 변경하고 싶다면 conf/cassandra.yaml 파일의 내용을 변경하세요.

[root@yongbok ~]# mkdir -p /var/log/cassandra

[root@yongbok ~]# chown -R `whoami` /var/log/cassandra

[root@yongbok ~]# mkdir -p /var/lib/cassandra

[root@yongbok ~]# chown -R `whoami` /var/lib/cassandra

 

3. Cassandra 실행

[root@yongbok ~]# /usr/local/apache-cassandra-version/bin/cassandra -f

위 명령어를 사용하여 Cassandra를 실행할수 있으며 뒤에 -f 옵션은 foreground에서 실행합니다.

기본적으로 옵션을 붙이지 않으면 background로 실행이 됩니다.

[root@yongbok ~]# /usr/local/apache-cassandra-0.8.7/bin/cassandra -f

INFO 20:34:41,026 Logging initialized
INFO 20:34:41,045 JVM vendor/version: Java HotSpot(TM) Client VM/1.7.0
INFO 20:34:41,056 Heap size: 1043333120/1044381696
INFO 20:34:41,057 Classpath: /usr/local/apache-cassandra-0.8.7/bin/../conf:/usr/local/apache-cassandra-0.8.7/bin/../build/classes/main:/usr/local/apache-cassandra-0.8.7/bin/../build/classes/thrift:/usr/local/apache-cassandra-0.8.7/bin/../lib/antlr-3.2.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/apache-cassandra-0.8.7.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/apache-cassandra-thrift-0.8.7.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/avro-1.4.0-fixes.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/avro-1.4.0-sources-fixes.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/commons-cli-1.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/commons-codec-1.2.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/commons-collections-3.2.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/commons-lang-2.4.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/concurrentlinkedhashmap-lru-1.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/guava-r08.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/high-scale-lib-1.1.2.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/jackson-core-asl-1.4.0.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/jackson-mapper-asl-1.4.0.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/jamm-0.2.2.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/jline-0.9.94.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/json-simple-1.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/libthrift-0.6.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/log4j-1.2.16.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/servlet-api-2.5-20081211.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/snakeyaml-1.6.jar:/usr/local/apache-cassandra-0.8.7/bin/../lib/jamm-0.2.2.jar
INFO 20:34:41,085 JNA not found. Native methods will be disabled.
INFO 20:34:41,135 Loading settings from file:/usr/local/apache-cassandra-0.8.7/conf/cassandra.yaml
INFO 20:34:41,448 DiskAccessMode ‘auto’ determined to be standard, indexAccessMode is standard
INFO 20:34:42,007 Global memtable threshold is enabled at 332MB
INFO 20:34:42,009 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,082 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,083 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,084 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,085 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,095 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,312 Opening /var/lib/cassandra/data/system/LocationInfo-g-5
INFO 20:34:42,507 Couldn’t detect any schema definitions in local storage.
INFO 20:34:42,510 Found table data in data directories. Consider using the CLI to define your schema.
INFO 20:34:42,512 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,513 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,514 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,515 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,516 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,518 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
INFO 20:34:42,565 Creating new commitlog segment /var/lib/cassandra/commitlog/CommitLog-1318419282565.log
INFO 20:34:42,603 Replaying /var/lib/cassandra/commitlog/CommitLog-1318076469164.log
INFO 20:34:42,693 Finished reading /var/lib/cassandra/commitlog/CommitLog-1318076469164.log
INFO 20:34:42,694 Log replay complete, 0 replayed mutations
INFO 20:34:42,716 Cassandra version: 0.8.7
INFO 20:34:42,717 Thrift API version: 19.16.0
INFO 20:34:42,717 Loading persisted ring state
INFO 20:34:42,723 Starting up server gossip
INFO 20:34:42,764 Enqueuing flush of Memtable-LocationInfo@14065971(29/36 serialized/live bytes, 1 ops)
INFO 20:34:42,766 Writing Memtable-LocationInfo@14065971(29/36 serialized/live bytes, 1 ops)
INFO 20:34:42,820 Completed flushing /var/lib/cassandra/data/system/LocationInfo-g-6-Data.db (80 bytes)
INFO 20:34:42,945 Starting Messaging Service on localhost/127.0.0.1:7000
INFO 20:34:42,994 Using saved token 127035816610104371005629633890270196119
INFO 20:34:42,995 Enqueuing flush of Memtable-LocationInfo@31572396(53/66 serialized/live bytes, 2 ops)
INFO 20:34:42,996 Writing Memtable-LocationInfo@31572396(53/66 serialized/live bytes, 2 ops)
INFO 20:34:43,041 Completed flushing /var/lib/cassandra/data/system/LocationInfo-g-7-Data.db (163 bytes)
INFO 20:34:43,049 Node localhost/127.0.0.1 state jump to normal
INFO 20:34:43,051 Will not load MX4J, mx4j-tools.jar is not in the classpath
INFO 20:34:43,238 Binding thrift service to localhost/127.0.0.1:9160
INFO 20:34:43,251 Using TFastFramedTransport with a max frame size of 15728640 bytes.
INFO 20:34:43,258 Using synchronous/threadpool thrift server on localhost/127.0.0.1 : 9160
INFO 20:34:43,259 Listening for thrift clients…

 

이후 로컬이나 외부에서 접속을 확인 하면 됩니다. (외부에서 접속시 –host 옵션을 사용)

[root@yongbok ~]# /usr/local/apache-cassandra-0.8.7/bin/cassandra-cli

Welcome to the Cassandra CLI.

Type ‘help;’ or ‘?’ for help.
Type ‘quit;’ or ‘exit;’ to quit.

[default@unknown]

 

더 자세한 명령어는 help, ?를 사용하면 됩니다.

Getting around:
?                       Display this help.
help;                   Display this help.
help <command>;         Display command-specific help.
exit;                   Exit this utility.
quit;                   Exit this utility.

Commands:
assume                  Apply client side validation.
connect                 Connect to a Cassandra node.
consistencylevel        Sets consisteny level for the client to use.
count                   Count columns or super columns.
create column family    Add a column family to an existing keyspace.
create keyspace         Add a keyspace to the cluster.
del                     Delete a column, super column or row.
decr                    Decrements a counter column.
describe cluster        Describe the cluster configuration.
describe keyspace       Describe a keyspace and it’s column families.
drop column family      Remove a column family and it’s data.
drop keyspace           Remove a keyspace and it’s data.
drop index              Remove an existing index from specific column.
get                     Get rows and columns.
incr                    Increments a counter column.
list                    List rows in a column family.
set                     Set columns.
show api version        Show the server API version.
show cluster name       Show the cluster name.
show keyspaces          Show all keyspaces and their column families.
show schema             Show a cli script to create keyspaces and column families.
truncate                Drop the data in a column family.
update column family    Update the settings for a column family.
update keyspace         Update the settings for a keyspace.
use                     Switch to a keyspace.

[default@unknown]

Loading Disqus Comments ...
Loading Facebook Comments ...

No Trackbacks.