代码之家  ›  专栏  ›  技术社区  ›  Sandeepan Nath

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

  •  1
  • Sandeepan Nath  · 技术社区  · 7 年前

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

    我有一个Java Spring启动应用程序在Windows上运行,它能够与主机127.0.0.1和端口3000的SalePikes 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;
        }
    
    }
    

    问题

    我的系统上运行着python for windows。

    我尝试运行与中给出的完全相同的示例 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 回复  |  直到 6 年前
        1
  •  2
  •   Ronen Botzer    6 年前

    Windows当前不支持Python客户端。您可以尝试使用 C client 对于Windows。请用叉子叉 aerospike/aerospike-client-python 如果你能让它发挥作用的话,就要为这些变化做出贡献。