Mongod 在 ubuntu 上启动问题

问题描述 投票:0回答:1

当我尝试检查 mongodb 的状态时,我得到以下信息:

× mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-04-16 16:40:14 EDT; 19s ago
       Docs: https://docs.mongodb.org/manual
    Process: 10689 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
   Main PID: 10689 (code=exited, status=1/FAILURE)
        CPU: 39ms

Apr 16 16:40:14 rime-VirtualBox systemd[1]: Started MongoDB Database Server.
Apr 16 16:40:14 rime-VirtualBox mongod[10689]: {"t":{"$date":"2024-04-16T20:40:14.057Z"},"s":"I",  "c":"CONTROL",  "id":5760901, ">
Apr 16 16:40:14 rime-VirtualBox mongod[10689]: about to fork child process, waiting until server is ready for connections.
Apr 16 16:40:14 rime-VirtualBox mongod[10691]: forked process: 10691
Apr 16 16:40:14 rime-VirtualBox mongod[10689]: ERROR: child process failed, exited with 1
Apr 16 16:40:14 rime-VirtualBox mongod[10689]: To see additional information in this output, start without the "--fork" option.
Apr 16 16:40:14 rime-VirtualBox systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
Apr 16 16:40:14 rime-VirtualBox systemd[1]: mongod.service: Failed with result 'exit-code'.
~

以下是一些重要文件:

配置

storage:
  dbPath: /var/lib/mongodb
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
net:
  port: 27017
  bindIp: 127.0.0.1
processManagement:
   fork: true
setParameter:
   enableLocalhostAuthBypass: false

服务

[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
RuntimeDirectory=mongodb
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false

# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings

[Install]
WantedBy=multi-user.target

日志


{"t":{"$date":"2024-04-16T16:45:41.024-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:42.029-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:43.029-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:44.029-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:45.041-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:46.041-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:47.043-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:48.045-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:49.046-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:50.052-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:51.057-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:52.059-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:53.059-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:54.060-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:55.081-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:55.367-04:00"},"s":"D1", "c":"INDEX",    "id":22533,   "ctx":"TTLMonitor","msg":"running TTL job for index","attr":{"namespace":"config.system.sessions","key":{"lastUse":1},"name":"lsidTTLIndex"}}
{"t":{"$date":"2024-04-16T16:45:55.367-04:00"},"s":"I",  "c":"INDEX",    "id":5479200, "ctx":"TTLMonitor","msg":"Deleted expired documents using index","attr":{"namespace":"config.system.sessions","index":"lsidTTLIndex","numDeleted":0,"durationMillis":0}}
{"t":{"$date":"2024-04-16T16:45:56.087-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:56.838-04:00"},"s":"D1", "c":"WTCHKPT",  "id":22430,   "ctx":"Checkpointer","msg":"WiredTiger message","attr":{"message":{"ts_sec":1713300356,"ts_usec":838383,"thread":"9327:0x76d97d11b640","session_name":"WT_SESSION.checkpoint","category":"WT_VERB_CHECKPOINT_PROGRESS","category_id":6,"verbose_level":"DEBUG_1","verbose_level_id":1,"msg":"saving checkpoint snapshot min: 69, snapshot max: 69 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1"}}}
{"t":{"$date":"2024-04-16T16:45:56.864-04:00"},"s":"D1", "c":"STORAGE",  "id":7702900, "ctx":"Checkpointer","msg":"Checkpoint thread sleeping","attr":{"duration":60}}
{"t":{"$date":"2024-04-16T16:45:57.087-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:58.087-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:45:59.088-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:00.088-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:01.089-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:02.092-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:03.092-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:04.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:05.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:06.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:07.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:08.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:09.094-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:10.097-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:11.097-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:12.097-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:13.097-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:14.098-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:15.105-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:16.106-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:17.106-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:18.127-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:19.128-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:20.132-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:21.149-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:22.156-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:23.176-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:24.194-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:25.194-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:26.200-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:27.202-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
{"t":{"$date":"2024-04-16T16:46:28.204-04:00"},"s":"D1", "c":"STORAGE",  "id":8097401, "ctx":"TimestampMonitor","msg":"No drop-pending idents have expired","attr":{"timestamp":{"$timestamp":{"t":0,"i":0}},"pendingIdentsCount":0}}
rime@rime-VirtualBox:~$ 

您能帮我解决这个问题吗?当我用 --verbose 启动它时,它似乎开始得很好...

我尝试更改.service文件中的execstart参数,但已经没有--fork

mongodb ubuntu configuration
1个回答
0
投票

一个常见的问题是缺少

storage.dbPath

除此之外,我建议使用这样的设置:

processManagement:
  fork: true
  pidFilePath: /var/run/mongodb/mongod.pid
  timeZoneInfo: /usr/share/zoneinfo

确保

storage.dbPath
的可靠方法是在服务文件中创建文件夹。看起来像这样:

[Service]
User=mongodb
Group=mongodb
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
ExecStartPre=/usr/bin/mkdir -p /var/lib/mongo
ExecStartPre=/usr/bin/chown mongod:mongod /var/lib/mongo
ExecStartPre=/usr/bin/chmod 0700 /var/lib/mongo
ExecStartPre=/usr/bin/mkdir -p /var/log/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/log/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/log/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking

注意,您不应该直接编辑文件

/lib/systemd/system/mongod.service
。当您更新 MongoDB 时,您的更改可能会被恢复。最好创建一个副本到
/etc/systemd/system/mongod.service
并将您的自定义设置放在那里。请参阅 https://unix.stackexchange.com/questions/224992/where-do-i-put-my-systemd-unit-file - 并且不要忘记随后运行
systemctl daemon-reload

© www.soinside.com 2019 - 2024. All rights reserved.