Cassadra Install
1. file download
2. unzip to download file
3. server run
{cassandra dir}/bin/cassandra -f (-f 옵션을 붙이게 되면 터미널을 종료 혹은 "ctrl+c" 를 입력 하면 종료가 된다. 백그라운드에서 동작을 시키고 싶다면 옵션 없이 실행)
4. Using cqlsh
#bin/cqlsh
5.cqlsh에서는 명령어의 종료를 세미콜론(;)으로 구분 한다.
6. Create keyspace
CREATE KEYSPACE mykeyspace WITH REPLICATION = {'class':'SimpleStrateg', 'replication_factor' : 1 }; |
7. new keyspace의 활성화
USE mykeyspace; |
8. Create Table
CREATE TABLE users ( user_id int PRIMARY KEY, fname text, lname text ); |
9. Insert Data
INSERT INTO users (user_id, fname, lame) VALUES (1745, 'john', 'smith'); INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe'); INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith'); |
10. Select Data
SELECT * FROM users; |
11. Set Index
CREATE INDEX ON users(lame); SELECT * FROM USERS WHERE lame = 'smith'; |
notice
#1 cassandra 2.0 and later require Java 7u25 or later.
Sharding Notice
1. If you have "Error on Cassandra server: Unable to gossip with any seeds" problem
It's now working using either unencrypted or encrypted communications. Encrypted communications started working after installing the JCE extensions on both servers, and making a change in certificate generation. The Datastax instructions for preparing server certificates for Cassandra 2.0 drops a parameter that was present in their Cassandra 1.2 instructions. Including the parameter seemed to make the difference. The additional parameter is -keyalg RSA:
Seed server:
keytool -genkey -alias prod01 -keystore .keystore -keyalg RSA
keytool -export -alias prod01 -file prod01.cer -keystore .keystore -keyalg RSA
Other server:
keytool -genkey -alias prod00 -keystore .keystore -keyalg RSA
keytool -export -alias prod00 -file prod00.cer -keystore .keystore -keyalg RSA
Then, make sure both servers have both certs, and use them to create a trust store using these commands on both servers:
keytool -import -v -trustcacerts -alias prod00 -file prod00.cer -keystore .truststore
keytool -import -v -trustcacerts -alias prod01 -file prod01.cer -keystore .truststore
chmod go-rwx .keystore