【发布时间】:2021-11-22 14:36:20
【问题描述】:
我已经完成了一个三节点 Cassandra 集群的设置。这个在aws上,服务器端口是开放的。三台服务器相互连接良好,工作完美。 我已经设置了
authenticator: AllowAllAuthenticator
在我的cassandra.yaml 文件中
我想用go cql建立连接,这里是连接代码
cluster := gocql.NewCluster("x.xxx.xxx.xxx")
cluster.Keyspace = "keyspace_name"
cluster.Consistency = gocql.Quorum
cluster.ProtoVersion = 4
cluster.ConnectTimeout = time.Second * 10
session, err := cluster.CreateSession()
if err != nil {
fmt.Println(err)
}
但是 go cql 将这条消息发回给我。
2020/09/26 09:53:44 gocql: unable to dial control conn x.xxx.xxx: dial tcp 127.0.0.1:9042: connectex: No connections could be made because the target machine actively refused them.
2020/09/26 09:53:44 gocql: unable to create session: control: unable to connect to initial hosts: dial tcp x.xxx.xxx.xxx:9042: connectex: No connections could be made because the target machine actively refused them.
panic: runtime error: invalid memory address or nil pointer dereference
【问题讨论】:
-
为什么要连接到本地主机?这是故意的吗?
-
错误提示你正在尝试连接到 localhost(127.0.0.1),你能确定你使用的是正确的主机名吗?
-
@danielfarrell no 这是一个错误,它与服务器连接良好,或者希望在本地使用 golang 并在 db 上使用 cassandra,这是网站开发的时间。跨度>
标签: go amazon-ec2 cassandra gocql