java 、maven、ycsb 的安装及配置见这篇博客: http://blog.csdn.net/hs794502825/article/details/17309845 本篇博客主要介绍 cassandra 的安装,以及利用 ycsb 对 cassandra 进行基本的测试 在 http://cassandra.apache.org/download/ 上面下载了最新版本的
java 、maven、ycsb 的安装及配置见这篇博客:cd /home/hs/program tar -zxvf apache-cassandra-2.0.3-bin.tar.gz然后为 cassandra 设置环境变量
#set cassandra environment export CASSANDRA_HOME=/home/hs/program/apache-cassandra-2.0.3 export PATH=$PATH:$CASSANDRA_HOME/bin:$CASSANDRA_HOME/lib之后,我就直接以普通用户(hs)执行 cassandra -f
sudo mkdir /var/lib/cassandra sudo mkdir /var/log/cassandra chown -R hs:hs /var/lib/cassandra chown -R hs:hs /var/log/cassandra 如此一来,hs 就具有写 /var/lib/cassandra/ 和 /var/log/cassandra/ 的权限 在终端1中运行cassandra: cassandra -f 如果有 Listening for thrift clients... 则说明成功启动 cassandra 在终端2中运行cassandra-cli: cassandra-cli 显示:
Connected to: "Test Cluster" on 127.0.0.1/9160 Welcome to Cassandra CLI version 2.0.3 The CLI is deprecated and will be removed in Cassandra 3.0. Consider migrating to cqlsh. CQL is fully backwards compatible with Thrift data; see http://www.datastax.com/dev/blog/thrift-to-cql3
hs@hs-virtual-machine:~$ cqlsh Connected to Test Cluster at localhost:9160. [cqlsh 4.1.0 | Cassandra 2.0.3 | CQL spec 3.1.1 | Thrift protocol 19.38.0]
create keyspace usertable; use usertable; create column family data;
./bin/ycsb load cassandra-10 -P workloads/workloada -p hosts=localhost -p columnfamily=data > ./my-results/load-cassandra-a
Loading workload... Starting test. InvalidRequestException(why:unconfigured columnfamily data) at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:20833) at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78) at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:964) at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:950) at com.yahoo.ycsb.db.CassandraClient10.insert(CassandraClient10.java:477) at com.yahoo.ycsb.DBWrapper.insert(DBWrapper.java:148) at com.yahoo.ycsb.workloads.CoreWorkload.doInsert(CoreWorkload.java:461) at com.yahoo.ycsb.ClientThread.run(Client.java:269)
drop column family data; create column family data with column_type = 'Standard' and comparator = 'UTF8Type';
./bin/ycsb load cassandra-10 -P workloads/workloada -p hosts=localhost -p columnfamily=data > ./my-results/load-cassandra-a
YCSB Client 0.1 Command line: -db com.yahoo.ycsb.db.CassandraClient10 -P workloads/workloada -p hosts=localhost -p columnfamily=data -load [OVERALL], RunTime(ms), 2287.0 [OVERALL], Throughput(ops/sec), 437.25404459991256 [INSERT], Operations, 1000 [INSERT], AverageLatency(us), 1670.687 [INSERT], MinLatency(us), 476 [INSERT], MaxLatency(us), 280228 [INSERT], 95thPercentileLatency(ms), 3 [INSERT], 99thPercentileLatency(ms), 12 [INSERT], Return=0, 1000 ......
./bin/ycsb run cassandra-10 -P workloads/workloada -p hosts=localhost -p columnfamily=data > ./my-results/run-cassandra-a
YCSB Client 0.1 Command line: -db com.yahoo.ycsb.db.CassandraClient10 -P workloads/workloada -p hosts=localhost -p columnfamily=data -t [OVERALL], RunTime(ms), 5574.0 [OVERALL], Throughput(ops/sec), 179.4043774668102 [UPDATE], Operations, 475 [UPDATE], AverageLatency(us), 2095.0547368421053 [UPDATE], MinLatency(us), 327 [UPDATE], MaxLatency(us), 143093 [UPDATE], 95thPercentileLatency(ms), 9 [UPDATE], 99thPercentileLatency(ms), 33 [UPDATE], Return=0, 475 ...... [READ], Operations, 525 [READ], AverageLatency(us), 5054.5085714285715 [READ], MinLatency(us), 492 [READ], MaxLatency(us), 674167 [READ], 95thPercentileLatency(ms), 11 [READ], 99thPercentileLatency(ms), 85 [READ], Return=0, 525