Reputation: 633
I tried accessing Apache Cassandra using cqlsh
But it returns with the error
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
Upvotes: 1
Views: 773
Reputation: 1538
You need to check what rpc_address and listen_address configured in cassandra.yaml then run the cqlsh command with port if you changed the default port. you will be able to connect the cassandra server.
Upvotes: 1
Reputation: 2283
There are multiple options:
a) using the IP address defined in your cassandra.yaml
file in the key listen_address
# cat cassandra.yaml | grep listen_address:
listen_address: 172.1.2.3
# cqlsh 172.1.2.3
Connected to keyspace1 at 172.1.2.3:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
b) if you are using linux, the command hostname can be helpful for this:
# cqlsh $(hostname)
Connected to keyspace1 at test-c-ca5d61df000b73cb4:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
c) get any IP address from the cluster with nodetool status
# nodetool status
Datacenter: us-east-vpc
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID
Rack
UN 172.1.2.3 4.7 GiB 256 33.1% 655da17a-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1d
UN 172.1.4.5 4.94 GiB 256 33.5% 23f18c46-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1c
UN 172.1.6.8 4.74 GiB 256 33.4% f8ad0b6a-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1a
# cqlsh 172.1.6.8
Connected to keyspace1 at 172.1.6.8:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
Upvotes: 1