MongoDB被linux杀死了

Arm*_*ndo 6 linux signals kill mongodb

我的mongoDB总是在没有被访问的几个小时内收到KILL信号,我不知道原因.

我正在使用:
SO:Ubuntu 16.04,512MB内存.
在pm2中运行节点7.5.0.
MongoDB版本3.4.1

状态mongod:

mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Fri 2017-06-02 06:25:06 BRT; 9h ago
 Docs: https://docs.mongodb.org/manual
Process: 1334 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=killed, signal=KILL)
Main PID: 1334 (code=killed, signal=KILL)

May 29 19:12:16 admin systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 02 06:25:06 admin systemd[1]: mongod.service: Main process exited, code=killed, status=9/KILL
Jun 02 06:25:06 admin systemd[1]: mongod.service: Unit entered failed state.
Jun 02 06:25:06 admin systemd[1]: mongod.service: Failed with result 'signal'.
Run Code Online (Sandbox Code Playgroud)

Mongod.service:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

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

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

等/ mongod.conf:

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true

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

net:
  port: 27017
  bindIp: 127.0.0.1

processManagement:
  fork: false
Run Code Online (Sandbox Code Playgroud)

journalctl:

Jun 01 22:32:02 admin pm2[23634]: [PM2] Spawning PM2 daemon with pm2_home=/home/administrator/.pm2
Jun 01 22:32:02 admin pm2[23634]: [PM2] PM2 Successfully daemonized
Jun 01 22:32:02 admin pm2[23634]: [PM2] Stopping PM2...
Jun 01 22:32:02 admin pm2[23634]: [PM2][WARN] No process found
Jun 01 22:32:02 admin pm2[23634]: [PM2] All processes have been stopped and deleted
Jun 01 22:32:02 admin pm2[23634]: [PM2] PM2 stopped
Jun 01 22:32:06 admin pm2[23649]: pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: Launching in no daemon mode
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: [PM2] Resurrecting
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: [PM2] Restoring processes located in /home/administrator/.pm2/dump.pm2
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: [Watch] Start watching 0
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: Starting execution sequence in -fork mode- for app name:MY_NODE id:1
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: App name:MY_NODE id:1 online
Jun 01 22:32:06 admin pm2[23649]: 2017-06-01 22:32:06: [PM2] Process /home/servers/nodejs/server_MY_NODE/server.js restored
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: ????????????????????????????????????????????????????????????????????????????????????????????
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: ? App name    ? id ? mode ? pid   ? status ? restart ? uptime ? cpu ? mem       ? watching ?
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: ????????????????????????????????????????????????????????????????????????????????????????????
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: ?   MY_NODE   ? 1  ? fork ? 23665 ? online ? 0       ? 0s     ? 24% ? 23.9 MB   ? disabled ?
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: ????????????????????????????????????????????????????????????????????????????????????????????
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07:  Use `pm2 show <id|name>` to get more details about an app
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: [--no-daemon] Continue to stream logs
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: [--no-daemon] Exit on target PM2 exit pid=23649
Jun 01 22:32:07 admin pm2[23649]: 2017-06-01 22:32:07: [STREAMING] Now streaming realtime logs for [all] processes
Jun 01 22:32:07 admin pm2[23649]: 22:32:07 1|MY_NODE | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
Jun 01 22:32:07 admin pm2[23649]: 22:32:07 1|MY_NODE | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Jun 01 22:32:09 admin pm2[23649]: 22:32:09 1|MY_NODE | Express Server in 10555
Jun 01 22:32:09 admin pm2[23649]: 22:32:09 1|MY_NODE | Database! connected in mongodb://localhost/MY_MONGO
Jun 02 06:25:05 admin pm2[23649]: 2017-06-02 06:25:05: App [MY_NODE] with id [1] and pid [23665], exited with code [0] via signal [SIGKILL]
Jun 02 06:25:05 admin pm2[23649]: 2017-06-02 06:25:05: Starting execution sequence in -fork mode- for app name:MY_NODE id:1
Jun 02 06:25:05 admin pm2[23649]: 06:25:05 PM2        | App [MY_NODE] with id [1] and pid [23665], exited with code [0] via signal [SIGKILL]
Jun 02 06:25:05 admin pm2[23649]: 06:25:05 PM2        | Starting execution sequence in -fork mode- for app name:MY_NODE id:1
Jun 02 06:25:05 admin pm2[23649]: 2017-06-02 06:25:05: App name:MY_NODE id:1 online
Jun 02 06:25:05 admin pm2[23649]: 06:25:05 PM2        | App name:MY_NODE id:1 online
Jun 02 06:25:06 admin pm2[23649]: 06:25:06 1|MY_NODE | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
Jun 02 06:25:06 admin pm2[23649]: 06:25:06 1|MY_NODE | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Jun 02 06:25:08 admin pm2[23649]: 06:25:08 1|MY_NODE | Express Server in 10555
Jun 02 06:25:08 admin pm2[23649]: 06:25:08 1|MY_NODE | Database! disconnected from mongodb://localhost/MY_MONGO
Jun 02 06:25:08 admin pm2[23649]: 06:25:08 1|MY_NODE | Database! Error in connection mongodb://localhost/MY_MONGO
Run Code Online (Sandbox Code Playgroud)

谁能帮助我,我将不胜感激

谢谢

c10*_*0ud 7

根据 Mongo-DB 文档,Ulimit 会影响 mongo 服务。我通过运行解决了同样的问题: ulimit -a验证这就是问题所在。

如果 -n 标志小于 64,000,则必须更改它: sudo ulimit -n 64000

然后重启mongo: sudo systemctl restart mongod

并确保它现在正在运行: systemctl status mongod