天天看點

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/#優雅關閉節點

繼續閱讀