这是我第一次使用 compose.io 作为我的 mongodb 主机。
我试图用 Laravel 配置 compose.io mongodb 但最终出现了这个错误:
ConnectionTimeoutException in Collection.php line 432:
No suitable servers found (`serverSelectionTryOnce` set)
我正在使用https://github.com/jenssegers/laravel-mongodb包向 Laravel 添加 mongodb 支持。
我的 mongodb 配置:
'mongodb' => [
'driver' => 'mongodb',
'host' => ['aws-us-east-1-portal.25.dblayer.com:20020/admin', 'aws-us-east-1-portal.26.dblayer.com:20020/admin'],
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => [
'ssl' => true,
'database' => 'admin', // sets the authentication database required by mongo 3
'replicaSet' => 'set-5939226a8aab5300121d0ef2',
'readPreference' => 'primary',
],
'driver_options' => [
'context' => stream_context_create( [
'ssl' => [
'local_cert' => base_path('mongo.pem'),
'cafile' => base_path('mongo.pem'),
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
'verify_expiry' => false,
'allow_invalid_certificates' => true
]
])
]
]
我也不确定MONGO_REPLICA_SET的价值是什么
有人经历过类似的事情吗?
谢谢