Mongo-Connector无法连接Elasticsearch的MongoDB副本集

时间:2018-05-25 11:11:34

标签: mongodb docker elasticsearch

昨天我根据此处显示的说明使用Docker-compose创建了副本集:

https://www.youtube.com/watch?v=mlw7vWISaF4

容器全部创建,我也设法为数据播种,所以使用Robo3T我可以查看我的收藏。我这样做是因为我需要使用mongo-connector将MongoDB连接到Elasticsearch。

这是docker-compose.yml文件:

version: '3'
services:
  mongo-rs0-1:
    image: "mongo-start"
    build: ./mongo-rs0-1
    ports:
      - "27017:27017"
    volumes:
      - ./mongo-rs0-1/data:/data/db
    depends_on:
      - "mongo-rs0-2"
      - "mongo-rs0-3"

  mongo-rs0-2:
    image: "mongo:3.6.4"
    command: --replSet rs0 --smallfiles --oplogSize 128
    ports:
      - "27018:27017"
    volumes:
      - ./mongo-rs0-2/data:/data/db

  mongo-rs0-3:
    image: "mongo:3.6.4"
    command: --replSet rs0 --smallfiles --oplogSize 128
    ports:
      - "27019:27017"
    volumes:
      - ./mongo-rs0-3/data:/data/db

  setup-rs:
    image: "setup-rs"
    build: ./setup
    depends_on:
      - "mongo-rs0-1"

  mongo-db-seeder:
    build:
      context: ./mongo-db-seed
      dockerfile: ./Dockerfile.dev
    volumes:
      - ./mongo-db-seed/seeddata:/opt/seeddata
    depends_on:
      - "web-app"
    command: "./import_mongo.sh"

  adminmongo:
    image: "mrvautin/adminmongo"
    ports:
      - "1234:1234"

  #Test Application
  web-app:
    image: docker-node-express-mongoreplicaset-app
    build: ./web-site
    ports:
      - "3000:3000"
    volumes:
      - ./web-site:/usr/src/app
      - /usr/src/app/node_modules
    depends_on:
      - "setup-rs"

这是配置该副本集的replica.js;

rsconf = {
  _id : "rs0",
  members: [
    { _id : 0, host : "mongo-rs0-1:27017" },
    { _id : 1, host : "mongo-rs0-2:27017" },
    { _id : 2, host : "mongo-rs0-3:27017" }
  ]
}

rs.initiate(rsconf);

rs.conf();

我安装了Elasticsearch并在端口9200上运行,等待构建索引。

这是我的主机文件(etc / hosts)我在os x上运行。

##  
# Host Database  
#  
# localhost is used to configure the loopback interface  
# when the system is booting.  Do not change this entry.  
##  
127.0.0.1   localhost  
255.255.255.255 broadcasthost  
::1             localhost

但是,当我运行此命令时(容器和Elasticsearch都在运行)

  

mongo-connector -m localhost:27017 -t localhost:9200 -d elastic2_doc_manager

我收到此错误:

  

ServerSelectionTimeoutError:mongo-rs0-3:27017:[Errno 8] nodename nor   提供或未知的servname,mongo-rs0-1:27017:[Errno 8] nodename   提供或不知道的服务名称,mongo-rs0-2:27017:[Errno 8]   提供的是nodename或servname,或者不知道

今天早上我有一个很好的搜索,我找不到任何指向这个问题的东西。副本集似乎运行正常,Elasticsearch正在运行,但缺少某些东西。

0 个答案:

没有答案