自动化测试Cassandra脚本

准备工作

安装6台Ubuntu9.10的64位系统
安装JDK
配置双向ssh
安装Cassandra
测试工具使用YCSB Benchmark

测试脚本

1.远程关闭cassandra

#!/bin/sh
for line in `cat server_list.txt`
do
ssh root@$line "pgrep -f cassandra |xargs kill -9 && echo KillOK && exit"
done
for line in `cat server_list.txt`
do
ssh root@$line "ps aux | grep cassandra"
done
10.11.1.140
10.11.1.142
10.11.1.143
10.11.1.144
10.11.1.145
10.11.1.146
seerver_list.txt


2. 远程修改Cassandra配置文件并且重启Cassandra

#!/bin/sh
count=1
for lin in `cat list.txt`
do
  var[count]=`echo $lin | cut -d '=' -f 2`
  count=$[count+1]
done
for line in `cat server_list.txt`
do
ssh root@$line "echo ssh OK------------------------------------------------ && cp -f /root/apache-cassandra-0.6.6/conf/storage-conf.xml /root/apache-cassandra-0.6.6/conf/storage-conf.xml.bk && echo copy OK--------------------------------------&& sed -e 's/<ConcurrentReads>.*<//ConcurrentReads>/<ConcurrentReads>${var[1]}<//ConcurrentReads>/g' -e 's/<ColumnFamily Name=/"data/" RowsCached=/".*/"/<ColumnFamily Name=/"data/" RowsCached=/"${var[3]}/"/g' -e 's/KeysCached=/".*/ //>/KeysCached=/"${var[2]}/" //>/g' -e 's/<IndexInterval>.*<//IndexInterval>/<IndexInterval>${var[4]}<//IndexInterval>/g' -e 's/<MemtableOperationsInMillions>.*<//MemtableOperationsInMillions>/<MemtableOperationsInMillions>${var[5]}<//MemtableOperationsInMillions>/g' -e 's/<MemtableThroughputInMB>.*<//MemtableThroughputInMB>/<MemtableThroughputInMB>${var[6]}<//MemtableThroughputInMB>/g' /root/apache-cassandra-0.6.6/conf/storage-conf.xml.bk > /root/apache-cassandra-0.6.6/conf/storage-conf.xml && echo modify OK----------------------------------------------- && sleep 4 && echo have a sleep------------------------------------------------ && nohup /root/apache-cassandra-0.6.6/bin/cassandra & exit"
done

ConcurrentReads=4
KeysCached=5000000
RowsCached=0
IndexInterval=128
MemtableOperationsInMillions=0.3
MemtableThroughputInMB=64

list.txt

后续脚本为本地自动化YCSB测试

老师教育我们学计算机的人不应该动手去做重复的事情,极是!

你可能感兴趣的:(server,测试,脚本,ssh,cassandra,测试工具)