macOS Big Sur 또는 macOS Catalina 에서 추가 작업이 필요하다.

전체 설치 과정은 [DB]몽고DB 설치 - macOS Big Sur 참조

# 테스트 환경 #
- macOS Big Sur 버전 11.x.x
- mongodb community 버전 4.2.x
- Homebrew 버전 3.x.x

 

오류 원인 : 데이터를 저장하는 폴더를 다음과 같이 만들 경우, 현재 macOS Big Sur에서에서 mongo적용되지 않는다.

$ sudo mkdir -p /data/db
mkdir: /data/db: Read-only file system

위 메시지 무시하고 설치 진행하면 다음과 같은 오류 메시지를 만난다.

오류 메시지 : 

[initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file., terminating

 

해결 : dbpath 설정 - 일반적으로 /data/db 경로이지만, /data/db 경로는 macOS Catalina부터 현재 Big Sur 버전에서 적용되지 않으므로, 다음과 같은 다른 경로를 설정한다.

mongod --dbpath /usr/local/var/mongodb/

 

macOS Big Sur 에서 몽고DB 설치 과정이다.

 

설치 환경

- macOS Big Sur 버전 11.x.x

- mongodb community 버전 4.2.x

- Homebrew 버전 3.x.x

 

설치 과정

1-1. xcode 설치된 경우, 패스

 

$ xcode-select --install

1-2. Homebrew 설치된 경우, 패스

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

1-3. Homebrew 업데이트 (2번 과정으로 새로 설치했다면 패스)

$ brew update

 

 

2. 설치 가능한 몽고DB 목록 검색

$ brew search mongodb

3. 이후 mongodb-community@4.2 버전으로 설치

$ brew tap mongodb/brew
$ brew install mongodb-community@4.2
...
If you need to have mongodb-community@4.2 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/mongodb-community@4.2/bin:$PATH"' >> /Users/[username]/.bash_profile
...

4. 환경변수 추가 : 설치 메시지 중에서 echo... 구문 그대로 복붙하여 실행

echo 'export PATH="/usr/local/opt... 생략

5. dbpath 설정 - 일반적으로 /data/db 경로이지만, /data/db 경로는 macOS Catalina부터 현재 Big Sur 버전에서 적용되지 않으므로, 다른 경로를 설정한다.

$ mongod --dbpath /usr/local/var/mongodb/
...
child process started successfully, parent exiting

6. alias 설정

$ alias mongod="mongod --config /usr/local/etc/mongod.conf --fork"

7. 서비스 시작

$ brew services start mongodb-community@4.2
==> Successfully started `mongodb-community@4.2` (label: homebrew.mxcl.mongodb-community@4.2)

8. 서비스 목록 확인

$ brew services list

9. 서비스 종료

$ brew services stop mongodb-community@4.2

 

+ Recent posts