Cassandra, Cassandra.yaml - cassandra

I have some questions about Cassandra, first of all i want to create columns and keyspaces in the storage-conf.xml, (which i dont have but i think that cassandra.yaml replaced that in the latest version)
I tried to write this in the cassandra.yaml by opening it in notepad, but it didnt seem to work since i couldnt see my new keyspace in datastax web interface.
<Keyspace>
<Keyspace Name="Sales">
<ColumnFamily Name="Customer" CompareWith="UTF8Type" />
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy
</ReplicaPlacementStrategy>
<ReplicationFactor>1</ReplicationFactor
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
</Keyspace>
What am i doing wrong?
I also wonder if there is a somehow easy way to migrate a relational sql server database in to cassandra?
Thanks in advance!

You are trying to create a keyspace and column by adding the above to cassandra.yaml you cant do that. Second of all what you are adding really doesn't make sense, cassandra.yaml is a YAML file, and the above is XML markup. Cassandra.yaml is for configuration only. If you want to add keyspaces/columns you are going to have to use a cassadra interface (cassandra APIs).
As for the migration, is there an easy way? No not really. B̶u̶t̶ ̶w̶i̶t̶h̶ ̶l̶o̶t̶s̶ ̶o̶f̶ ̶d̶e̶n̶o̶r̶m̶a̶l̶i̶z̶a̶t̶i̶o̶n̶ ̶a̶n̶d̶ ̶r̶e̶s̶e̶a̶r̶c̶h̶ ̶i̶t̶ ̶c̶a̶n̶ ̶b̶e̶ ̶d̶o̶n̶e̶.̶ ̶H̶e̶r̶e̶ ̶i̶s̶ ̶a̶ ̶[̶b̶l̶o̶g̶]̶[̶5̶]̶ ̶t̶h̶a̶t̶ ̶g̶o̶e̶s̶ ̶o̶v̶e̶r̶ ̶a̶ ̶b̶a̶s̶i̶c̶ ̶w̶a̶y̶ ̶o̶f̶ ̶a̶t̶t̶e̶m̶p̶t̶i̶n̶g̶ ̶t̶o̶ ̶d̶o̶ ̶s̶o̶.
Update
The blog is gone 😞. This tutorial by oreilly provides a good overview of how a typical RDMS data model can be modified for Cassandra.

Related

Exporting a Cassandra Keyspace with Data to a file

Am trying to export a Cassandra Keyspace plus Data to a file. Is there a cqlsh command that allows the export of all tables + Data at once.?
I used this code to export the keyspace. Now I would like to export all the Data from all the tables into the file.
$ cqlsh -e "DESCRIBE KEYSPACE somekeyspace" > /path/to/somekeyspace.cql
Looking at the DataStax documentation, you should be able to do that using the COPY command as follows (for a single table):
COPY someKeySpace.someTable (someCol1, someCol2)
TO '/path/to/someTable_Col1Col2.csv' WITH HEADER = TRUE;
For all tables, probably you will need to write this code multiple times OR iterate through the tables. You might find this article also useful.
ps. I also found this GitHub repo that seems interesting, but I haven't used it yet myself, so I am suggesting it here for you to maybe give it a try :)
https://github.com/masumsoft/cassandra-exporter

Unable to add cassandra connection

I am trying to add an connection to my cassandra database.
As shown in the examples I added this definition:
#Store(type='cassandra', column.family='StockTable',keyspace='AnalyticsFamily',cassandra.host='localhost')
#IndexBy('volume')
#PrimaryKey('symbol')
define table StockTable (symbol string, price float, volume long);
In the editor I get an red cross as shown in the image below.
Am I missing the cassandra driver on the worker? If yes, how can I add it to the docker image? Or what am I doing wrong?
You have to add the osgi compatible cassandra connectors to {SP_HOME}/lib folder.
Please see https://docs.wso2.com/display/SP4xx/Configuring+Datasources for more details

InvalidRequestException Keyspace keyspace1 does not exist

I'm trying to connect to a Datastax Community Edition server 2.1.2 via JDBC but I keep getting the following error no matter what I try to do, even when issuing a very basic command like select * from system_traces.events;
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
Issuing that same command via cqlsh works properly, so it seems to be a JDBC issue.
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:229):229
at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92):92
at java.sql.DriverManager.getConnection(DriverManager.java:664):664
at java.sql.DriverManager.getConnection(DriverManager.java:270):270
at railo.commons.db.DBUtil.getConnection(DBUtil.java:109):109
at railo.runtime.db.DatasourceConnectionPool.loadDatasourceConnection(DatasourceConnectionPool.java:89):89
at railo.runtime.db.DatasourceConnectionPool.getDatasourceConnection(DatasourceConnectionPool.java:81):81
at railo.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl.java:65):65
at railo.runtime.tag.Query.executeDatasoure(Query.java:696):696 ...
Any ideas? TIA!
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
This exception means you are trying to query for a keyspace (in this case "Keyspace1") that hasn't yet been added to Cassandra. Try creating the keyspace before querying it.
You're probably doing a select (SELECT * FROM "Keyspace1"."Standard1") that you're not seeing or passing initialisation parameters to JDBC telling it to connect to Keyspace1. Verify that your code isn't looking for the non-existent keyspace by searching through the queries you have, specifically looking for Keyspace1 (or "Keyspace1" since in this case the keyspace name is case-sensitive).
On a side-note, "Keyspace1"."Standard1" tend to be the standard ks.cf pair used for cassandra examples so it would be good to scan your code for them to make sure that they are created before they are queried.

who has a whole cassandra jdbc example which can run in eclipse?

the example may include:
create keyspace and columnfamily
insert data
select/get data and show in Console
because I found this http://cassandra.apache.org/doc/cql/CQL.html is hard to me
thank you for attention , I got it http://niranjandubey.blogspot.com/2012/11/cassandra-jdbc-to-perform-crud.html.
But I also need a FILE-read-write example of cassandra (may be using datastax?)

Apache Cassandra. UnavailableException While Trying to insert a record

I am very new to Cassandra, and some how configured it. I was following This Link
.
Everything was fine. But in the end when I am trying to insert a record, it gives me the following exception. Today since afternoon I am trying to fix this. Googled a lot, but could not reach anywhere.
Any help on this will be greatly appretiated.
[default#DEMO] set Users[1234][name] = scott;
null
UnavailableException()
at org.apache.cassandra.thrift.Cassandra$insert_result.read(Cassandra.java:16077)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_insert(Cassandra.java:801)
at org.apache.cassandra.thrift.Cassandra$Client.insert(Cassandra.java:785)
at org.apache.cassandra.cli.CliClient.executeSet(CliClient.java:909)
at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:222)
at org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:201)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:328)
[default#DEMO]
Thank you
Achyuth
this is old one, I want to share my experience.
I had same issue when I was setting the qa environment. Every thing configured fine: including : cassandra-topology.properties. But the nodetool ring display the unknown DC value for all nodes since the default is set UNKNOWN. That told me that the cassandra-topology.properties is not right in some way. After tried several things still no luck, I decided to create my own cassandra-topology.properties file and re-type every thing with vi, then it starts fine.
So if you have issue, run nodetool ring first to see if the DC set is what it should be.

Resources