YCSB 사용할 일이 반복적으로 많아 질것 같아 Script 처리를 하면 좀 편해질까 싶어 막스크립트 작성중... 우선은 Cassandra가 직접적으로 관련이 있어 cassandra-10만 우선 지원.(cassnadra-7,8도 동일하게 가능할듯...)


기능은 단순하다.

- ycsb 명령 줄의 parameter들을 다이얼로그 형태로 지원하는 것일 뿐....

- 그일 첨 시작이라 테스트 해보고 써억~ 편의점이 없다면 과감히 휴지통으로 고고~


실행 예)



# ./ycsb_runner.workloads.20130108.sh 


 === 'Green' is supported ===


 [a] basic

 [b] cassandra-10

 [c] cassandra-7

 [d] cassandra-8

 [e] gemfire

 [f] hbase

 [g] infinispan

 [h] jdbc

 [i] mapkeeper

 [j] mongodb

 [k] nosqldb

 [l] redis

 [m] voldemort


 -> Select Database: b



 -> Title(Name): test


===============================================


 -> hosts (Not Null, ex:192.168.1.52,192.168.1.53): 172.21.81.139,172.21.81.127


 -> cassandra.username (Default: Null): 


 -> cassandra.password (Default: Null): 


 -> cassandra.connectionretries (Default: 300): 


 -> cassandra.operationretries (Default: 300): 


 -> cassandra.columnfamily (Default: data): 


 -> fieldcount (Default: 10): 


 -> fieldlength (Default: 200): 


 -> cassandra.readconsistencylevel (Default: ONE): 


 -> cassandra.writeconsistencylevel (Default: ONE): 


 -> cassandra.scanconsistencylevel (Default: ONE): 


 -> cassandra.deleteconsistencylevel (Default: ONE): 


 -> threads - Number of client threads (Default: 1):


ycsb_runner.sh

#!/bin/bash



### by call518@gmail.com (Jung-In.Jung)


### ChangeLog

#* 2013-01-03 : created, support and tested cassandra-10




# [YCSB]

# Usage: ./bin/ycsb command database [options]

# Commands:

#     load          Execute the load phase

#     run           Execute the transaction phase

#     shell         Interactive mode

# Databases:

#     basic         https://github.com/brianfrankcooper/YCSB/tree/master/basic

#     cassandra-10  https://github.com/brianfrankcooper/YCSB/tree/master/cassandra

#     cassandra-7   https://github.com/brianfrankcooper/YCSB/tree/master/cassandra

#     cassandra-8   https://github.com/brianfrankcooper/YCSB/tree/master/cassandra

#     gemfire       https://github.com/brianfrankcooper/YCSB/tree/master/gemfire

#     hbase         https://github.com/brianfrankcooper/YCSB/tree/master/hbase

#     infinispan    https://github.com/brianfrankcooper/YCSB/tree/master/infinispan

#     jdbc          https://github.com/brianfrankcooper/YCSB/tree/master/jdbc

#     mapkeeper     https://github.com/brianfrankcooper/YCSB/tree/master/mapkeeper

#     mongodb       https://github.com/brianfrankcooper/YCSB/tree/master/mongodb

#     nosqldb       https://github.com/brianfrankcooper/YCSB/tree/master/nosqldb

#     redis         https://github.com/brianfrankcooper/YCSB/tree/master/redis

#     voldemort     https://github.com/brianfrankcooper/YCSB/tree/master/voldemort

# Options:

#     -P file       Specify workload file

#     -p key=value  Override workload property

#     -s            Print status to stderr

#     -target n     Target ops/sec (default: unthrottled)

#     -threads n    Number of client threads (default: 1)

# Workload Files:

#     There are various predefined workloads under workloads/ directory.

#     See https://github.com/brianfrankcooper/YCSB/wiki/Core-Properties

#     for the list of workload properties.


trap "rm -f $tmp_file; reset_color; echo; exit 99" 2


now_time() {

date +"%Y-%m-%d__%H-%M-%S"

}


reset_color() {

tput sgr0

}


color_green="\033[1;32m"

color_red="\033[1;31m"

color_blue="\033[1;34m"

color_yellow="\033[1;33m"

color_cyan="\033[1;36m"


tmp_file="/dev/shm/$RANDOM.tmp"


CASSANDRA_CLI="/usr/local/cassandra/bin/cassandra-cli"


YCSB_BIN="/usr/local/src/ycsb-0.1.4/bin/ycsb"

WORKLOAD_DIR="/usr/local/src/ycsb-0.1.4/workloads"


RUN_PATH=`pwd`

LOG_DIR="$RUN_PATH/logs"


mkdir -p $LOG_DIR


if [ -z $YCSB_BIN ]; then

YCSB_BIN=`which ycsb`

if [ -z $YCSB_BIN ]; then

echo

echo -e "$color_red Not found ycsb command!!!"

reset_color

echo

echo -n " -> Input YCSB Command Path: "

read YCSB_BIN

if [ ! -f $YCSB_BIN ] || [ -z $YCSB_BIN ]; then

echo

echo -e "$color_red Invalid path or not found. retry!!"

echo

reset_color

exit 101

fi

fi

fi


if [ ! -d $WORKLOAD_DIR ]; then

echo -e "$color_red Not found workloads directory command!!!"

reset_color

exit 101

fi


###############################################################

basic() {

echo -e "$color_green TBD"

echo

}


cassandra_10() {

echo -n "

 -> Title(Name): "

read title

if [ -z $title ]; then

echo -e "$color_red title is Invalid of Null. retry!!"

echo

reset_color

exit 101

fi


#echo -n "

# [a] load

# [b] run

#

# -> Select Command: "

#

#read command

#case $command in

# a|A)

# command="load"

# ;;

# b|B)

# command="run"

# ;;

#esac

command="run"


echo

echo "==============================================="


echo -n -e "$color_red

 -> hosts (Not Null, ex:192.168.1.52,192.168.1.53): "

reset_color

read hosts

if [ -z $hosts ];then

echo

echo -e "$color_red Hosts is Null !!! retry!!!"

echo

reset_color

exit 105

fi


echo -n "

 -> cassandra.username (Default: Null): "

read cassandra_username


echo -n "

 -> cassandra.password (Default: Null): "

read cassandra_password


echo -n "

 -> cassandra.connectionretries (Default: 300): "

read cassandra_connectionretries

if [ -z $cassandra_connectionretries ]; then cassandra_connectionretries="300"; fi


echo -n "

 -> cassandra.operationretries (Default: 300): "

read cassandra_operationretries

if [ -z $cassandra_operationretries ]; then cassandra_operationretries="300"; fi


echo -n "

 -> cassandra.columnfamily (Default: data): "

read cassandra_columnfamily

if [ -z $cassandra_columnfamily ]; then cassandra_columnfamily="data"; fi


echo -n "

 -> fieldcount (Default: 10): "

read fieldcount

if [ -z $fieldcount ]; then fieldcount="10"; fi


echo -n "

 -> fieldlength (Default: 200): "

read fieldlength

if [ -z $fieldlength ]; then fieldlength="200"; fi


echo -n "

 -> cassandra.readconsistencylevel (Default: ONE): "

read cassandra_readconsistencylevel


echo -n "

 -> cassandra.writeconsistencylevel (Default: ONE): "

read cassandra_writeconsistencylevel

if [ -z $ ]; then =""; fi


echo -n "

 -> cassandra.scanconsistencylevel (Default: ONE): "

read cassandra_scanconsistencylevel


echo -n "

 -> cassandra.deleteconsistencylevel (Default: ONE): "

read cassandra_deleteconsistencylevel


echo -n "

 -> threads - Number of client threads (Default: 1): "

read threads


echo -n "

 -> target - Target ops/sec (Default: unthrottled): "

read target


args="a b c d e f"


TIMESTAMP=`now_time`

for arg in $args

do

host_one=`echo $hosts | awk -F',' '{print $1}'`

echo "create keyspace usertable;

use usertable;

drop column family $cassandra_columnfamily;

create column family $cassandra_columnfamily;" > $tmp_file

$CASSANDRA_CLI -h $host_one -p 9160 < $tmp_file > /dev/null

rm -f $tmp_file


CMD="$YCSB_BIN $command $db -s -P workloads/workload$arg -p hosts=$hosts"


if [ ! -z $cassandra_username ]; then CMD="$CMD -p cassandra.username=$cassandra_username"; fi

if [ ! -z $cassandra_password ]; then CMD="$CMD -p cassandra.password=$cassandra_password"; fi

if [ ! -z $cassandra_connectionretries ]; then CMD="$CMD -p cassandra.connectionretries=$cassandra_connectionretries"; fi

if [ ! -z $cassandra_operationretries ]; then CMD="$CMD -p cassandra.operationretries=$cassandra_operationretries"; fi

if [ ! -z $cassandra_columnfamily ]; then CMD="$CMD -p cassandra.columnfamily=$cassandra_columnfamily"; fi

if [ ! -z $fieldlength ]; then CMD="$CMD -p fieldlength=$fieldlength"; fi

if [ ! -z $fieldcount ]; then CMD="$CMD -p fieldcount=$fieldcount"; fi

if [ ! -z $cassandra_readconsistencylevel ]; then CMD="$CMD -p cassandra.readconsistencylevel=$cassandra_readconsistencylevel"; fi

if [ ! -z $cassandra_writeconsistencylevel ]; then CMD="$CMD -p cassandra.writeconsistencylevel=$cassandra_writeconsistencylevel"; fi

if [ ! -z $cassandra_scanconsistencylevel ]; then CMD="$CMD -p cassandra.scanconsistencylevel=$cassandra_scanconsistencylevel"; fi

if [ ! -z $cassandra_deleteconsistencylevel ]; then CMD="$CMD -p cassandra.deleteconsistencylevel=$cassandra_deleteconsistencylevel"; fi

if [ ! -z $threads ]; then

CMD="$CMD -threads $threads"

fi

if [ ! -z $target ]; then

CMD="$CMD -target $target"

fi

echo -e "$color_cyan"

echo "=== [ YCSB Benchamrk Command ] ==="

echo

echo "# $CMD"

#echo -n "$color_blue

#Press any key to continue..... "

#read tmp

LOG_FILE="$LOG_DIR/$title--workload$arg---$TIMESTAMP.log"


echo "[Start]: `now_time`" > $LOG_FILE

echo >> $LOG_FILE

echo "[Running] # $CMD" >> $LOG_FILE

echo >> $LOG_FILE

$CMD 2>&1 | tee -a $LOG_FILE

echo >> $LOG_FILE

echo "[END]: `now_time`" >> $LOG_FILE

done

reset_color


echo

}


cassandra_7() {

echo -e "$color_green TBD"

echo

}


cassandra_8() {

echo -e "$color_green TBD"

echo

}


gemfire() {

echo -e "$color_green TBD"

echo

}


hbase() {

echo -e "$color_green TBD"

echo

}


infinispan() {

echo -e "$color_green TBD"

echo

}


jdbc() {

echo -e "$color_green TBD"

echo

}


mapkeeper() {

echo -e "$color_green TBD"

echo

}


mongodb() {

echo -e "$color_green TBD"

echo

}


nosqldb() {

echo -e "$color_green TBD"

echo

}


redis() {

echo -e "$color_green TBD"

echo

}


voldemort() {

echo -e "$color_green TBD"

echo

}

###############################################################


clear


echo

echo -e "$color_green === 'Green' is supported ==="; reset_color

echo

echo " [a] basic"; reset_color

echo -e "$color_green [b] cassandra-10"; reset_color

echo " [c] cassandra-7"; reset_color

echo " [d] cassandra-8"; reset_color

echo " [e] gemfire"; reset_color

echo " [f] hbase"; reset_color

echo " [g] infinispan"; reset_color

echo " [h] jdbc"; reset_color

echo " [i] mapkeeper"; reset_color

echo " [j] mongodb"; reset_color

echo " [k] nosqldb"; reset_color

echo " [l] redis"; reset_color

echo " [m] voldemort"; reset_color

echo

echo -n " -> Select Database: "


read db

echo


case $db in

a|A)

db="basic"

basic

;;

b|B)

db="cassandra-10"

cassandra_10

;;

c|C)

db="cassandra-7"

cassandra_7

;;

d|D)

db="cassandra-8"

cassandra_8

;;

e|E)

db=gemfire

gemfire

;;

f|F)

db="hbase"

hbase

;;

g|G)

db="infinispan"

infinispan

;;

h|H)

db="jdbc"

jdbc

;;

i|I)

db="mapkeeper"

mapkeeper

;;

j|J)

db="mongodb"

mongodb

;;

k|K)

db="nosqldb"

nosqldb

;;

l|L)

db="redis"

redis

;;

m|M)

db="voldemort"

voldemort

;;

*)

echo

echo -e "$color_red Invalid Selection. Retry!!"

echo

reset_color

exit 100

;;

esac


reset_color


Posted by 사랑줍는거지
,