CentOS 7にMongoDBをインストールして実行する方法は?

CentOS 7にMongoDBをインストールして実行する方法は?

CentOS 7システムにMongoDBサーバーをインストールして実行しようとしています。 CentOS 7システムは私の大学のキャンパスにあり、自宅からVPN経由でSSH経由でアクセスします。

私はフォローしましたすべてリンクに記載されている手順:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

出力は次のとおりですsudo systemctl start mongod

Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.  

出力は次のとおりですsystemctl status mongod.service

● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2020-12-30 00:23:07 IST; 1min 41s ago
     Docs: https://docs.mongodb.org/manual
  Process: 61587 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
  Process: 61584 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 61581 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 61578 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Dec 30 00:23:07 smart systemd[1]: Starting MongoDB Database Server...
Dec 30 00:23:07 smart mongod[61587]: about to fork child process, waiting until server is ready for connections.
Dec 30 00:23:07 smart mongod[61587]: forked process: 61589
Dec 30 00:23:07 smart mongod[61587]: ERROR: child process failed, exited with 14
Dec 30 00:23:07 smart mongod[61587]: To see additional information in this output, start without the "--for...tion.
Dec 30 00:23:07 smart systemd[1]: mongod.service: control process exited, code=exited status=14
Dec 30 00:23:07 smart systemd[1]: Failed to start MongoDB Database Server.
Dec 30 00:23:07 smart systemd[1]: Unit mongod.service entered failed state.
Dec 30 00:23:07 smart systemd[1]: mongod.service failed.
Hint: Some lines were ellipsized, use -l to show in full.   

出力は次のとおりですjournalctl -xe

Dec 30 00:23:07 smart polkitd[1826]: Unregistered Authentication Agent for unix-process:61557:106467206 (system bus
Dec 30 00:23:08 smart dbus[1879]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd'
Dec 30 00:23:08 smart setroubleshoot[61594]: failed to retrieve rpm info for /proc/sys/net/ipv4/tcp_fastopen
Dec 30 00:23:08 smart setroubleshoot[61594]: SELinux is preventing /usr/bin/mongod from open access on the file /pr
Dec 30 00:23:08 smart python[61594]: SELinux is preventing /usr/bin/mongod from open access on the file /proc/sys/n

                                     *****  Plugin catchall (100. confidence) suggests   **************************

                                     If you believe that mongod should be allowed open access on the tcp_fastopen f
                                     Then you should report this as a bug.
                                     You can generate a local policy module to allow this access.
                                     Do
                                     allow this access for now by executing:
                                     # ausearch -c 'mongod' --raw | audit2allow -M my-mongod
                                     # semodule -i my-mongod.pp

Dec 30 00:23:11 smart setroubleshoot[61594]: SELinux is preventing /usr/bin/mongod from unlink access on the sock_f
Dec 30 00:23:11 smart python[61594]: SELinux is preventing /usr/bin/mongod from unlink access on the sock_file mong

                                     *****  Plugin catchall (100. confidence) suggests   **************************

                                     If you believe that mongod should be allowed unlink access on the mongodb-2701
                                     Then you should report this as a bug.
                                     You can generate a local policy module to allow this access.
                                     Do
                                     allow this access for now by executing:
                                     # ausearch -c 'mongod' --raw | audit2allow -M my-mongod
                                     # semodule -i my-mongod.pp

Dec 30 00:24:52 smart chronyd[2023]: Source 162.159.200.123 replaced with 5.189.141.35

どこで間違っているのか、基本的な構成手順を見逃したのかはわかりません。私は次のような多くのオンラインブログ/ウェブサイトを試しました。
https://unix.stackexchange.com/a/568238/372656
https://stackoverflow.com/a/64818226
しかし、彼らは役に立ちませんでした。

誰でもこの問題を解決する方法を説明できますか?よろしくお願いします。

ベストアンサー1

私は解決策として私のコメントを投稿すると思いました。

これは、Journalctl出力では、SELinuxがMongodが特定のファイルに公開アクセスするのを防ぎ、mongodbが機能しないことを示します。 SELinuxを許可モードに設定するか、SELinuxにmongodbの実行を許可するように指示する必要があります。

バラよりこのリンク詳細については。このリンク詳細については、リンク1に従ってenforcing = 0に設定するか、/etc/selinux/configを編集して許可に設定してください。

おすすめ記事