2017-05-25 1 views
1

Ich versuche ansible-mongodb-cluster Skripte zu verwenden, um einen Mongodb-Cluster zu erstellen. Ich habe Hosts bearbeitet, um nur einen primären und einen Slave zu haben. Ich verwende molecule mit vagrant, um es zu testen.Zugriff von einer Instanz auf eine andere mithilfe von Molekül

das ist mein molecule.yml

ansible: 
    playbook: 01_create_cluster.yml 
    verbose: vvv 
inventory: hosts 
vagrant: 
    platforms: 
    - name: centos 
     box: centos/7 
    providers: 
    - name: virtualbox 
     type: virtualbox 
     options: 
     memory: 512 
     cpus: 2 
    instances: 
    - name: mongo1 
     ansible_groups: 
     - mongo_servers 
     - mongod_primary 
     - mongod_slaves 
     interfaces: 
     - network_name: private_network 
      type: static 
      ip: 192.168.80.1 
    - name: mongo2 
     ansible_groups: 
     - mongo_servers 
     - mongod_primary 
     - mongod_slaves 
     interfaces: 
     - network_name: private_network 
      type: static 
      ip: 192.168.80.2 

und das ist hosts Inventar ansible Datei:

[mongo_servers] 
mongo1 mongod_port=27017 
mongo2 mongod_port=27017 

[mongod_primary] 
mongo1 mongod_port=27017 

[mongod_slaves] 
mongo2 mongod_port=27017 

das Problem Borns, wenn nach Primär erstellt wird und die Replikation auf sie aktiviert, Slave versucht Verbinden mit dem primären:

"MongoDB shell version v3.4.4", 
     "connecting to: mongodb://mongo1:27017/", 
     "2017-05-25T15:38:51.399+0000 I NETWORK [thread1] getaddrinfo(\"mongo1\") failed: Name or service not known", 
     "2017-05-25T15:38:51.400+0000 E QUERY [thread1] Error: couldn't initialize connection to host mongo1, address is invalid :", 
     "[email protected]/mongo/shell/mongo.js:237:13", 
     "@(connect):1:6" 

es weiß nicht mongo1 Gastgeber.

Auch wenn ich in /etc/hosts die Beziehung hinzufügen

192.168.80.1 mongo1 

es sagt mir, dass Destination Net Unreachable

wie kann ich lösen und lassen Sie alle VM „sehen“, die anderen im Netzwerk?

EDIT

ping im Timeout und telnet

EDIT2

trace

[[email protected] ~]$ traceroute mongo1 
traceroute to mongo1 (192.168.80.1), 30 hops max, 60 byte packets 
1 gateway (10.0.2.2) 0.191 ms 0.111 ms 0.063 ms 
2 192.168.93.254 (192.168.93.254) 0.614 ms 0.716 ms 0.710 ms 
3 10.17.254.1 (10.17.254.1) 3.410 ms 3.366 ms 3.316 ms 
4 93-57-16-193.ip162.fastwebnet.it (93.57.16.193) 5.409 ms 5.384 ms 5.340 ms 
5 93-54-33-65.ip127.fastwebnet.it (93.54.33.65) 21.192 ms 21.135 ms 21.084 ms 
6 10.2.7.101 (10.2.7.101) 10.390 ms 2.447 ms 2.318 ms 
7 10.254.20.77 (10.254.20.77) 2.228 ms 10.254.20.73 (10.254.20.73) 2.171 ms 2.045 ms 
8 * * * 
9 * * * 
10 * * * 
11 * * * 
12 * * * 
13 * * * 
14 * * * 
15 * * * 
16 * * * 
17 * * * 
18 * * * 
19 * * * 
20 * * * 
21 * * * 
22 * * * 
23 * * * 
24 * * * 
25 * * * 
26 * * * 
27 * * * 
28 * * * 
29 * * * 
30 * * * 
[[email protected] ~]$ 
+0

können Sie 'telnet mongo1 27017' aus der sekundären bash? –

+0

okay. Darf ich wissen, warum Sie ein Replikat mit nur zwei Knoten erstellen? Gemäß MongoDB-Empfehlungen sollte ein Replikat mindestens 3 Mongod-Knoten einschließlich eines Arbiters haben. Dies ist jedoch möglicherweise nicht der Grund für dieses Problem. Können Sie den Befehl "traceroute" auf dem sekundären Server ausführen, um den primären Server zu erreichen? – harshavmb

+0

Wurde auf dem primären mongod-Host auch der '27017'-Port geöffnet? – harshavmb

Antwort

0

Dies ist auch geht ich zwei andere Konfiguration in die molecule.yml ausgewertete Hinzufügen :

interfaces: 
     - network_name: private_network 
      type: static 
      ip: 192.168.80.1 
      auto_config: true 
     options: 
     append_platform_to_hostname: no 


auto_config: true 

und

options: 
      append_platform_to_hostname: no 

jetzt, wenn ich die anderen vm ping, antworten sie erfolgreich!

Verwandte Themen