2016-09-21 11 views
0

私はamazonのlinux環境にmongodbをインストールするための公式文書を読みました。mongodbとのリモート接続

は、インストール後に、私はスタートに失敗した

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

をしましたが、私は唯一のmongodを書くとき言う

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

あり、その後、別のコンソール上で、私は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] 
> 

とを開始しましたmongodコンソールで接続を受け入れた

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

今私は、質問のカップルを持っている

1.Iが理解できないのですが、私のmongoが動作するかしないのですか? (常に失敗のmongodを起動するだけのmongodを入力するに取り組んでいるbeacause)

2.Iは私robomongoを介してリモートのmongoサーバーに接続できない、それは

私mongo.configファイル「のMongoDBに接続できません」と言います - >

# 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. 

答えて

0

bindIpの設定はちょっと変わっています。コンマ区切りのリストが表示されるのはなぜですか?ちょうど0.0.0.0を使用してください。

その後、セキュリティグループにポート27017を開いて接続することができます。

+0

ありがとう私はすべてのことをしたが、セキュリティグループに追加するのを忘れてしまったあなたの答えは私に思い出させる – adasdasd

0

は、あなたの質問に答えるために:

  1. をおを使用して接続できる場合シェルを実行すると、サーバーが実行されています。そうでないと、Connection refusedexception: connect failedのようなエラーが表示されます。

  2. デフォルトでは、AWSファイアウォールは非常に制限されています。任意のホストからのポート27017への着信を許可するかどうかを確認してください。すべての人にポートを開いているという警告が表示されますが、データベースへの接続を許可する必要があります。

関連する問題