我正试图连接到我在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超时异常。
如果你在Mac上的vagrant上安装了一个节点,并且你在Mac上的一个id中运行你的应用程序--比如说eclipse--vagrant上的locoalhost在Mac上通常是172.28.128.3,在vagrant的shell中运行ifconfig可以确认这一点。amc是一个web服务器,默认在3000端口与aerospike对话,并在8081端口为dashboard提供服务,所以它是一个通过web浏览器连接到aerospike的监控和管理网关。 如果你是新用户,如果你下载了CE,你可以免费获得Aerospike学院的Aerospike入门课程。利用这个优势 - 几个小时的投资。否则这里有一些介绍视频在YouTube上。( 02-介绍Aerospike 和 03-handon )