天天看点

NoSQL_Cassandra_导出数据库结构/数据库结构还原

今天博主遇到了个情况,就是要还原数据库的表结构。特此记录一下

通过以下的过程可以达到数据库还原, 且不需要cqlsh登录数据库进行操作的效果。

过程如下:

1.导出数据库描述文件(建表语句)

cqlsh 10.200.250.192(server ip)  -e 'desc keyspace  clicki_dc(keyspace name)'  > db.cql(db's file)

2.利用导出的数据库文件还原服务器上的数据库

cqlsh 10.200.250.190(server ip) -f db.cql(db's file)

在还原过程中会用到的指令:

nodetool status (查看集群状态的指令)

nodetool stopdaemon(关闭当前节点的cassandra server)

cassandra -f (cassandra 前台启动, 方便查看错误)

话外篇:

如果你们当前的环境是Cassandra的集群,只需要在seeds(或者任意一台机器?)创建数据库即可。

其他节点会通过seeds节点,更新自己的数据库。

在处理过程中遇到了,修改数据库集群的名字搭建集群的问题。

解决方法:

http://stackoverflow.com/questions/22006887/cassandra-saved-cluster-name-test-cluster-configured-name

参考文章:

http://zqhxuyuan.github.io/2015/10/15/Cassandra-Operation/#优雅关闭节点

继续阅读