如何在cassandra中获取所有群集,数据中心及其所有详细信息的列表。
system.peers
是否足以提供所有已连接的群集详细信息?
答案 0 :(得分:1)
使用#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
string first = "hello";
string second = "hello_world";
int match = 0;
size_t lowest = first.length() <= second.length() ? first.length() : second.length();
for (int i = 0; i < lowest; ++i) {
if(first.at(i) == second.at(i)) {
match++;
} else {
break;
}
}
cout << match << endl;
return 0;
}
和system.local
。
在3节点群集system.peers
中将包含有关当前节点的数据,system.local
将包含仅有2个其他节点的数据
注意: system.peers
只有一条记录。
答案 1 :(得分:0)
直接访问系统表可能有效,但可能不是“便携式”#34; Cassandra版本之间。我建议使用驱动程序获取群集元数据 - 它将适用于不同版本的Cassandra(通过Java driver或Python driver)。
P.S。我在扩展Cassaforte(Clojure的驱动程序)时遇到了这个问题 - 在切换到通过驱动程序获取元数据之后,我能够支持所有Cassandra版本。