さくらVPSのCentos7にMongoDBをインストールしてユーザー認証までしたい。
解決したいこと
さくらVPSのCentos7にMongoDBをインストールしてユーザー認証までしたい。
発生している問題・エラー
ここのサイトを参考にしてMongoDB4.4をインストールしました。
$systemctl start mongod.service
$mongo
>use admin
>db.createUser(...)
という風にサイト通りにユーザーを作成しました。
$systemctl stop mongod.service
$vim /etc/mongod.conf
#以下を変更しました。
#security:
↓
security:
authorization: enabled
そしてMongoDBを再起動しようとしたところ。
$systemctl start mongod.service
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
自分で試したこと
公式のドキュメントを参考に進めようと思って①を始めてみれば
$mongod --port 27017 --dbpath /var/lib/mongodb
{"t":{"$date":"2021-03-03T18:00:53.439+09:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-03-03T18:00:53.445+09:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-03-03T18:00:53.445+09:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2021-03-03T18:00:53.446+09:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1365,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","host":"os3-360-13185.vs.sakura.ne.jp"}}
{"t":{"$date":"2021-03-03T18:00:53.446+09:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.4","gitVersion":"8db30a63db1a9d84bdcad0c83369623f708e0397","openSSLVersion":"OpenSSL 1.0.1e-fips 11 Feb 2013","modules":[],"allocator":"tcmalloc","environment":{"distmod":"rhel70","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2021-03-03T18:00:53.446+09:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"CentOS Linux release 7.8.2003 (Core)","version":"Kernel 3.10.0-1127.8.2.el7.x86_64"}}}
{"t":{"$date":"2021-03-03T18:00:53.446+09:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"port":27017},"storage":{"dbPath":"/var/lib/mongodb"}}}}
{"t":{"$date":"2021-03-03T18:00:53.447+09:00"},"s":"E", "c":"STORAGE", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Address already in use"}}}
{"t":{"$date":"2021-03-03T18:00:53.447+09:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2021-03-03T18:00:53.447+09:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"NETWORK", "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"CONTROL", "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"STORAGE", "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"STORAGE", "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"-", "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"FTDC", "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"CONTROL", "id":20565, "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2021-03-03T18:00:53.448+09:00"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}}
What?
この後にターミナルで普通に起動してみようとしてみました。
$mongo
MongoDB shell version v4.4.4
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
What?
因みにですがcentos7をインストールしてから何も設定していない状態なのでfirewallは停止させていますし、SELinuxは有効になっていません。
という風に何でユーザー認証を設定できないのか分かりません。
同じ状況です!となってる人がいるという事だけでもいいので何か一つ教えてください。
0