无法通过网络连接到VoltDB

时间:2019-05-30 10:20:37

标签: go voltdb

我开始使用VoltDB。在局域网中的服务器上运行VoltDB社区。服务器启动后报告服务器初始化完成

Build: 9.0 voltdb-9.0-0-g6aae38a-local Community Edition
Loaded node-specific settings from voltdbroot/config/path.properties
Connecting to VoltDB cluster as the leader...
Host id of this node is: 0
Restarting the database cluster from the command logs
WARN: User authentication is not enabled. The database is accessible and could be modified or shut down by anyone on the network.
Partition placement has been restored.
Initializing the database. This may take a moment...
WARN: This is not a highly available cluster. K-Safety is set to 0.
WARN: Durability is turned off. Command logging is off.
Restoring from path: /home/samtech/voltdb-db/voltdbroot/snapshots with nonce: SHUTDOWN_20190530T151422_my4epdwk9mv4
Duplicate rows will be output to: /home/samtech/voltdb-db/voltdbroot/snapshots nonce: SHUTDOWN_20190530T151422_my4epdwk9mv4
Finished restore of /home/samtech/voltdb-db/voltdbroot/snapshots with nonce: SHUTDOWN_20190530T151422_my4epdwk9mv4 in 0.09 seconds
Server Operational State is: NORMAL
Server completed initialization.

我可以通过以下方式本地连接到服务器

sqlcmd --servers=192.168.1.4

或通过

sqlcmd

但是当我尝试在go应用程序中使用voltdb-client-go连接时,它显示以下错误

No valid connections failed to connect to server 192.168.1.4

这是我正在尝试的代码

package main

import (
    "database/sql"
    "log"

    _ "github.com/VoltDB/voltdb-client-go/voltdbclient"
)

func main() {
    InitVDb()
}

func InitVDb() {
    VDb, err := sql.Open("voltdb", "192.168.1.4")
    if err != nil {
        log.Fatalf("Voltdb Connection error %v\n", err)
    }

    err = VDb.Ping()
    if err != nil {
        VDb.Close()
        log.Fatalf("Ping failed: %v\n", err)
    }

    log.Println("Connection suceeded...")
}

我也尝试使用“ 192.168.1.4:21212”,但收到相同的错误。 代码有什么问题?

数据库计算机上没有防火墙(ipconfig)。

1 个答案:

答案 0 :(得分:0)

在hello_word中,它使用的是localhost:21212作为连接字符串,所以我只是跟随并放置了192.168.1.4:21212

但是应该是

voltdb://192.168.1.4:21212

它修复了连接问题。