Aerospike Java客户端EOFException

时间:2020-06-11 15:09:12

标签: vagrant aerospike

我试图连接到我在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.
    }
}

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

更新

我现在正在使用IP地址172.28.128.4(通过ifconfig命令获得它)和端口3000连接到Aerospike。我现在收到套接字超时异常。

1 个答案:

答案 0 :(得分:1)

如果您在Mac上的vagrant上设置了一个节点,并且正在运行,则说明您是在Mac上的ide中运行应用程序-例如eclipse-vagrant上的locoalhost通常以172.28.128.3的价格暴露于mac。在无所事事的shell中运行ifconfig将确认这一点。如果您的应用程序在内部运行,则127.0.0.1应该可以工作,在每种情况下,您的应用程序都应指定端口3000。这就是aerospike服务器正在侦听的端口。 amc是一个Web服务器,它在端口3000上与aerospike进行通信,并且默认情况下在端口8081上提供仪表板。因此,它是通过网络浏览器通往航空尖峰的监视和管理网关。同样,在您的Aerospike配置中,建议您使用网状配置而不是多播,尽管对于单个节点没有关系-您不是在建立集群。如果您是新手,如果下载CE,则可以免费访问Aerospike学院的Aerospike入门课程。充分利用-几个小时的投资。否则,这是youtube上的一些介绍性视频。 (02-Intro to Aerospike03-handson