MongoDB 停止未知原因

MongoDB stops unknown reason

我在 Ubuntu 14.04.4 上设置了 MongoDB 服务器 有时它会停止不明原因。你有什么想法吗?

你可以看到我启动mongod实例前后的最后日志。

2016-10-12T08:47:32.223+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-12T08:47:32.222+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-10-12T08:47:31.727+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-12T08:47:31.727+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2016-10-12T08:47:31.727+0000 W - [initandlisten] Detected unclean shutdown - /var/lib/mongodb/mongod.lock is not empty.
2016-10-12T08:47:31.727+0000 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,server_ip", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] distarch: x86_64
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] build environment:
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] modules: none
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] db version v3.2.10
2016-10-12T08:47:31.700+0000 I CONTROL [initandlisten] MongoDB starting : pid=4487 port=27017 dbpath=/var/lib/mongodb 64-bit host=db-server
2016-10-11T06:54:31.233+0000 I ACCESS [conn1] Successfully authenticated as principal agent on admin
2016-10-11T06:54:29.641+0000 I ACCESS [conn6] Successfully authenticated as principal agent on admin

Note: I was not change anything on config file except bind Ip.

更新

当我查看系统日志文件时;

Oct 11 02:54:38 db-server kernel: [] Out of memory: Kill process 26603 (mongod) score 687 or sacrifice child
Oct 11 02:54:38 db-server kernel: [] init: mongod main process (26603) killed by KILL signal

看起来您的 mongo 进程已被 Linux 内存不足杀手杀死。这通常发生在您的机器 运行 内存不足并且需要终止某些东西以防止 OS 崩溃时。

您可以指导它做什么。你可以看看这篇文章来获得一些建议:

OOM Killer

或者您可以尝试 运行 Mongo 更少的内存,但是 Mongo 很难配置以限制内存使用。这里有一些指导:

Easy Steps to Limit Mongodb Memory Usage

可能是您的机器上没有足够的 RAM 运行 mongo - 您的 Ubuntu 服务器上有多少内存?