将cassandra-stress连接到AWS Keyspaces时遇连接失败问题求助
Let's walk through the common gaps that might be causing your connection failures—since you already got cqlsh working, we know the basics are right, so it's likely specific to how cassandra-stress interacts with AWS Keyspaces and Docker.
1. Missing Required CQL Version
AWS Keyspaces strictly requires CQL 3.4.4, which you specified in your cqlsh command but didn't include in the cassandra-stress call. This is a frequent oversight because native Cassandra doesn't enforce this, but AWS's managed service does.
Add cqlversion=3.4.4 to your -mode parameter to match your working cqlsh config.
2. Docker Container Path Mismatch for Truststore
When running cassandra-stress inside Docker, the path to your cassandra_truststore.jks in the command refers to the container's filesystem, not your host machine. If you didn't mount the host directory containing the truststore into the container, cassandra-stress can't find the file.
Fix this by:
- Mounting your host's
.cassandradirectory to a path inside the container (e.g.,/opt/cassandra-ssl/) using the-vflag indocker run. - Updating the
truststorepath in your command to point to the container's mounted path.
3. SSL Isn't Explicitly Enabled in Transport Settings
While you specified the truststore, cassandra-stress might not default to SSL for the connection. AWS Keyspaces only accepts encrypted connections, so you need to explicitly enable SSL in the transport config.
Add ssl=true to the -transport section of your command.
4. Special Characters in Password Are Being Parsed by Shell
Your password contains / and = characters, which can be misinterpreted by the Docker shell if not properly quoted. Wrap both your username and password in single quotes to prevent shell parsing.
Corrected Docker Command Example
Putting all these fixes together, your command should look something like this:
docker run -v /root/.cassandra/:/opt/cassandra-ssl/ cassandra:3.11 /bin/bash -c " cd /usr/local/bin && ./cassandra-stress write \ -node cassandra.eu-central-1.amazonaws.com \ -port native=9142 \ -transport truststore=/opt/cassandra-ssl/cassandra_truststore.jks truststore-password=mypassword ssl=true \ -mode native cql3 cqlversion=3.4.4 \ user='myuser-at-722222222222' \ password='12/12ZmHmtD1klsDk9cgqt/XXXXXXXXxUz6Sy687z/U=' "
Bonus Check: Cassandra Version Compatibility
Ensure you're using a cassandra-stress version that matches AWS Keyspaces' underlying Cassandra version (3.11.x). Using a newer or older version can introduce compatibility issues—using the cassandra:3.11 Docker image ensures you're on the right version.
内容的提问来源于stack exchange,提问作者Yaron

