【发布时间】:2016-11-27 17:57:59
【问题描述】:
我的主题行可能会说这是一个重复的问题,但事实并非如此。我已经尝试了所有可能的方法来搜索这个问题,但未能解决我的问题。
我的 PC 上运行的是 Windows 8.1。我已通过在其上使用 Hyper-V 将 Ubuntu 16.04 版本安装为 VM。我已经在我的 Ubuntu 系统上安装了 Cassandra 3.7。
Cassandra 能够从本地主机(即 Ubuntu 系统)进行连接。我创建了键空间和所有内容,但是当我尝试从我的 golang 代码连接 Casandra 时,如下所示,我收到了错误。
主包
import (
"fmt"
"log"
"github.com/gocql/gocql"
)
func main() {
// connect to the cluster
cluster := gocql.NewCluster("192.168.137.217") //Put comma separated IPs in case of multiple cluster
cluster.Keyspace = "broker_keyspace"
cluster.Consistency = gocql.Quorum
session, _ := cluster.CreateSession()
defer session.Close()
}
192.168.137.217 是我的虚拟机的 IP 地址。我得到的错误是不允许连接 9042 端口。我试图从我的 Windows 8.1 系统(这是运行 Cassandra 的 VM 的主机)运行此代码。我确实尝试过 telnet,发现 9042 端口未打开主机连接。
我开始使用 cassandra.yaml 配置文件,但现在它甚至无法在 Ubuntu 系统上运行。我无法使用
获取节点状态nodetool status
我在 cassandra.yaml 文件中的常用配置如下。
rpc_address: localhost
listen_address: localhost
我还取消了 /etc/cassandra/cassandra-env.sh 文件中以下行的注释,并将公共名称更新为 127.0.0.1。
# add this if you're having trouble connecting:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"
我使用 service cassandra restart 重新启动了 cassandra,但是当我尝试 nodetool status 时出现以下错误。
nodetool:无法连接到“127.0.0.1:7199” - ConnectException:“连接被拒绝”。
抱歉这个问题太长了,但请帮助我真的厌倦了这个问题,从过去 6 到 7 个小时都非常努力。
谢谢..
【问题讨论】: