我已经完成了一个三节点 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