无法通过python连接到aersopike db-无法通过[('127.0.0.1',3000)]连接到集群

时间:2018-07-13 14:39:24

标签: java python vagrant aerospike

我在Windows系统上运行的虚拟盒子上通过Vagrant运行了Aerospike。

我有一个运行在Windows上的Java Spring Boot应用程序,它能够与主机127.0.0.1和端口3000上的aerospike db通信。

这是我的属性文件-

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
        }
}

1 个答案:

答案 0 :(得分:2)

Windows当前不支持Python客户端。您可以尝试使用C client(适用于Windows)来构建它。如果可以使用,请分叉aerospike/aerospike-client-python并贡献所做的更改。