从关系表到Keyspaces
(注:keyspace是Cassandra 中最顶层的命名空间。)
现在要考虑的问题是如何转换它们,可按以下方法进行:
根据敏捷开发的相关经验,如果某事件很难或很复杂,最好将其分成多个部分,因为毕竟与MMF(Minimal Marketable Feature,最小市场化功能)之间还有一定的差距。步骤如下:
步骤1:将关系数据库中的表转移到Cassandra列族(Column Families)中
步骤2:创建新的列族使所有数据无需进行JOIN等操作。
步骤3:根据搜索器与查询方法的需要扩展列族。通常情况下一个搜索器或一个查询方法使用一个列族。
步骤4:根据之前的步骤修改Creators与Updater函数。不要担心保存重复数据,只要记住一点:只需考虑数据查询,忘记以前关系型数据库相关的法则。
步骤5:判断,如果没有完成,继续做步骤3与步骤4。
I had a relational database, that I wanted to migrate to cassandra. Cassandra's sstableloader provides option to load the existing data from flat files to a cassandra ring. Hence this can be used as a way to migrate data in relational databases to cassandra, as most relational databases let us export the data into flat files.
sqoop gives the option to do this effectively. Interestingly, DataStax Enterprise provides everything we want in the big data space as a package. This includes, cassandra, hadoop, hive, pig, sqoop, and mahout, which comes handy in this case.
Under the resources directory, you may find the cassandra, dse, hadoop, hive, log4j-appender, mahout, pig, solr, sqoop, and tomcat specific configurations. For example, from resources/hadoop/bin, you may format the hadoop name node using ./hadoop namenode -format
as usual.
Download and extract DataStax Enterprise binary archive (dse-2.1-bin.tar.gz). * Follow the documentation, which is also available as a PDF. * Migrating a relational database to cassandra is documented and is also blogged. * Before starting DataStax, make sure that the JAVA_HOME is set. This also can be set directly on conf/hadoop-env.sh. * Include the connector to the relational database into a location reachable by sqoop. I put mysql-connector-java-5.1.12-bin.jar under resources/sqoop. * Set the environment $ bin/dse-env.sh * Start DataStax Enterprise, as an Analytics node.
$ sudo bin/dse cassandra -t
where cassandra starts the Cassandra process plus CassandraFS and the -t option starts the Hadoop JobTracker and TaskTracker processes. if you start without the -t flag, the below exception will be thrown during the further operations that are discussed below.