Cant' connect to Cassandra with cqlsh - cassandra

When i tried to connect to my cassandra cluster with cqlsh, i had this following 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")})
So i go to the cassandra.yaml file but my rpc_adress and listen_address parameters are goods.
There is my listen_adress :
# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.
listen_address: localhost
# listen_interface: eth0
# listen_interface_prefer_ipv6: false
And my rpc_address :
rpc_address: localhost
# port for Thrift to listen for clients on
rpc_port: 9160
I also tried to modify the file, but i dont have the right for it.
Thank you in advance

Related

How do I initialize a multi-node Cassandra cluster?

I installed Cassandra DB on my Ubuntu VM1 and also installed on other VM Ubuntu VM2.
MY question is:
How to initialize multi node cluster (single data-center) on my VM's?
I also changed my Cassandra.yaml like below:
IP default to IP system seed , listen_address.
cluster_name: 'MyDigitalOceanCluster'
initial_token: 0
seed_provider:
seeds: "198.211.50.0"
listen_address: 198.211.50.0
rpc_address: 0.0.0.0
endpoint_snitch: RackInferringSnitch
After the changes I received this message:
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")})
Aaron has pretty much given you the answers but for what it's worth set the following in cassandra.yaml:
num_tokens: 16 or if you prefer to specify tokens, make sure you pick tokens which are balanced
listen_address: private_ip
rpc_address: public_ip (or same IP if your VM only has 1 NIC)
set seeds to the IP of both nodes (1 of the nodes is sufficient but 2 is preferred)
endpoint_snitch: GossipingPropertyFileSnitch is recommended and almost always the right choice (see my reasons here https://community.datastax.com/questions/8887/)
When connecting with cqlsh, you need to specify the node's client IP (rpc_address) otherwise it will default to localhost (127.0.0.1). For example:
$ cqlsh 198.211.50.0
Cheers!

Cassandra Says Listening on Port 9042 But Couldn't Connect It

I've running cassandra on my local machine.
I've starting it sudo service cassandra start. And then check logs under var/log/cassandra/system-log and it says:
INFO [main] 2019-07-28 13:13:17,226 Server.java:162 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
INFO [main] 2019-07-28 13:13:17,270 CassandraDaemon.java:501 - Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it
INFO [SharedPool-Worker-1] 2019-07-28 13:13:27,133 ApproximateTime.java:44 - Scheduling approximate time-check task with a precision of 10 milliseconds
INFO [OptionalTasks:1] 2019-07-28 13:13:27,298 CassandraRoleManager.java:339 - Created default superuser role 'cassandra'
Then I try to connect with cqlsh in terminal and it says:
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
What is wrong? Also I couldn't see 9042 port with netstat -tulpn command.
Go to /etc/cassandra/cassandra-env.sh
Uncomment
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
and change it to
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname==localhost"
Set listen_address and broadcast_rpc_address to local ip (get ip address from ifconfig).
Restart Cassandra.
cqlsh localhost 9042
This would work if you didn't change the cassandra.yml file.

Not able to login to cqlsh in Cassandra cluster of 3 nodes hosted in Google cloud platform

I'm setting up a 3 node Cassandra cluster and after installing
cassandra I tried to connect to cassandra using 'cqlsh'
I'm not able to connect to cassandra db terminal.
rammady#deb-cassandra-ram-1:~$ cqlsh 10.142.0.76 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")})
I've modified cassandra.yaml file and provided 1: private ip address
under seed -seed:10.142.0.75,10.142.0.76,10.142.0.77 2:
listen_address: 10.142.0.75 3: rpc_address: 10.142.0.75
You need to connect to the ip you defined in the config:
cqlsh 10.142.0.75
netstat -tulpn would show you, that the node is listening not on the loopback if.

accessing remote cassandra database

I am trying to access remote cassendra database by command:
cqlsh xx:x:x:x xxxx
got below error:
Connection error:
('Unable to connect to any servers',
{'xx:x:x:x': ConnectionShutdown('Connection to xx:x:x:x was closed',)
}
)
when I am trying to access localhost I am getting error:
command: cqlsh
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")}
)
You need to check that Cassandra is accessible on the given IP & port that you specify in the command line. If you didn't change default ports, then you can use cqlsh IP. If it doesn't work, check that you don't have firewall that doesn't allow traffic to port 9042 on given IP.

CQLSH is not recognized in google cloud datastax cluster nodes

I have deployed a 4 node datastax cluster in GCP. I can ssh into each of the VM nodes but cqlsh is not recognized.Can you please help me to understand where I am going wrong
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")})
If your cluster is working correctly, then the nodes must know about each other by their own IPs (internal or external). So Cassandra isn't configured to bind 9042 to 127.0.0.1, which means trying to cqlsh to 127.0.0.1:9042 won't work.
One way to check, would be just to do a nodetool status, and use one of those IP addresses. But, as you're on GCP, you may have both internal and external IP addresses, so in that case it really depends on which IP is set as your broadcast_rpc_address. You can check them all by grepping your cassandra.yaml.
$ grep "_address:" cassandra.yaml
listen_address: 192.168.1.3
broadcast_address: 10.20.15.1
# listen_on_broadcast_address: false
rpc_address: 192.168.1.3
broadcast_rpc_address: 10.20.15.1
In this case, your cqlsh command would look something like this:
cqlsh 10.20.15.1 -u youruser -p yourpassword

Resources