teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

試した結果を追加

2020/06/16 07:51

投稿

takaoS
takaoS

スコア9

title CHANGED
File without changes
body CHANGED
@@ -87,8 +87,49 @@
87
87
  6月 16 06:36:39 ip-hogehoge..ap-northeast-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
88
88
  ```
89
89
 
90
- となるのではないかと推測しているのですが、調べても解決方法が見当せん
90
+ となるのではないかと推測し調べてところ、以下のサイトを見つけした
91
+ https://stackoverflow.com/questions/43589290/mongo-service-start-or-restart-always-fail/48122382
91
92
 
93
+ これの通りに、以下のように編集し、
94
+
95
+ ```
96
+ // 編集後
97
+
98
+ # network interfaces
99
+ net:
100
+ port: 27017
101
+ bindIp: [127.0.0.1,0.0.0.0,::] # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
102
+
103
+ ```
104
+
105
+ 再度、再起動をかけてみましたが、結局できませんでした。
106
+ そして、以下のようにエラーが変わりました(status=2からstatus=14)。
107
+
108
+ ```
109
+ [ec2-user@ip-hogehoge etc]$ sudo systemctl status mongod.service
110
+ ● mongod.service - MongoDB Database Server
111
+ Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
112
+ Active: failed (Result: exit-code) since 火 2020-06-16 07:16:53 UTC; 14s ago
113
+ Docs: https://docs.mongodb.org/manual
114
+ Process: 6894 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
115
+ Process: 6891 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
116
+ Process: 6888 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
117
+ Process: 6887 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
118
+ Main PID: 6559 (code=exited, status=0/SUCCESS)
119
+
120
+ 6月 16 07:16:45 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: Starting MongoDB Database Server...
121
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal mongod[6894]: src/third_party/gperftools-2.7/dist/src/central_freelist.cc:...8192
122
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal mongod[6894]: 2020-06-16T07:16:53.696+0000 F - [main] out of memory.
123
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=14
124
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
125
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: Unit mongod.service entered failed state.
126
+ 6月 16 07:16:53 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: mongod.service failed.
127
+ Hint: Some lines were ellipsized, use -l to show in full.
128
+ ```
129
+
130
+
131
+ 現在も調査中ですが、解決方法が分かりません。
132
+
92
133
  以上、ご教授いただけると助かります。
93
134
 
94
135
 

1

説明不足の部分を補足

2020/06/16 07:51

投稿

takaoS
takaoS

スコア9

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Amazon Linux 2のEC2にMongoDBをインストールし、ローカルマシンにインストールしたMongoDB CompassからアクセスしてCRUD操作がしたいです。
4
4
 
5
+ そのために、/etc/mongod.confを編集して、localhost以外からのアクセスを許可したいです。
5
6
 
6
7
 
7
8
  MongoDBをインストールするEC2は、デフォルトで用意されているVPC領域のパブリックサブネット上に構築しました。
@@ -18,27 +19,100 @@
18
19
 
19
20
  ### 発生している問題・エラーメッセージ
20
21
 
21
- https://stackoverflow.com/questions/49285525/connect-to-ec2-via-mongodb-compass-community
22
- 上記URLによると、/etc/mongodb.confを編集して、localhost以外からのアクセスを許可する必要があるらしいです。
23
22
 
24
- そこで、EC2にログインし、以下のように/etc/mongodb.confを編集しました
25
23
 
24
+ ローカルからEC2のMongoDBへのアクセスを許可するために、EC2にログインし、以下のように/etc/mongod.confを編集しました。
25
+
26
26
  ```
27
27
  // 編集前
28
28
 
29
+ # network interfaces
30
+ net:
31
+ port: 27017
32
+ bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
33
+ ```
29
34
 
35
+
30
36
  ```
37
+ // 編集後
31
38
 
39
+ # network interfaces
40
+ net:
32
- ### 該当のソースコード
41
+ port: 27017
42
+ bindIp: 0.0.0.0,:: # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
33
43
 
34
- ```ここに言語名を入力
35
- ソースコード
36
44
  ```
37
45
 
46
+ その後、設定を反映させるためにrestartをしようとすると、以下のようなエラーが出て実行されません。
47
+
48
+ ```
49
+ [ec2-user@ip-hogehoge etc]$ sudo service mongod restart
50
+ Redirecting to /bin/systemctl restart mongod.service
51
+ Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
52
+ ```
53
+
54
+ 言われた通りにstatusを実行してみると、以下のような結果が表示されます。
55
+
56
+ ```
57
+ [ec2-user@ip-hogehoge etc]$ sudo systemctl status mongod.service
58
+ ● mongod.service - MongoDB Database Server
59
+ Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
60
+ Active: failed (Result: exit-code) since 火 2020-06-16 06:36:39 UTC; 14s ago
61
+ Docs: https://docs.mongodb.org/manual
62
+ Process: 6622 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
63
+ Process: 6619 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
64
+ Process: 6616 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
65
+ Process: 6614 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
66
+ Main PID: 6559 (code=exited, status=0/SUCCESS)
67
+
68
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: Starting MongoDB Database Server...
69
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal mongod[6622]: Error parsing YAML config file: yaml-cpp: error at line 29, ...alue
70
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal mongod[6622]: try '/usr/bin/mongod --help' for more information
71
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=2
72
+ 6月 16 06:36:39 ip-hogehoge..ap-northeast-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
73
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: Unit mongod.service entered failed state.
74
+ 6月 16 06:36:39 ip-hogehoge.ap-northeast-1.compute.internal systemd[1]: mongod.service failed.
75
+ Hint: Some lines were ellipsized, use -l to show in full.
76
+ ```
77
+
78
+ この結果の上から5行目が、
79
+
80
+ ```
81
+ Process: 6622 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
82
+ ```
83
+
84
+ となっており、これが原因で
85
+
86
+ ```
87
+ 6月 16 06:36:39 ip-hogehoge..ap-northeast-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
88
+ ```
89
+
90
+ となるのではないかと推測しているのですが、調べても解決方法が見当たりません。
91
+
92
+ 以上、ご教授いただけると助かります。
93
+
94
+
38
95
  ### 試したこと
39
96
 
40
- ここに問題に対して試したことを記載してださい
97
+ /etc/mongod.conf を編集前戻すと、問題再起動できます
41
98
 
99
+ ```
100
+ [ec2-user@ip-hogehoge etc]$ sudo service mongod restart
42
- ### 補足情報(FW/ツールのバージョンなど)
101
+ Redirecting to /bin/systemctl restart mongod.service
102
+ ```
43
103
 
104
+
105
+ ### 参考にしたサイト
106
+
107
+ https://stackoverflow.com/questions/49285525/connect-to-ec2-via-mongodb-compass-community
108
+
109
+ https://docs.mongodb.com/manual/reference/configuration-options/#net-options
110
+
111
+ https://teratail.com/questions/130790
112
+
113
+ https://docs.mongodb.com/manual/reference/exit-codes/
44
- ここより詳細な情報を記載してくださ
114
+ ↑ステータスコード
115
+
116
+ https://stackoverflow.com/questions/57380491/mongodb-status-failed-after-editing-mongo-conf-code-exited-status-2
117
+
118
+ https://superuser.com/questions/1397079/mongo-cant-start-service