본문 바로가기

project/Expert

[MongoDB] dump하고 backup 하기 - ③

728x90
반응형

 이전 포스팅에서는 MongoDB dump를 할 때, 순서대로 시도했었던 방법들과 오류들에 대해서 포스팅 하였다. 이번 포스팅 역시 오류 발생이 주 내용이다. 

ssanggo.tistory.com/55

 

[MongoDB] dump하고 backup 하기 - ②(오류 대잔치)

이전 포스팅에서는 MongoDB dump 하는 방법을 알아 보았다. MongoDB dump 방법에 대해 궁금한 사람은 아래 링크를 통해 확인해 보길 바랍니다. ssanggo.tistory.com/54 [MongoDB] dump하고 backup 하기 - ① 프로..

ssanggo.tistory.com


 

6. 구글링을 하다보니, Cache 문제일 수 있다는 내용을 보아서 Mongod.conf 설정을 바꿔 실행을 하기로 하였다.

Mongod.conf 의 path는 /etc/mongod.conf 이다. 아래는 처음 기본으로 설정던 설정값이다.

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
  #path: /home/search/apps/mongo_data/log/mongodb.log

# Where and how to store data.
storage:
  dbPath: /home/mongo_data/
  journal:
    enabled: true
#  engine:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  #pidFilePath: /home/search/apps/mongo_data/mongod.pid

  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.

 

우선 설치된 mongo의 cache는 얼마인지 확인을 하기 위해서 mongo shell에 들어가 db.serverStatus().wiredTiger.cache 라는 명령어를 치게 되면 아래와 같은 내용이 나온다. 더 많은 내용이 나오지만.. cache 사이즈를 보니, "maximum bytes configured" 쪽은 이상이 없는 것 같은데, "bytes currently in the cache" 부분의 캐시가 부족한 것 같아 2GB 로 늘리기로 하였다.

"bytes currently in the cache" : 599763,

"maximum bytes configured" : 33077329920,

 

> db.serverStatus().wiredTiger.cache
{
	"application threads page read from disk to cache count" : 17,
	"application threads page read from disk to cache time (usecs)" : 494,
	"application threads page write from cache to disk count" : 271,
	"application threads page write from cache to disk time (usecs)" : 23419,
	"bytes belonging to page images in the cache" : 534739,
	"bytes belonging to the cache overflow table in the cache" : 182,
	"bytes currently in the cache" : 599763,
	"bytes dirty in the cache cumulative" : 2191523,
	"bytes not belonging to page images in the cache" : 65024,
	"bytes read into cache" : 495324,
	"bytes written from cache" : 3030484,
	"cache overflow cursor application thread wait time (usecs)" : 0,
	"cache overflow cursor internal thread wait time (usecs)" : 0,
	"cache overflow score" : 0,
	"cache overflow table entries" : 0,
	"cache overflow table insert calls" : 0,
	"cache overflow table max on-disk size" : 0,
	"cache overflow table on-disk size" : 0,
	"cache overflow table remove calls" : 0,
	"checkpoint blocked page eviction" : 0,

 

여기서 추가로 설정한 것은 storage에 "wiredTiger" 라고 되어 있는 부분의 내용이다. "wiredTiger" 세부 설정된 내용은 다른 블로그에서 찾은 내용을 참고하였다.

 

storage:
  dbPath: /home/mongo_data/
  journal:
    enabled: true
  # engine:
  wiredTiger:
    engineConfig:
      cacheSizeGB : 2
      journalCompressor : zstd
      directoryForIndexes : false
      maxCacheOverflowFileSizeGB : 30
    collectionConfig :
      blockCompressor : zstd
    indexConfig : 
      prefixCompression : true

 

그러고 나서 설정된 값을 적용하기 위해서는 기존 mongo를 종료했다가 다시 켜야 적용이 된다고 하여, 강제로 kill을 하였다. 그랬더니, MongoDB가 켜지지가 않았다.. 기존에 Mongo가 안켜지면 시도했었던 명령어들과 방법들을 시도했지만, 이번에는 WiredTiger Error (13) 이라는 Error가 발생했는데, 여기서 부터는 정말 식은땀이 날 정도로 패닉이 와버렸다...

 

해결하기 위해 열심히 구글링을 하였던 결과를 짧게 나마 순서대로 요약하자면,

 

더보기

1. mongo --repair → 실행X

2. tmp/mongodb-27017.sock, /home/DB/mongod.lock, WiredTiger.lock 삭제 → 실행 X

3. conf 기존 값으로 다시 변경 → 실행 X

4. /home/DB 권한설정(sudo chown -R mongod:mongod /home/DB/) → 실행 O

 

결국 mongod.conf 설정한 부분은 확인해 보지 못했다...


 

다음 포스팅에서는 다시 dump시 --gzip 옵션을 넣어서 실행하는 부분을 포스팅 하겠다.

 

 

728x90
반응형