【问题标题】:Aerospike Java client EOFExceptionAerospike Java 客户端 EOFException
【发布时间】:2020-10-01 06:45:09
【问题描述】:

我正在尝试连接到我在 MacOSX 上使用 Vagrant 设置的 Aerospike 单节点。我的 AMC 在 localhost:2200 上运行。我无法成功连接。

import com.aerospike.client.AerospikeClient;

public class AerospikeDriver {
    public static void main(String[] args) {
        AerospikeClient client = new AerospikeClient("127.0.0.1", 2200);
        client.close();
    }
}

我在第一行本身就收到了这个错误。我也尝试将端口更改为 3000。同样的错误。有时,我也会得到 SocketException。

Exception in thread "main" com.aerospike.client.AerospikeException$Connection: Error Code -8: Failed to connect to host(s): 
127.0.0.1 2200 Error Code -1: java.io.EOFException

    at com.aerospike.client.cluster.Cluster.seedNodes(Cluster.java:532)
    at com.aerospike.client.cluster.Cluster.tend(Cluster.java:425)
    at com.aerospike.client.cluster.Cluster.waitTillStabilized(Cluster.java:380)
    at com.aerospike.client.cluster.Cluster.initTendThread(Cluster.java:286)
    at com.aerospike.client.cluster.Cluster.<init>(Cluster.java:243)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:234)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:175)
    at AerospikeDriver.main(AerospikeDriver.java:5)

我对 aerospike 客户端的 maven 依赖是这样的:

<dependency>
    <groupId>com.aerospike</groupId>
    <artifactId>aerospike-client</artifactId>
    <version>4.1.11</version>
</dependency>

这是我的 aerospike conf:

# Aerospike database configuration file.

# This stanza must come first.
service {
    user root
    group root
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    pidfile /var/run/aerospike/asd.pid
#   service-threads 4
#   transaction-queues 4
#   transaction-threads-per-queue 4
    proto-fd-max 15000
        node-id-interface eth1
}

logging {
    # Log file must be an absolute path.
    file /var/log/aerospike/aerospike.log {
        context any info 
    }
        file /var/log/aerospike/udf.log {
                context udf info
                context aggr info
        }
}

network {
    service {
        address eth1
        port 3000
#                access-address <Published IP>
#                access-address <NAT IP> 
    }

    heartbeat {
        mode multicast
                multicast-group 239.1.99.222
        address eth1 
        port 9918
                protocol v3

        # To use unicast-mesh heartbeats, comment out the 3 lines above and
        # use the following 4 lines instead.
#       mode mesh
#       port 3002
#       mesh-address 10.1.1.1
#       mesh-port 3002

        interval 150
        timeout 10
    }

    fabric {
        port 3001
                address eth1
    }


    info {
        port 3003
    }
}

#namespace test {
#   replication-factor 2
#   memory-size 4G
#   default-ttl 30d # 30 days, use 0 to never expire/evict.
#
#   storage-engine memory
#}

namespace test {
    replication-factor 2
    memory-size 2G
    default-ttl 5d # 5 days, use 0 to never expire/evict.

    # To use file storage backing, comment out the line above and use the
    # following lines instead.
    storage-engine device {
        file /opt/aerospike/data/test.dat
        filesize 5G
        data-in-memory true # Store data in memory in addition to file.
    }
}

我做错了什么?在这里需要一些帮助。我对 aerospike 很陌生。我尝试到处搜索,但找不到任何东西。

更新

我现在使用 IP 地址 172.28.128.4(从 ifconfig 命令获取)和端口 3000 连接到 aerospike。我现在收到 Socket Timeout Exception。

【问题讨论】:

    标签: vagrant aerospike


    【解决方案1】:

    如果您在 Mac 上的 vagrant 上设置单个节点,并且您在 mac 上的 ide 中运行应用程序 - 比如说 eclipse - vagrant 上的 locaalhost 通常以 172.28.128.3 暴露给 mac。在您的 vagrant shell 中运行 ifconfig 将确认这一点。如果您的应用程序在 vagrant 内部运行,那么 127.0.0.1 应该可以工作,在每种情况下,您的应用程序都应该指定端口 3000。这就是 aerospike 服务器正在监听的地方。 amc 是一个网络服务器,它在端口 3000 上与 aerospike 通信,默认情况下在端口 8081 上为仪表板提供服务。因此,它是通过 Web 浏览器访问 aerospike 的监控和管理网关。此外,在您的 aerospike 配置中,建议您使用网格配置而不是多播,尽管对于单个节点来说这并不重要——您不是在创建集群。如果您是新手,如果您下载 CE,您可以免费访问 Aerospike 学院的 Aerospike 介绍课程。利用这一点 - 几个小时的投资。否则,这里有一些 youtube 上的介绍视频。 (02-Intro to Aerospike03-handson

    【讨论】:

    • 感谢您的回复。我尝试了上述所有选项。 IP 地址为 172.28.128.4。我将端口设为 3000。我收到了 Socket Timeout Exception。
    • 1 - 你的应用程序在你的 mac 上,而 aerospike 在 vagrant 上运行? 2 - 你试过写唱片吗? -什么aerospike版本?我认为您的服务器没有启动。在命名空间配置中,在 default-ttl 5d 条目之后,在下一行中,添加:nsup-period 30 并重新启动服务器。
    • 1- 是的。应用程序在 mac 上,aerospike 在 vagrant 2 上 - 我使用 AQL 成功写了一条记录。我的 aerospike 版本 4.8.0.5。我的应用程序中的 aerospike 客户端版本是 4.4.11。 3-服务器状态正在运行。我也尝试了您提出的解决方案。它对我不起作用。
    • nsup-period 要求适用于 4.9+ 版——这就解释了这一点。我想 AQL 在 vagrant 内部运行 - 所以服务器已启动 - 你只是无法从 mac 连接到它。我有和你一样的配置,我可以连接。当您使用 vagrant up 启动 vagrant - 检查端口 3000 的端口转发:我有:默认值:转发端口... 默认值:3000(访客)=> 3000(主机)(适配器 1)默认值:8081(访客)=> 8081 (主机)(适配器 1)默认值:22(访客)=> 2222(主机)(适配器 1)
    • ==> 默认值:转发端口... 默认值:3000(访客)=> 3000(主机)(适配器 1)默认值:8081(访客)=> 2200(主机)(适配器 1)默认值:22(访客)=> 2222(主机)(适配器 1)
    猜你喜欢
    • 2017-03-20
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    • 1970-01-01
    相关资源
    最近更新 更多