我通过 Vagrant 在 Windows 系统上运行的虚拟盒子上运行 Aerospike。
我有一个在 Windows 上运行的 Java Spring Boot 应用程序,它能够与主机 127.0.0.1 和端口 3000 上的 aerospike 数据库通信。
这是我的属性文件 -
prepaid.aerospike.namespace=hello
prepaid.aerospike.hosts.count=1
prepaid.aerospike.hostname1=127.0.0.1
prepaid.aerospike.port1=3000
prepaid.aerospike.sequence.namespace=hello1
这是 AerospikeConfiguration 文件 -
package com.citruspay.common.prepaid.aerospike;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.aerospike.client.AerospikeException;
import com.aerospike.client.Host;
import com.spikeify.Spikeify;
@Configuration
public class AerospikeConfiguration {
@Value("${prepaid.aerospike.namespace}")
private String namespace;
@Value("${prepaid.aerospike.hosts.count}")
private String aerospikeHostCount;
@Value("${prepaid.um.aerospike.cache.namespace}")
private String aerospikeUMCacheNamespace;
@Value("${prepaid.aerospike.history.namespace}")
private String aerospikeHistoryNamespace;
@Autowired
@Qualifier("configProperties")
Properties config;
public Host[] aerospikeHosts() {
Integer hostsCount = Integer.parseInt(aerospikeHostCount);
Host[] hosts = new Host[hostsCount];
for (int i = 1; i <= hostsCount; i++) {
hosts[i - 1] = new Host(
config.getProperty("prepaid.aerospike.hostname" + i),
Integer.parseInt(
config.getProperty("prepaid.aerospike.port" + i)));
}
return hosts;
}
@Bean
public Spikeify spikeify() throws AerospikeException {
SpikeifyService.globalConfig(namespace, aerospikeHosts());
return SpikeifyService.sfy();
}
public String getNamespace() {
return namespace;
}
}
问题
我的系统上运行着用于 Windows 的 python。
我尝试运行 https://www.aerospike.com/docs/client/python 中给出的完全相同的示例
通过 python aerospike.py 运行 python 文件,我得到 -
failed to connect to the cluster with [('127.0.0.1', 3000)]
更新
来自 aerospike.conf 的网络部分 -
network {
service {
address any
port 3000
}
heartbeat {
mode mesh
port 3002 # Heartbeat port for this node.
# address 127.0.0.1
# List one or more other nodes, one ip-address & port per line:
# # mesh-seed-address-port 10.10.10.11 3002
# # mesh-seed-address-port 10.10.10.12 3002
# # mesh-seed-address-port 10.10.10.13 3002
# # mesh-seed-address-port 10.10.10.14 3002
#
# interval 250
# timeout 10
#
}
fabric {
port 3001
}
info {
port 3003
}
}
最佳答案
Windows 目前不支持 Python 客户端。您可以尝试使用 C client 来构建它对于 Windows。请 fork aerospike/aerospike-client-python如果您让它发挥作用,并贡献更改。
关于java - 无法通过 python 连接到 aersopike db - 无法使用 [ ('127.0.0.1' , 3000)] 连接到集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51327636/