英文:
Issue connecting to Click to Deploy Cassandra instance
问题
我正在尝试使用Golang的gocql
驱动程序从远程机器将数据写入Click To Deploy Cassandra集群,但连接失败。
这是我的cassandra.yaml配置:
native_transport: true
listen_address: <public ip>
broadcast_address: <public ip>
rpc_address: 0.0.0.0
native_transport_port: 9042
这是我使用的Golang代码,我正在尝试远程连接:
import (
"fmt"
"github.com/gocql/gocql"
)
func main() {
// 连接到集群
cluster := gocql.NewCluster(<cassandra节点的公共IP>)
cluster.Keyspace = "demo"
session, _ := cluster.CreateSession()
defer session.Close()
if err := session.Query("INSERT INTO users (lastname, firstname) VALUES ('Karthic', 'Rao')").Exec(); err != nil {
fmt.Printf("写入错误: %s", err.Error())
}
}
这是错误信息:
connect: failed to connect to "<public ip>:9042": dial tcp <public ip>:9042: i/o timeout
有关如何修复此问题以在Cassandra节点上进行I/O的任何想法吗?
英文:
I'm trying to write data into Click To Deploy cassandra cluster using Golang gocql
driver from a remote machine , But it fails to connect .
Here is my cassandra.yaml configuration ,
native_transport: true
listen_address: <public ip>
broadcast_address: <public ip>
rpc_address: 0.0.0.0
native_transport_port : 9042
And here is the Golang Code using which I'm remotely trying to connect
import (
"fmt"
"github.com/gocql/gocql"
)
func main() {
// connect to the cluster
cluster := gocql.NewCluster(<public ip of cassandra nodes>)
cluster.Keyspace = "demo"
session, _ := cluster.CreateSession()
defer session.Close()
if err := session.Query("INSERT INTO users (lastname, firstname) VALUES ('Karthic', 'Rao')").Exec(); err != nil {
fmt.Printf("ERror writing : ", err.Error())
}
}
Here is the error ,
connect: failed to connect to "<public ip>:9042": dial tcp <public ip> :9042: i/o timeout
Any idea on how to fix this to make i/o on the cassandra nodes ?
答案1
得分: 1
你只需要在你的GCE防火墙上打开CQL本机传输端口(tcp:9042),就可以远程连接到你的集群节点。你可以使用"telnet <公共IP> 9042"命令测试端口是否打开并监听。同时确保你的远程网络/防火墙没有阻止对端口9042的出站流量。
如果防火墙配置正确,你可以telnet到端口,但仍然收到上述错误信息,则说明你的gocql设置有问题。
英文:
You just need to open CQL native transport port (tcp:9042)
on your GCE firewall to be able to connect to your cluster nodes remotely. You can use telnet <public ip> 9042
command to test if the port is open and listening. Also make sure the outgoing traffics to the port 9042
is not blocked on your remote network/firewall.
If the firewall is configured properly and you could telnet to the port but still receiving the mentioned error, then something is wrong with your gocql setup.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论