未找到cassandra应力文件异常

ff29svar  于 2021-06-10  发布在  Cassandra
关注(0)|答案(1)|浏览(371)

我正在尝试使用已定义的own.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压力无论如何也找不到它。
你知道怎么做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 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

结果相同:文件未找到异常。我更新了这篇文章,因为我打了一些字或者没有正确理解答案。

ecfsfe2w

ecfsfe2w1#

您正在通过docker运行它,并且运行docker映像的进程在显式装载它之前无法访问您的文件系统。启动映像时,需要使用 -v 命令开关 docker run ,然后从 docker exec ,例如:

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

您可以在docker文档中阅读有关卷的更多信息。
更新:以下是完全可行的解决方案:

docker run -v /var/tmp/123/:/data/ --name stress-test cassandra
sudo cp sales-stress-exampl.yaml /var/tmp/123
docker exec -ti stress-test cassandra-stress user \
  profile=file:///data/sales-stress-exampl.yaml \
  ops\(insert=3,read1=1\) no-warmup

相关问题