We're setting up 3 node Cassandra cluster in AWS.
We performed the below steps ;
1) On all 3 nodes, installed the latest version of Oracle JDK 1.8.
On all 3 nodes, installed Cassandra 2.1.8.
On all 3 nodes, located cassandra.yaml and set the following properties:
cluster_name: 'ABC'
authenticator: PasswordAuthenticator
authorizer: CassandraAuthorizer
write_request_timeout_in_ms: 5000
2) In the same file, set both "listen_address" and "rpc_address" to a permanent address of a host (the one which is not changed after Amazon VM restart).
3) In the same file, under "seed_provider" property, set "seeds" property to a permanent address of a host (the one which is not changed after Amazon VM restart) which is choosen to be the seed.
4) Save all changes and close the file. Also open the required ports in firewall.
5) Started Cassandra on all nodes one by one and confirmed that all nodes are up.
Problem :
Connected to node 1 and executed the below query
root#ip-10-181-119-112:/etc/cassandra/bin# ./cqlsh -u cassandra -p cassandra 10-181-119-112
Connected to Dev Cluster at 10-181-119-112:9042.
[cqlsh 5.0.1 | Cassandra 2.1.8 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cassandra#cqlsh> ALTER KEYSPACE system_auth WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'us-east': 3 };
Tried to change the same on second node but I am not able to connect to second node facing below error.
root#ip-10-181-133-155:/etc/cassandra/bin# ./cqlsh -u cassandra -p cassandra 10-181-133-155
Connection error: ('Unable to connect to any servers', {'10-181-133-155': AuthenticationFailed(u'Failed to authenticate to 10-181-133-155: code=0100 [Bad credentials] message="org.apache.cassandra.exceptions.UnavailableException: Cannot achieve consistency level QUORUM"',)})
Please let me know what I am doing wrong here and help me in resolving this issue.
It seems like it can't read the authentication data for the default user. Try to nodetool repair the system_auth keyspace on all nodes. Also, make sure the datacenter name used in your replication settings ("us-east") matches what you see in nodetool status.
Related
I try to build Cassandra cluster with 3 nodes
On node 1 i've got a trouble when i try use cqlsh:
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")})
In cassandra.yaml i dont't see strings with ip 127.0.0.1, i wrote there correct parametres (in my mind)
cluster_name: 'cassandra_cluster'
seeds: "node_public_ip_1,node_public_ip_2,node_public_ip_3"
listen_address: node_public_ip_1
rpc_adress: node_public_ip_1
in cassandra-topology.properties:
`# Cassandra Node IP=Data Center:Rack`
node_public_ip_1=dc1:rac1
node_public_ip_2=dc1:rac1
node_public_ip_3=dc1:rac1
What i do wrong?
Thanks!
When you run cqlsh without specifying the host, it defaults to localhost (127.0.0.1). You need to specify the client IP address (rpc_address) of the node you want to connect to when running cqlsh.
Also, the standard recommendation for multi-homed servers is to use the private IP for internal cluster comms and the public IP for client connections. This means that in cassandra.yaml you would configure:
listen_address: private_ip
rpc_address: public_ip
Since the seeds are used for seeding cluster communication, you would also configure the seeds list with the nodes' private IP addresses.
Finally, if you're using the old PropertyFileSnitch, you should also configure cassandra-topology.properties with the nodes' private IP addresses.
However, PFS is really old and in almost all cases our recommendation is to use GossipingPropertyFileSnitch since it has all the benefits of being able to expand the cluster in the future without any downsides as I've explained in this post -- https://community.datastax.com/questions/8887/.
It is also a lot simpler to manage GPFS since you only need to set a single node's DC and rack configuration in cassandra-rackdc.properties without having to reconfigure all the nodes whenever you add/remove nodes from the cluster.
When you do switch to GPFS, you should delete cassandra-topology.properties on the nodes to prevent any gossip issues in the future as I've explained in this post -- https://community.datastax.com/questions/4621/. Cheers!
Try run the "nodetool status" and "nodetool describecluster" on both nodes of this cluster to identify the IP used by nodes.
and try connect passing the host/ip. like:
cqlsh <host> <port> -u <user> -p <password>
I'm running a single node at the moment. I'm trying to enable password authentication for Cassandra.
I'm following this guide: http://cassandra.apache.org/doc/latest/operating/security.html#password-authentication
I'll note that I didn't alter system_auth's replication as it's a single node cluster.
I edited cassandra.yaml to use authenticator: PasswordAuthenticator.
I then restarted cassandra and tried the command cqlsh -u cassandra -p cassandra, but that gives me the error:
Connection error: ('Unable to connect to any servers',
{'127.0.0.1': AuthenticationFailed(u'Failed to authenticate to 127.0.0.1:
code=0100 [Bad credentials] message="org.apache.cassandra.exceptions.
UnavailableException: Cannot achieve consistency level QUORUM"',)})
I've tried running nodetool repair but it says: Replication factor is 1. No repair is needed for keyspace 'system_auth'
How do I solve this?
I managed to solve the problem.
I had to run ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; as it was set to {'class': 'NetworkTopologyStrategy', 'DC1': '1', 'DC2': '1'} previously, even though it was a single node cluster.
This is why it couldn't achieve a QUORUM.
Follow the below steps:
Set the authenticator in /etc/cassandra/cassandra.yaml file to AllowAllAuthenticator
Restart the cassandra
sudo service cassandra restart
run the following commands
cqlsh
ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
Now change the authenticator again back to PasswordAuthenticator
Restart the cassandra
sudo service cassandra restart
Now you will be able to login using the following command
cqlsh -u cassandra -p cassandra
The issue is happening since a system_auth was set to {'class': 'NetworkTopologyStrategy', 'DC1': '1', 'DC2': '1'} previously, even though it was a single node cluster.
http://docs.datastax.com/en/datastax_enterprise/4.8/datastax_enterprise/sec/secConfiguringInternalAuthentication.html
The user 'cassandra' always uses QUORUM in system_auth per default. Try creating a different user (as superuser) and your problem should be gone.
The reason is that you cannot have QUORUM on a single node cluser, see Igors Anwser.
In 1-node (or 2-node) configurations QUORUM is impossible, and repair is not needed (as it's used to fix data inconsistencies between nodes)
In the Cassandra.yaml file, switch the authentication back to authenticator: AllowAllAuthentication and make sure authorizer: AllowAllAuthorizer
is set as well. This will allow you to use cqlsh again. It will no longer be checking for authentication before connecting. Once in cqlsh follow the other answers to lower the required replication to a lower level.
In case you are using docker-desktop do the following:
Use CLI of the docker image:
cd etc/cassandra
vim cassandra.yml - to edit the file
Change authenticator to AllowAllAuthenticator
Restart the container and do following steps:
docker-compose up -d image_name
Refer below highlighted commands:
Now swith back the authenticator to PasswordAuthenticator in cassandra.yaml
Restart conatiner and now use below step to login to cqlsh:
What fixed it for me was go into the cqlsh shell, use the keyspace you're having issue's with, and run the command CONSISTENCY QUORUM
How to enable cassandra port to connect with BI application. Here my setup with cassandra is of multiple nodes (192.xxx.xx.01,192.xxx.xx.02,192.xxx.xx.03). In this scenario which node will be acting like master / coordinator with my application.
Although i worked with listen_address, rpc_address, broadcast_rpc_address and seeds, I opened both tcp ports 9042 and 9160.
version: 3.10
Kindly, lead me to the right direction.
Cassandra uses master-less architecture.All nodes are equal in cassandra.
When you connect to one of the node that node act as co-ordinator node, any of the node can be co-ordinator.
The coordinator is selected by the driver based on the policy you have set. Common policies are DCAwareRoundRobinPolicy and TokenAware Policy.
For DCAwareRoundRobinPolicy, the driver selects the coordinator node based on its round robin policy. See more here: http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/DCAwareRoundRobinPolicy.html
For TokenAwarePolicy, it selects a coordinator node that has the data being queried - to reduce "hops" and latency. More info: http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/TokenAwarePolicy.html
native_transport_port is 9042 by default and clients use native transport by default.
Hence you should have connection from your BI to Cassandra host on port 9042.
I have a cassandra db running locally. I can see it working in Ops Center. However, when I open dev center and try to connect I get a cryptic "unable to connect" error.
How can I get the exact name / connectionstring that I need to use to connect to this local cassandra db via dev center?
The hostname/IP to connect to is specified in the listen_address property of your cassandra.yaml.If you are connecting to Cassandra from your localhost only (a sandbox machine), then you can set the listen_address in your cassandra.yaml accordingly:
listen_address: localhost
When you start Cassandra, you should see lines similar to this either in STDOUT or in your system.log (timestamps removed for brevity):
Starting listening for CQL clients on localhost/127.0.0.1:9042...
Binding thrift service to localhost/127.0.0.1:9160
Listening for thrift clients...
These lines indicate which address you should be using to connect to your cluster. The first way to test your connection, is with clqsh. Note that cqlsh will connect to "localhost" by default. If you are connecting to a host/IP other than localhost, then you will need to specify it on the command line.
$ cqlsh
Connected to Test Cluster at localhost:9042.
[cqlsh 5.0.1 | Cassandra 2.1.0-rc5-SNAPSHOT | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh>
If this works, then you should also be able to connect (and test) from DataStax Dev Center (also on your local machine) by defining a connection to localhost, like this:
At this point, you should be able to connect via your application code (Java CQL3 driver shown):
cluster = Cluster.builder().addContactPoint("localhost").build();
Metadata metadata = cluster.Metadata;
Console.WriteLine("Connected to cluster: " + metadata.ClusterName.ToString());
Session session = cluster.connect();
I have setup Cassandra, and I've created a keyspace('mykeyspace') and a table in it. I started Cassandra as a service, added the cassandra.properties file like this, in the presto installation files:
connector.name=cassandra
cassandra.contact-points=localhost
cassandra.native-protocol-port=9142
cassandra.thrift-port=9160
After this I have issued this command in Presto but I'm not sure if it is connecting to the Cassandra data:
./presto --server localhost:8080 --catalog cassandra --schema mykeyspace
Now, when I give the command 'show tables', I get this Exception-message:
All host(s) tried for query failed (tried: localhost/127.0.0.1 (com.datastax.driver.core.TransportException: [localhost/127.0.0.1] Cannot connect))
I have used cqlsh, to view a created table in 'mykeyspace' in cassandra, and hence sure that cassandra is running.
I would really appreciate any help to clear this error.
If you have a default cassandra installation, the dafault native protocol port is 9042. If that is the case, you can remove cassandra.native-protocol-port and cassandra.thrift-port properties.
If you want to keep this ports, you can change cassandra.yaml configuration file, property native_transport_port
I hope it's helps.