2016-08-29 5 views
0

私はEC2上に3つのインスタンスを持っています。それぞれ弾性IPを持ち、それぞれがmongoバージョン3.2を実行しています。すべてがタイプ名で設定されたレプリカ内にあります。 mongod.confのbind_ip設定はIP 0.0.0.0で設定されています。mongoレプリカセットとのPHP接続エラー

私はphpでmongoに接続しようとしています。私は既に内線番号mongodblibraryをインストールしています。

同一ポート上にあるそのすべて、プライマリIP:52.67.34.1

マイ接続:

$this->manager = new MongoDB\Driver\Manager(
      "mongodb://52.67.34.1,52.67.77.2,52.67.30.3/?replicaSet=homologation"); 

しかし、クエリを実行または挿入すると、次のエラーを与える:

Fatal error: Uncaught exception 'MongoDB \ Driver \ Exception \ ConnectionTimeoutException' with message 'No suitable servers found (serverselectiontryonce set): [connection error calling ismaster on '52.67.34.1:27017'] [connection error calling ismaster on '52.67.77.2:27017'] [connection error calling ismaster on '52.67.30.3:27017'] [Failed connecting to '172.31.1.1:27017': Connection timed out] [Failed connecting to '172.31.2.2:27017': Connection timed out] [Failed connecting to '172.31.3.3:27017': Connection timed out]

このエラーを解決するにはどうすればよいですか? mongoに接続しますか?

+1

接続性のあるW/Wアプリサーバーとmongodbサーバーをチェックしましたか? – Astro

+1

セキュリティグループでこのポート27017を開いていますか – error2007s

+0

@Astro 1つのIPが動作しますが、複数のポートが動作しません – pedrosalpr

答えて

1

PHPでマシンIPで設定されたレプリカに接続する際に問題があり、マシンホストを使用してこれを解決しました。

あなたのサーバーホストがあなたのDNS(パブリックまたはプライベート)にない場合は、各レプリカメンバーを/ etc/hostsファイルに宣言することをお勧めします。

それは私のために働いて、それが助けてくれることを願っています。

関連する問題