简体   繁体   English

C#到Cassandra服务的用户名和密码

[英]C# to Cassandra service with username and password

Cassandra is running as a service on a remote machine but in the same network. Cassandra作为服务在远程计算机上但在同一网络中运行。 Also I created a .net program that communicates with the Cassandra environment. 我还创建了一个与Cassandra环境进行通信的.net程序。

I was able to communicate with Cassandra when it was NOT running as a service with the following connection string: 当Cassandra不能作为服务使用以下连接字符串运行时,我就可以与它通信:

private void Connect()
    {
        cluster = Cluster.Builder().WithCredentials(username, password).AddContactPoint("192.168.30.104").Build();
        session = cluster.Connect("core_meter");
    }

But when I try to connect to Cassandra when its running as a service I get the following error: 但是,当我尝试连接到作为服务运行的Cassandra时,出现以下错误:

An unhandled exception of type 'Cassandra.NoHostAvailableException' occurred in Cassandra.dll Cassandra.dll中发生了'Cassandra.NoHostAvailableException'类型的未处理异常

Additional information: None of the hosts tried for query are available (tried: 192.168.30.104:9042) 附加信息:尝试查询的主机均不可用(已尝试:192.168.30.104:9042)

I am not sure if I have to change anything in my .yaml file before I can approach a service with username and password. 我不确定在我可以使用用户名和密码访问服务之前,是否需要更改.yaml文件中的任何内容。 here is the yaml file: https://www.dropbox.com/s/wbrexlarkjrvlrm/cassandra.yaml?dl=0 这是Yaml文件: https ://www.dropbox.com/s/wbrexlarkjrvlrm/cassandra.yaml ? dl =0

edit: When i communicate with the service WITHOUT a username and password I can communicate with the service (I can always communicate with the execution through command prompt) but when I use a username and password it does not work anymore. 编辑:当我不使用用户名和密码与服务通信时,我可以与服务进行通信(我可以始终通过命令提示符与执行通信),但是当我使用用户名和密码时,它将不再起作用。

It seems to me that your service and the single executable are using different yaml configuration files. 在我看来,您的服务和单个可执行文件正在使用不同的 Yaml配置文件。 Check your environment variables and your cassandra-env.sh files. 检查环境变量和cassandra-env.sh文件。 Also have a look at DataStax documentation . 也可以看一下DataStax文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM