How to connect Cassandra to localhost using cqlsh?

2020-05-30 03:56发布

I set rpc_port to the public IP address, and now I can connect to Cassandra just fine from an outside server.

However, I cannot connect from the Cassandra server itself, using cqlsh

I am getting an error.Thar are:

 Connection error: Could not connect to localhost:9160

Is there a configuration, I can change to be able to connect from the server itself ?

14条回答
Explosion°爆炸
2楼-- · 2020-05-30 04:05

for 2.0.5 the following works for me ..

   $CASSANDRA_HOME/bin/cqlsh xx.xx.xxx.xxx 9160
查看更多
够拽才男人
3楼-- · 2020-05-30 04:07

Consider changing /etc/cassandra-env.sh:

JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=true"
not "true" but "false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"

sudo service cassandra restart

查看更多
放荡不羁爱自由
4楼-- · 2020-05-30 04:07

How to change default port 9042 in Cassandra ?

I resolved issue using below steps :

1) Stop cassandara services

sudo su -
systemctl stop datastax-agent
systemctl stop opscenterd
systemctl stop app-dse

2) Take backup and Change port from 9042 to 9035

cp /opt/dse/resources/cassandra/conf/cassandra.yaml /opt/dse/resources/cassandra/conf/bkp_cassandra.yaml
vi /opt/dse/resources/cassandra/conf/cassandra.yaml

native_transport_port: 9035

3) Start Cassandra services

systemctl start datastax-agent
systemctl start opscenterd
systemctl start app-dse

4) create cqlshrc file.

vi  /root/.cassandra/cqlshrc

[connection]
hostname = 198.168.1.100
port = 9035
查看更多
再贱就再见
5楼-- · 2020-05-30 04:14

Use this command

sudo service cassandra start

to start cassandra and then use

cqlsh command
查看更多
淡お忘
6楼-- · 2020-05-30 04:15

You need to connect to cassandra through the rpc_address defined in cassandra.yaml. For example, I use cqlsh 10.0.80.49 9160.

查看更多
爷、活的狠高调
7楼-- · 2020-05-30 04:19
  1. Check the cassandra.yaml file on the line with rpc_port : normally by default = 9160
  2. Login to the machine hosting cassandra
  3. Try cqlsh 127.0.0.1 9160 : should be ok in any case
  4. try cqlsh [IP of host] 9160 : if ok then cassandra reachable from lan, if ok then cassandra is not reachable from lan but only localhost 127.0.0.1
查看更多
登录 后发表回答