卡桑德拉(Cassandra)所有的主人都尝试查询失败的cassandracsharpdriver
我试图将Cassandra从虚拟机连接到主机,并将其与Cassandracsharpdriver一起使用。该错误是“试图查询的所有主机失败(trover :: socketException'连接尝试失败,因为连接的方在一段时间后连接的响应未正确响应,或者建立的连接失败,因为连接的主机未能响应')。 我已经在主机(XXX1)上进行了Cassandra测试,然后它可以使用,然后在上面使用Cassandra创建3个虚拟机(xxx2),(xxx3),(xxx4),但它们都无法在主机上使用。我什至尝试在.YAML配置文件中添加所有IP,但似乎不起作用,尽管X2,X3,X4以相同的方式在VirtualBox上相互连接。是否需要检查任何东西,以便将3个虚拟机连接到主机。这是我所做的:config virt机器网络仅主机; confim virt机IP到静态; config .yaml文件cirt and Main Machine;创建键空间,表。这是代码创建Isession
public static DataConnection Ins
{
get
{
if (_Ins == null)
_Ins = new DataConnection();
return _Ins;
}
set
{
_Ins = value;
}
}
private static DataConnection _Ins;
private DataConnection()
{
session = getConnect();
session.Execute("use KeySpace;");
}
public ISession session;
private string IP = "x.x.x.4";
private string Datacenter = "datacenter1";
public ISession getConnect()
{
return session = Cluster.Builder()
.AddContactPoints(IP)
.WithPort(9042)
.WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy(Datacenter))
.Build()
.Connect();
}
,这里是使用部分:
private void LoginBtnSubmit_Click(object sender, EventArgs e)
{
string query = "Query sth";
Cassandra.RowSet row = DataConnection.Ins.session.Execute(query);
if (row.FirstOrDefault() != null)
{
//Do sth
}
}
I tried to connect cassandra from virtual machine to main machine and use it with CassandraCSharpDriver. The error is "All hosts tried for query failed (tried :: SocketException 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond')".
I already have cassandra tested on main machine (x.x.x.1) and it worked, then I create 3 virtual machine with cassandra on it (x.x.x.2),(x.x.x.3),(x.x.x.4) but none of them worked on main machine. I even tried add all of the IP in the .yaml config file but doesn't seem work, althought x2, x3, x4 connected to each others on virtualbox with the same way. Is there anything I need to check in order to connect 3 virtual machine to main machine. Here is what I have done: config virt machine network to host-only; config virt machine IP to static; config .yaml file both virt and main machine; create keyspace, table. Here is the code create ISession
public static DataConnection Ins
{
get
{
if (_Ins == null)
_Ins = new DataConnection();
return _Ins;
}
set
{
_Ins = value;
}
}
private static DataConnection _Ins;
private DataConnection()
{
session = getConnect();
session.Execute("use KeySpace;");
}
public ISession session;
private string IP = "x.x.x.4";
private string Datacenter = "datacenter1";
public ISession getConnect()
{
return session = Cluster.Builder()
.AddContactPoints(IP)
.WithPort(9042)
.WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy(Datacenter))
.Build()
.Connect();
}
And here the using part:
private void LoginBtnSubmit_Click(object sender, EventArgs e)
{
string query = "Query sth";
Cassandra.RowSet row = DataConnection.Ins.session.Execute(query);
if (row.FirstOrDefault() != null)
{
//Do sth
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论