vagrant - Aerospike Java 客户端 EOFException
问题描述
我正在尝试连接到我在 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。我现在收到套接字超时异常。
解决方案
如果您在 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-介绍 Aerospike和03-handson )
推荐阅读
- python - 框的Tkinter对齐和选择问题
- javascript - 未捕获的 ReferenceError:未定义 href
- python - 将 JSON 转换为 CSV 文件
- reactjs - 学习者问题:如何将消息栏 (Fabric UI) 中的按钮与功能相关联?
- flutter - Flutter authstate 干扰了我的底栏(firebase)
- java - 如何制作一个 switch 语句以在 Java 中不断重复
- rxjs - RXJS 组合 x 个 observables,其中 n 个是可选的
- scala - Akka 流:为什么 Sink.head 用alsoTo 广播终止流?
- python - Sum & count of a column based on the content of the last value in each group excluding the last row
- subdomain - 如何在 freehosting.com 中添加 TXT?