Cassandra linux cannot connect from remote - cassandra

I have installed cassandra but not able to connect to cassandra server from remote ip..
[root#li1632-39 ~]# cassandra -v
3.0.9
I and connecting public_ip:9042 but connection refused. When I try to validate by telnet I can see port is closed.
When I try to check the status of cassandra its running.
[root#li1636-25 ~]# nodetool status
Datacenter: singapore
=====================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.130.104 297.48 KB 256 100.0% 85bebb4d-4ce9-4144-b33a-8e9759a87e54 rack5
UN 192.168.130.59 262.73 KB 256 100.0% f79f1c04-b567-4e15-98f0-5fd1a8345f61 rack5
I have cassandra.yaml
listen_address: 192.168.130.59
rpc_address: 192.168.130.59
start_rpc: true
I have also tried with cassandra.yaml
listen_address: 0.0.0.0
rpc_address: 0.0.0.0
start_rpc: true
In this case I am getting below error.
[root#li1636-25 ~]# nodetool status
nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
Error from the remote host on telnet.
A-MacBook-Air:~ ads$ telnet public_ip 9042
Trying 172.104.52.39...
telnet: connect to address public_ip: Connection refused
telnet: Unable to connect to remote host
Below is the result of Netstat
netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3575/sshd
tcp 0 0 192.168.130.59:7000 0.0.0.0:* LISTEN 6777/java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 6777/java
tcp 0 0 127.0.0.1:37857 0.0.0.0:* LISTEN 6777/java
tcp 0 0 192.168.130.59:9160 0.0.0.0:* LISTEN 6777/java
tcp6 0 0 192.168.130.59:9042 :::* LISTEN 6777/java
tcp6 0 0 :::22 :::* LISTEN 3575/sshd
I have stopped Firewalld also.

Related

Why can't I talk to a service on tcp/3000 on my CentOS VPS

I'm trying to run a second web service on my VPS at port 3000.
On the VPS I run:
# php -S myhost.com:3000
and then in a browser, navigate to http://myhost.com:3000 but the browser times out and the service logs/outputs nothing.
If I run the service on port 80 (i.e., php -S myhost.com:80 and navigate to http://myhost.com), it works.
So firewall. Except that:
[root#spinal ~]# firewall-cmd --list-ports
3887/tcp 3000/tcp
(the 3887 is another service, which is working correctly.) And I rebooted the VPS after setting up port 3000 in the firewall. I reckon the service is listening correctly because:
[root#spinal ~]# netstat -tupl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:imap 0.0.0.0:* LISTEN 1907/dovecot
tcp 0 0 0.0.0.0:ciphire-data 0.0.0.0:* LISTEN 1876/sshd
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN 1903/nginx: master
tcp 0 0 0.0.0.0:urd 0.0.0.0:* LISTEN 2004/master
tcp 0 0 myhost.com:hbci 0.0.0.0:* LISTEN 2206/php
tcp 0 0 localhost.loca:postgres 0.0.0.0:* LISTEN 1908/postgres
tcp 0 0 0.0.0.0:smtp 0.0.0.0:* LISTEN 2004/master
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN 1903/nginx: master
tcp 0 0 0.0.0.0:imaps 0.0.0.0:* LISTEN 1907/dovecot
tcp 0 0 localhost.lo:cslistener 0.0.0.0:* LISTEN 1878/php-fpm: maste
tcp6 0 0 [::]:imap [::]:* LISTEN 1907/dovecot
tcp6 0 0 [::]:ciphire-data [::]:* LISTEN 1876/sshd
tcp6 0 0 [::]:urd [::]:* LISTEN 2004/master
tcp6 0 0 [::]:smtp [::]:* LISTEN 2004/master
tcp6 0 0 [::]:imaps [::]:* LISTEN 1907/dovecot
I can however connect locally. This works, when run on the VPS:
$ curl http://myhost.com:3000
so that again points at the firewall. But disabling the firewall doesn't help:
# systemctl stop firewalld
so it could be a DNS problem: my browser and the VPS differ on what myhost.com resolves-to. Except that, as mentioned above, switching to port 80 solves the problem. So it's something to do with coming-in on port 3000, from outside. But not firewalld.
The question at Can't reach nodejs on port 3000 from external on CentOS 7 is close to mine, but isn't conclusively answered.
I feel pretty stupid. It was a firewall; not on the VPS, but on my local network. When I tried it on a machine that doesn't go through my local network, it worked. I hope my public confession helps someone else.

Connect remote scylla db server shows error

I have installed scylla-db in google cloud servers.
Steps i have followed:
sudo yum install epel-release
sudo curl -o /etc/yum.repos.d/scylla.repo -L http://repositories.scylladb.com/scylla/repo/a2a0ba89d456770dfdc1cd70325e3291/centos/scylladb-2.0.repo
sudo yum install scylla
sudo scylla_setup
(Given yes to "verify supportable version" , " verify packages" , "core dump", " fstim ssd "
For remaining : Given NO)
IN file :/etc/scylla.d/io.conf
SEASTAR_IO="--max-io-requests=12 --num-io-queues=1"
( edited this file manually )
sudo systemctl start scylla-server
It shows: Cannot able to read yaml file. Then google it and downgraded the yaml-cpp version to 0.5.1 from 0.5.3 version.
then
scylla-server started running .
[root#scylla ~]# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 127.0.0.1 208.69 KB 256 ? 888e91da-9385-4c61-8417-dd59c1a979b8 rack1
Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
[root#scylla ~]# cat /etc/scylla/scylla.yaml | grep seeds:
- seeds: "127.0.0.1"
[root#scylla ~]# cat /etc/scylla/scylla.yaml | grep rpc_address:
rpc_address: localhost
#broadcast_rpc_address:
[root#scylla ~]# cat /etc/scylla/scylla.yaml | grep listen_address:
listen_address: localhost
[root#scylla ~]# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.8 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
cqlsh> exit
[root#scylla ~]# netstat -tupln | grep LISTEN
tcp 0 0 127.0.0.1:10000 0.0.0.0:* LISTEN 6387/scylla
tcp 0 0 127.0.0.1:9042 0.0.0.0:* LISTEN 6387/scylla
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1105/sshd
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 6387/scylla
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1119/master
tcp 0 0 0.0.0.0:9180 0.0.0.0:* LISTEN 6387/scylla
tcp 0 0 127.0.0.1:9160 0.0.0.0:* LISTEN 6387/scylla
tcp6 0 0 :::80 :::* LISTEN 5217/httpd
tcp6 0 0 :::22 :::* LISTEN 1105/sshd
tcp6 0 0 :::35063 :::* LISTEN 6412/scylla-jmx
tcp6 0 0 ::1:25 :::* LISTEN 1119/master
tcp6 0 0 127.0.0.1:7199 :::* LISTEN 6412/scylla-jmx
scylla-server is running.
Same setup was done another server
Server Name scylla-db-1
I need to connect to the server scylla ( IP: xx.xx.xxx) from this server.
when i execute the below :
[root#scylla-db-1 ~]# cqlsh xx.xx.xxx
Connection error: ('Unable to connect to any servers', {'xx.xx.xxx': error(111, "Tried connecting to [('xx.xx.xxx', 9042)]. Last error: Connection refused")})
How to connect the remote server from this server?
Also
while checking the http://xx.xx.xxx:10000 and http://xx.xx.xxx:10000/ui in the browser , I m getting problem loading page.
Note :
I have done editing the /etc/scylla.d/io.conf file for assigning the
max-io-requests manually
Port 10000 is the rest api for scylla and is usually left bounded to the 127.0.0.1 - thats why you can not access it
To gain access via cql you need to edit the /etc/scylla/scylla.yaml file and set the rpc_address
Please follow the instructions for configuring scylla for a cluster deployment: single dc http://docs.scylladb.com/procedures/create_cluster/ or multi dc http://docs.scylladb.com/procedures/create_cluster_multidc/.
You need set rpc_address on scylla.yaml and while connecting through cql give your rpc_address as well cqlsh xx.xxx.xxx.xx with user/pass if enabled.

All of a sudden -- tcp connect (localhost:5432): connection refused - :econnrefused

For a few months all has been ok, but now I have a lot of:
mix phoenix.server
[error] Postgrex.Protocol (#PID<0.302.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.303.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
on localhost.
But:
Postgresql is running
Its config is the same
The config of my phoenix/elixir application is the same too.
systemctl status postgresql shows everything is ok
nothing bad in the log
I can connect to Pg via Pg GUI tool
What's the matter?
$ netstat -tulnp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 ::1:5432 :::* LISTEN -
udp 0 0 192.168.1.37:68 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* 25117/libpepflashpl
udp6 0 0 :::5353 :::* 25117/libpepflashpl

How to configure Cassandra on GCE then I can access it from my local java application running on Win7?

I created a CentOS on GCE and installed dsc-cassandra 3.0. Then I changed the rpc_address from localhost to the internal ip or external ip in cassandra.yaml.
On the VM, I started cassandra and use cqlsh to access cassandra successfully. But I couldn't use cqlsh internal_ip or cqlsh external_ip.
Also, I turned on tcp:9042 port for this instance.
But I still couldn't access Cassandra from my local java app with the NoHostAvailableException(Cannot connect).
By the way, I did the same thing of my local VM running with VM VistualBox. I could access it.
Running sudo netstat -lntp | grep pid displayed:
tcp 0 0 127.0.0.1:33743 0.0.0.0:* LISTEN 1207/java
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 1207/java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 1207/java
tcp6 0 0 127.0.0.1:9042 :::* LISTEN 1207/java
The Ip address was still 127.0.0.1. I think this is the problem.
How to configure the cassandra.yaml file?
I know where I was wrong.
I used sudo service cassandra restart to restart cassandra after editing the cassandra.yaml. The terminal showed:
Restarting cassandra (via systemctl): [ OK ]
Actually, I think it didn't really restart it. Then I used nodetool stopdaemon to stop cassandra and then start it again. The configuration of cassandra.yaml worked.
Helpful commands:
1.
ps aux | grep cassandra
sudo netstat -lntp | grep <cassandra_pid>
Using these commands to verify the ip/port of the cassandra service on remote VM.
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 5928/java
tcp 0 0 127.0.0.1:42682 0.0.0.0:* LISTEN 5928/java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 5928/java
tcp6 0 0 10.138.0.2:9042 :::* LISTEN 5928/java
2.
telnet <cassandra_ip> 9042
Using this command to verify the ip/port of the cassandra service on local machine.

Restricting Cassandra to localhost only

I installed cassandra as a service on Ubuntu. Test Cluster is accessible on 127.0.0.1:9042. I want to restrict everything related to cassandra to localhost only, nothing open to internet. Currently, this is what I see on netstat -tulpen:
udp 0 0 130.159.223.50:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
udp6 0 0 fe80::215:5dff:fcdf:123 :::*
udp6 0 0 ::1:123 :::*
udp6 0 0 :::123 :::*
Disclaimer: What you want to achieve can be done through configuration, but for a production cluster, it should be done using a firewall.
You need to modify a number of settings in cassanra.yaml to listen only for the loopback address (127.0.0.1)
listen_address: 127.0.0.1
rpc_address: 127.0.0.1
# make sure the broadcast address is commented out
# broadcast_address: 1.2.3.4
When running nodetool you should see the node's ip as the loopback interface ip
$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 127.0.0.1 60.62 TB 256 ? e7060cda-f99b-495c-ad55-2d380b4d452e rack1
Note: Non-system keyspaces don't have the same replication settings, effective ownership
information is meaningless
You can then verify that cassandra is innacessable over the public or private ip but only on the loopback ip with telnet:
core:cassandra core$ telnet <external ip> 9042
Trying 134.103.x.x...
telnet: connect to address 134.103.x.x: Connection refused
telnet: Unable to connect to remote host
core:cassandra core$ telnet <internal ip> 9042
Trying 10.17.x.x...
telnet: connect to address 10.17.x.x: Connection refused
telnet: Unable to connect to remote host
core:cassandra core$ telnet 127.0.0.1 9042
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> Connection closed.

Resources