본문으로 바로가기

문제

 

환경

Linux db 5.4.51-v7+ #1333 SMP Mon Aug 10 16:45:19 BST 2020 armv7l GNU/Linux


PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

 

파이썬과 연동과정에서 갑자기 데이터 삽입이 안되는 현상이 발생했고, MongoDB 재시작 후 다음과 같이 접근이 불가했습니다.

$ sudo mongo

> show dbs
Fri Sep  4 18:41:49.461 listDatabases failed:{
	"errmsg" : "exception: file /var/lib/mongodb/db.4 open/create failed in createPrivateMap (look in log for more information)",
	"code" : 13636,
	"ok" : 0
} at src/mongo/shell/mongo.js:46

 

$ tail /var/log/mongodb/mongodb.log
 /usr/bin/mongod(_ZN5mongo12_execCommandEPNS_7CommandERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_7BSONObjEiRS7_RNS_14BSONObjBuilderEb+0x34) [0x303a3c]
 /usr/bin/mongod(_ZN5mongo7Command11execCommandEPS0_RNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x668) [0x304298]
 /usr/bin/mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x260) [0x304c30]
 /usr/bin/mongod(_ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x2c) [0x45d094]
 /usr/bin/mongod(_ZN5mongo8runQueryB5cxx11ERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0x8f8) [0x4603e4]
 /usr/bin/mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0x524) [0x3f52d8]
Fri Sep  4 18:41:49.441 [conn1] warning database /var/lib/mongodb db could not be opened
Fri Sep  4 18:41:49.442 [conn1] DBException 13636: file /var/lib/mongodb/db.4 open/create failed in createPrivateMap (look in log for more information)
Fri Sep  4 18:41:49.451 [conn1] command admin.$cmd command: { listDatabases: 1.0 } ntoreturn:1 keyUpdates:0 locks(micros) W:2835017 r:114 reslen:179 2839ms
Fri Sep  4 18:41:52.735 [conn1] end connection 127.0.0.1:57192 (0 connections now open)

 

 

해결방법

 

메모리 부족으로 발생하는 오류입니다.

 

Swap Memory 증가, Memory Overcommit 활성화 설정으로 해결되지 않았고

MongoDB 설정파일의 Journaling 옵션을 주석처리해서 해결되었습니다.

 

/etc/mongodb.conf

# mongodb.conf

...

# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
# journal=true

 

해당 설정파일 주석처리한 후 MongoDB 서비스를 재시작합니다.

$ sudo systemctl restart mongodb

 

> show dbs
daum_news	0.5GB
dictionary	0.0625GB
football	0.0625GB
local	0.03125GB
naver_news	0.5GB
test	0.0625GB