2016-09-21 4 views
0

J'ai parcouru la documentation officielle pour installer mongodb dans l'environnement Linux en amazon.Connexion à distance avec mongodb

après l'installation je l'ai fait

[[email protected] etc]# service mongod restart 
dirname: missing operand 
Try 'dirname --help' for more information. 
Stopping mongod:           [ OK ] 
Starting mongod:           [FAILED] 

le début est échoué, mais quand je n'écrire mongod est dit

[[email protected] etc]# mongod 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] MongoDB starting : pid=16633 port=27017 dbpath=/data/db 64-bit host=ip-172-31-20-59 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] db version v3.2.9 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] allocator: tcmalloc 
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] modules: none 
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] build environment: 
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten]  distmod: amazon 
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten]  distarch: x86_64 
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten]  target_arch: x86_64 
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] options: {} 
2016-09-21T05:23:57.726+0000 I -  [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'. 
2016-09-21T05:23:57.735+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal 
2016-09-21T05:23:57.735+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed 
2016-09-21T05:23:57.899+0000 I JOURNAL [durability] Durability thread started 
2016-09-21T05:23:57.899+0000 I JOURNAL [journal writer] Journal writer thread started 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] **  We suggest setting it to 'never' 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
2016-09-21T05:23:57.907+0000 I FTDC  [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' 
2016-09-21T05:23:57.907+0000 I NETWORK [initandlisten] waiting for connections on port 27017 
2016-09-21T05:23:57.907+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker 

puis sur une autre console que j'ai commencé mongo

[[email protected] etc]# mongo 
MongoDB shell version: 3.2.9 
connecting to: test 
Server has startup warnings: 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] **  We suggest setting it to 'never' 
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] 
> 

et dans la console de mongod il a accepté la connnection

2016-09-21T05:25:09.684+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:49068 #1 (1 connection now open) 

Maintenant, j'ai deux ou trois questions,

1.i ne suis pas en mesure de comprendre est mon mongo fonctionne ou non? (Beacause à partir mongod toujours échoué, mais sur la saisie que mongod travaille)

2.i ne peut pas se connecter au serveur mongo à distance à travers mon robomongo il dit « ne peut pas se connecter à MongoDB »

mon fichier mongo.config ->

# mongod.conf 

    # for documentation of all options, see: 
    # http://docs.mongodb.org/manual/reference/configuration-options/ 

    # where to write logging data. 
    systemLog: 
     destination: file 
     logAppend: true 
     path: /var/log/mongodb/mongod.log 

    # Where and how to store data. 
    storage: 
     dbPath: /var/lib/mongo 
     journal: 
     enabled: true 
    # engine: 
    # mmapv1: 
    # wiredTiger: 

    # how the process runs 
    processManagement: 
     fork: true # fork and run in background 
    #pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile 

    # network interfaces 
    net: 
     port: 27017 
     bindIp: 0.0.0.0,10.0.0.1,127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. 

Répondre

0

Votre réglage bindIp est un peu bizarre. Pourquoi la liste séparée par des virgules? Utilisez simplement 0.0.0.0. Ensuite, ouvrez le port 27017 dans votre groupe de sécurité et vous pourrez vous connecter.

+0

Merci j'ai fait toutes les choses mais j'ai oublié d'ajouter dans le groupe de sécurité votre réponse me rappelle – adasdasd

0

Pour répondre à vos questions:

  1. Si vous pouvez vous connecter en utilisant la mongo shell, le serveur est en cours d'exécution. Sinon, vous verrez une erreur comme Connection refused et exception: connect failed

  2. Par défaut, le pare-feu AWS est très restrictif. Veuillez vérifier si vous autorisez la connexion entrante au port 27017 depuis n'importe quel hôte. Il y aura un avertissement disant que vous ouvrez le port à tout le monde, mais il est nécessaire d'autoriser les connexions à la base de données.