未找到Cassandra-stress文件异常

时间:2019-05-11 12:09:12

标签: docker cassandra cassandra-stress

我正在尝试使用已定义的.yaml文件运行cassandra-strees,但仍然出现错误:

java.io.IOError: java.io.FileNotFoundException: /home/kenik/Documents/stress.yaml (No such file or directory)

这对我来说很麻烦。 让我解释一下原因。

首先我的Stress.yaml文件:

# Keyspace name and create CQL
#

CREATE KEYSPACE weatherteller
WITH REPLICATION = { 
    'class' : 'SimpleStrategy',
    'datacenter1' : 1
};
#
# Table name and create CQL
#
table: weather
table_definition:
  CREATE TABLE weatherteller.weather (
        weatherid bigint,
        measurementdate timestamp,
        summary varchar,
        preciptype varchar,
        temperature double,
        apparenttemperature double, 
        humidity double,
        windspeed double,
        windbearing double,
        visibility double,
        pressure double,
        dailysummary varchar,
        city varchar,
        PRIMARY KEY (weatherid, measurementdate, city)
   )
#
columnspec:
  - name: weatherid
    size: uniform(1..64)
  - name: measurementdate
    cluster: uniform(20...40)
  - name: summary
    size: gaussian(100...500)
  - name: preciptype
    size: uniform(1..32)
  - name: temperature
    size: uniform(1..32)
  - name: apparenttemperature
    size: uniform(1..32)
  - name: humidity
    size: uniform(1..10)
  - name: windspeed
    size: uniform(1..10)
  - name: windbearing
    size: uniform(1..10)
  - name: visibility
    size: uniform(1..10)
  - name: pressure
    size: uniform(1..10)  
  - name: dailysummary
    size: uniform(1..100)  
  - name: city
    size: uniform(1..100)  


insert:
  partitions: fixed(1)
  select: fixed(1)/500 
  batchtype: UNLOGGED

queries:
  weather:
    cql: select * from weather where weatherid = ? and measurementdate = ? and city = ?
    fields: samerow

我运行的命令:

docker exec -it cassandra cassandra-stress user profile=file:///home/kenik/Documents/stress.yaml no-warmup ops\(insert=1,weather=1\) n=10000 -graph file=./stress.html

'cassandra'是我当前正在运行的容器。

stress.yaml文件的绝对路径是/home/kenik/Documents/stress.yaml我已经使用命令readlink -f stress.yaml进行了检查。我在放置Stress.yaml的目录中。 如您所见,路径似乎很好,但cassandra-stress无法找到它。

您知道运行此卡桑德拉压力测试的任何方法吗?

//更新 启动容器时,我使用命令:

docker run -e DS_LICENSE=accept -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -v /home/kenik/Documents/dir -p 9042:9042 --name cassandra -m 2g -d modified-cassandra

docker run -e DS_LICENSE=accept -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -v /home/kenik/Documents/:/dir -p 9042:9042 --name cassandra -m 2g -d modified-cassandra

并尝试执行测试:

docker exec -it cassandra cassandra-stress user profile=file:///dir/stress.yaml ops\(insert=1\) n=10000 -graph file=stress.html

结果相同:找不到文件异常。我已经更新了帖子,因为我可能打了些打字或者听不懂答案。

1 个答案:

答案 0 :(得分:0)

您正在通过Docker运行它,并且运行Docker映像的进程无法访问您的文件系统,除非您明确安装它。启动映像时,需要使用-v的{​​{1}}命令开关将目录安装到Docker,然后从docker run引用它,例如:

docker exec

您可以了解有关volumes in Docker documentation的更多信息。

更新:这是完全可行的解决方案:

docker run ... -v /home/kenik/Documents/:/somedir ...
docker exec ... profile=file:///somedir/stress.yaml