首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cassandra-stress工具在为用户配置文件使用yaml文件时抛出错误

cassandra-stress工具在为用户配置文件使用yaml文件时抛出错误
EN

Stack Overflow用户
提问于 2021-01-11 21:25:29
回答 2查看 158关注 0票数 1

我可以使用默认的键空间和表来运行cassandra-stress,但是参考datastax文档,我尝试使用我自己的配置文件来使用cassandra-stress工具。Datastax文档- https://docs.datastax.com/en/dse/5.1/dse-admin/datastax_enterprise/tools/toolsCStress.html

我有2个DC,有(2+1)节点和Cassandra3.11设置,我相应地修改了yaml文件,但我得到了错误。

命令-

代码语言:javascript
复制
cassandra-stress user profile=/var/lib/cassandra/stresstest/cqlstress-example.yaml n=1000000 ops\(insert=3,read1=1\) no-warmup cl=one

错误-

代码语言:javascript
复制
java.io.IOError: while parsing a block mapping
 in 'reader', line 5, column 4:
       CREATE KEYSPACE perftesting WITH ...
       ^
expected <block end>, but found FlowEntry
 in 'reader', line 5, column 87:
     ... lass': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
                                         ^

    at org.apache.cassandra.stress.StressProfile.load(StressProfile.java:823)
    at org.apache.cassandra.stress.settings.SettingsCommandUser.<init>(SettingsCommandUser.java:62)
    at org.apache.cassandra.stress.settings.SettingsCommandUser.build(SettingsCommandUser.java:150)
    at org.apache.cassandra.stress.settings.SettingsCommand.get(SettingsCommand.java:217)
    at org.apache.cassandra.stress.settings.StressSettings.get(StressSettings.java:264)
    at org.apache.cassandra.stress.settings.StressSettings.parse(StressSettings.java:241)
    at org.apache.cassandra.stress.Stress.run(Stress.java:80)
    at org.apache.cassandra.stress.Stress.main(Stress.java:62)
Caused by: while parsing a block mapping
 in 'reader', line 5, column 4:
       CREATE KEYSPACE perftesting WITH ...
       ^
expected <block end>, but found FlowEntry
 in 'reader', line 5, column 87:
     ... lass': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
                                         ^
    at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:570)
    at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
    at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143)
    at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:230)
    at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159)
    at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:237)
    at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159)
    at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122)
    at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481)
    at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:475)
    at org.apache.cassandra.stress.StressProfile.load(StressProfile.java:814)
    ... 7 more

cqlstress-example.yaml的内容

代码语言:javascript
复制
keyspace: perftesting

keyspace_definition: 

  CREATE KEYSPACE perftesting WITH replication = { 'class': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
  
table: users

table_definition:

  CREATE TABLE users (
    username text,
    first_name text,
    last_name text,
    password text,
    email text,
    last_access timeuuid,
    PRIMARY KEY(username)
  );

extra_definitions:
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name2 AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name3 AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);

columnspec:
  - name: username
    size: uniform(10..30)
  - name: first_name
    size: fixed(16)
  - name: last_name
    size: uniform(1..32)
  - name: password
    size: fixed(80) # sha-512
  - name: email
    size: uniform(16..50)
  - name: startdate
    cluster: uniform(20...40)
  - name: description
    size: gaussian(100...500)
  
insert:
  partitions: fixed(10)
  batchtype: UNLOGGED

queries:
  read1:
    cql: select * from users where username = ? and startdate = ?
    fields: samerow     # samerow or multirow (select arguments from the same row, or randomly from all rows in the partition)  
EN

回答 2

Stack Overflow用户

发布于 2021-01-12 02:30:27

cassandra-stress中的yaml解析器非常严格。我总是在提前定义模式和使用压力插入/查询数据方面取得更大的成功。

我的建议是从stress.yaml中删除CREATE语句,通过cqlsh预先运行它们,然后重试。

票数 1
EN

Stack Overflow用户

发布于 2021-04-26 14:12:37

就像@Aaron所说的,最好提前定义模式。

另外,要注意yaml文件中的多行CQL语句。我发现将多行语句改为单行语句解决了我的大部分问题。

拥有一个带有yaml语法突出显示的IDE可能有助于查看您的语法是不是您想要的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65667713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档