고양이/etc/yum.repos.d/mongodb-org.repo

고양이/etc/yum.repos.d/mongodb-org.repo

MongoDb는 기본 설정으로 잘 실행됩니다.

cat /etc/mongod.conf이 문제는 기본 로그 경로를 다음으로 변경하면 발생합니다.

systemLog:
  destination: file
  logAppend: true
  path: /var/www/logs/mongodb/mongod.log

설치 및 시작 단계는 다음과 같습니다.mongod

설치가 성공한 것처럼 보이지만 mongod로그 경로가 업데이트된 후에는 시작되지 않습니다 /etc/mongod.conf.

고양이/etc/yum.repos.d/mongodb-org.repo

[mongodb-org-6.0]
name=MongoDB Repository
#baseurl=https://repo.mongodb.org/yum/redhat//mongodb-org/6.0/x86_64/
baseurl=https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

#mongod 스크립트 설치 및 실행

echo "Installing mongodb"
sudo yum install -y mongodb-org
mkdir -p "$log_location/mongodb"
sudo systemctl start mongod
echo "Status mongodb"
sudo systemctl status mongod --no-pager

산출:

Installing mongodb
MongoDB Repository                                                                                                                                       5.8 kB/s | 9.4 kB     00:01
Package mongodb-org-4.0.28-1.el8.x86_64 is already installed.
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                                    Architecture                     Version                                     Repository                                 Size
=========================================================================================================================================================================================
Upgrading:
 mongodb-org                                                x86_64                           6.0.1-1.el8                                 mongodb-org-6.0                            11 k
 mongodb-org-tools                                          x86_64                           6.0.1-1.el8                                 mongodb-org-6.0                            11 k
Installing dependencies:
 cyrus-sasl                                                 x86_64                           2.1.27-6.el8_5                              baseos                                     96 k
 mongodb-database-tools                                     x86_64                           100.6.0-1                                   mongodb-org-6.0                            48 M
 mongodb-mongosh                                            x86_64                           1.5.4-1.el8                                 mongodb-org-6.0                            41 M
 mongodb-org-database                                       x86_64                           6.0.1-1.el8                                 mongodb-org-6.0                            11 k
 mongodb-org-database-tools-extra                           x86_64                           6.0.1-1.el8                                 mongodb-org-6.0                            16 k

Transaction Summary
=========================================================================================================================================================================================
Install  5 Packages
Upgrade  2 Packages

Total download size: 89 M
Downloading Packages:
(1/7): mongodb-mongosh-1.5.4.x86_64.rpm                                                                                                                   51 MB/s |  41 MB     00:00
(2/7): mongodb-database-tools-100.6.0.x86_64.rpm                                                                                                          50 MB/s |  48 MB     00:00
(3/7): mongodb-org-database-6.0.1-1.el8.x86_64.rpm                                                                                                        43 kB/s |  11 kB     00:00
(4/7): mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64.rpm                                                                                            66 kB/s |  16 kB     00:00
(5/7): mongodb-org-6.0.1-1.el8.x86_64.rpm                                                                                                                 44 kB/s |  11 kB     00:00
(6/7): mongodb-org-tools-6.0.1-1.el8.x86_64.rpm                                                                                                           41 kB/s |  11 kB     00:00
(7/7): cyrus-sasl-2.1.27-6.el8_5.x86_64.rpm                                                                                                              6.5 kB/s |  96 kB     00:14
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    5.8 MB/s |  89 MB     00:15
MongoDB Repository                                                                                                                                       660  B/s | 1.7 kB     00:02
Importing GPG key 0x64C3C388:
 Userid     : "MongoDB 6.0 Release Signing Key <[email protected]>"
 Fingerprint: 39BD 841E 4BE5 FB19 5A65 400E 6A26 B1AE 64C3 C388
 From       : https://www.mongodb.org/static/pgp/server-6.0.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1
  Installing       : mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64                                                                                                             1/9
  Installing       : mongodb-org-database-6.0.1-1.el8.x86_64                                                                                                                         2/9
  Installing       : mongodb-mongosh-1.5.4-1.el8.x86_64                                                                                                                              3/9
  Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                                                                                4/9
  Installing       : cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                                                                                4/9
  Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                                                                                4/9
  Running scriptlet: mongodb-database-tools-100.6.0-1.x86_64                                                                                                                         5/9
  Installing       : mongodb-database-tools-100.6.0-1.x86_64                                                                                                                         5/9
  Running scriptlet: mongodb-database-tools-100.6.0-1.x86_64                                                                                                                         5/9
  Upgrading        : mongodb-org-tools-6.0.1-1.el8.x86_64                                                                                                                            6/9
  Upgrading        : mongodb-org-6.0.1-1.el8.x86_64                                                                                                                                  7/9
  Cleanup          : mongodb-org-4.0.28-1.el8.x86_64                                                                                                                                 8/9
  Cleanup          : mongodb-org-tools-4.0.28-1.el8.x86_64                                                                                                                           9/9
  Running scriptlet: mongodb-org-tools-4.0.28-1.el8.x86_64                                                                                                                           9/9
  Verifying        : cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                                                                                1/9
  Verifying        : mongodb-database-tools-100.6.0-1.x86_64                                                                                                                         2/9
  Verifying        : mongodb-mongosh-1.5.4-1.el8.x86_64                                                                                                                              3/9
  Verifying        : mongodb-org-database-6.0.1-1.el8.x86_64                                                                                                                         4/9
  Verifying        : mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64                                                                                                             5/9
  Verifying        : mongodb-org-6.0.1-1.el8.x86_64                                                                                                                                  6/9
  Verifying        : mongodb-org-4.0.28-1.el8.x86_64                                                                                                                                 7/9
  Verifying        : mongodb-org-tools-6.0.1-1.el8.x86_64                                                                                                                            8/9
  Verifying        : mongodb-org-tools-4.0.28-1.el8.x86_64                                                                                                                           9/9

Upgraded:
  mongodb-org-6.0.1-1.el8.x86_64                                                           mongodb-org-tools-6.0.1-1.el8.x86_64
Installed:
  cyrus-sasl-2.1.27-6.el8_5.x86_64                        mongodb-database-tools-100.6.0-1.x86_64     mongodb-mongosh-1.5.4-1.el8.x86_64     mongodb-org-database-6.0.1-1.el8.x86_64
  mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64

Complete!
Job for mongod.service failed because the control process exited with error code.
See "systemctl status mongod.service" and "journalctl -xe" for details.
Status mongodb
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2022-09-05 06:36:08 UTC; 75ms ago
     Docs: https://docs.mongodb.org/manual
  Process: 33739 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=1/FAILURE)
  Process: 33736 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 33735 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 33733 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Sep 05 06:36:08 DKERP systemd[1]: Starting MongoDB Database Server...
Sep 05 06:36:08 DKERP mongod[33739]: about to fork child process, waiting until server is ready for connections.
Sep 05 06:36:08 DKERP mongod[33740]: forked process: 33741
Sep 05 06:36:08 DKERP mongod[33739]: ERROR: child process failed, exited with error number 1
Sep 05 06:36:08 DKERP mongod[33739]: To see additional information in this output, start without the "--fork" option.
Sep 05 06:36:08 DKERP systemd[1]: mongod.service: Control process exited, code=exited status=1
Sep 05 06:36:08 DKERP systemd[1]: mongod.service: Failed with result 'exit-code'.
Sep 05 06:36:08 DKERP systemd[1]: Failed to start MongoDB Database Server.

한 가지 제안은 이 명령을 시도한 후에 시작하는 것이었지만 sudo systemctl daemon-reload나에게도 효과가 없었습니다.

안타깝게도 다음 출력과 같이 로그에는 아무 것도 표시되지 않습니다.

[root@vultr ~]# grep log /etc/mongod.conf
# where to write logging data.
  logAppend: true
  path: /var/www/logs/mongodb/mongod.log
[root@vultr ~]# cat /var/www/logs/mongodb/mongod.log | wc -l
cat: /var/www/logs/mongodb/mongod.log: No such file or directory
0

나는 centos8에서 mongo 6을하고 있습니다

[root@vultr ~]# uname -a
Linux DKERP 4.18.0-408.el8.x86_64 #1 SMP Mon Jul 18 17:42:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@vultr ~]# hostnamectl
   Static hostname: DKERP
         Icon name: computer-vm
           Chassis: vm
        Machine ID: c07ca36f4c37437f8c6c6cbb7d73daf1
           Boot ID: 83ee4a5872024054be50448423a9f5e7
    Virtualization: microsoft
  Operating System: CentOS Stream 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-408.el8.x86_64
      Architecture: x86-64

fork구성 파일에서 옵션을 제거했습니다 . 자세한 디버그 정보는 다음과 같습니다.

[root@vultr ~]# journalctl -xe
Sep 05 10:20:26 DKERP systemd[1]: Starting MongoDB Database Server...
-- Subject: Unit mongod.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit mongod.service has begun starting up.
Sep 05 10:20:26 DKERP mongod[34825]: 2022-09-05T10:20:26.596+0000 F CONTROL  [main] Failed global initialization: FileNotOpen: Failed to open "/var/www/logs/mongodb/mongod.log"
Sep 05 10:20:26 DKERP systemd[1]: mongod.service: Control process exited, code=exited status=1
Sep 05 10:20:26 DKERP dbus-daemon[775]: [system] Activating via systemd: service name='org.fedoraproject.Setroubleshootd' unit='setroubleshootd.service' requested by ':1.239' (uid=0 pi>
Sep 05 10:20:26 DKERP systemd[1]: mongod.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The unit mongod.service has entered the 'failed' state with result 'exit-code'.
Sep 05 10:20:26 DKERP systemd[1]: Failed to start MongoDB Database Server.
-- Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit mongod.service has failed.
--
-- The result is failed.
Sep 05 10:20:26 DKERP systemd[1]: Starting SETroubleshoot daemon for processing new SELinux denial logs...
-- Subject: Unit setroubleshootd.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit setroubleshootd.service has begun starting up.
Sep 05 10:20:26 DKERP sudo[34814]: pam_unix(sudo:session): session closed for user root
Sep 05 10:20:27 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd'
Sep 05 10:20:27 DKERP systemd[1]: Started SETroubleshoot daemon for processing new SELinux denial logs.
-- Subject: Unit setroubleshootd.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit setroubleshootd.service has finished starting up.
--
-- The start-up result is done.
Sep 05 10:20:28 DKERP setroubleshoot[34827]: AnalyzeThread.run(): Cancel pending alarm
Sep 05 10:20:28 DKERP dbus-daemon[775]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.917' (uid=995 pid=34827 comm="/usr/libexec/platfo>
Sep 05 10:20:28 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged'
Sep 05 10:20:29 DKERP setroubleshoot[34827]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0>
Sep 05 10:20:29 DKERP setroubleshoot[34827]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes.

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

                                             If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default.
                                             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 -X 300 -i my-mongod.pp

Sep 05 10:20:29 DKERP setroubleshoot[34827]: AnalyzeThread.run(): Set alarm timeout to 10

그런 다음 일시적으로 비활성화하기로 결정했지만 selinux여전히 다음 오류가 발생합니다.

[root@vultr ~]# journalctl -xe
Sep 05 10:26:43 DKERP systemd[1]: Started SETroubleshoot daemon for processing new SELinux denial logs.
-- Subject: Unit setroubleshootd.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit setroubleshootd.service has finished starting up.
--
-- The start-up result is done.
Sep 05 10:26:43 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm
Sep 05 10:26:43 DKERP dbus-daemon[775]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.949' (uid=995 pid=34922 comm="/usr/libexec/platfo>
Sep 05 10:26:44 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged'
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0>
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes.

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

                                             If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default.
                                             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 -X 300 -i my-mongod.pp

Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10
Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0>
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes.

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

                                             If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default.
                                             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 -X 300 -i my-mongod.pp

Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10
Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm
Sep 05 10:26:44 DKERP setroubleshoot[34922]: failed to retrieve rpm info for /sys/fs/cgroup/memory/memory.limit_in_bytes
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from getattr access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes. For complete SELinux mes>
Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from getattr access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes.

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

                                             If you believe that mongod should be allowed getattr access on the memory.limit_in_bytes file by default.
                                             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 -X 300 -i my-mongod.pp

Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10

mongod를 실행하는 방법을 제안해 주실 수 있나요?

관련 정보