[NodeJS] 맥북에 MongoDB 설치하기
OSX에 Homebrew를 이용하여 MongoDB를 설치해보자
1. Homebrew 설치
MongoDB를 설치하기에 앞서 OSX 용 패키지 관리자인 Homebrew를 설치한다.
Homebrew는 설치되는 패키지들을 기본적으로 usr/local/Cellar 디렉토리에서 관리하는데, 설정 시 개별적으로 찾아볼 필요가 없어 상당히 편리하다.
터미널에서 ruby와 curl을 이용해 설치를 진행할 수 있다.
https://brew.sh/index_ko.html 에 접속하여 아래와 같은 명령어를 확인 후 터미널에 입력한다.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
아래와 같이 출력되면서 Homebrew 설치파일 다운로드 후, 설치된다.
brew -v 명령어로 설치된 버전을 확인할 수 있다.
==> Downloading and installing Homebrew... Already up-to-date. ==> Installation successful! ==> Homebrew has enabled anonymous aggregate user behaviour analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics.html ==> Next steps: - Run `brew help` to get started - Further documentation: https://docs.brew.sh |
2. MongoDB 설치
이어서 터미널에 아래 명령어를 입력하여 MongoDB를 다운로드 및 설치한다.
brew install mongodb
==> Installing dependencies for mongodb: openssl ==> Installing mongodb dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2m.sierra.bottl ######################################################################## 100.0% ==> Summary 🍺 /usr/local/Cellar/openssl/1.0.2m: 1,792 files, 12.3MB ==> Installing mongodb ==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.4.10.sierra.bottl ######################################################################## 100.0% ==> Pouring mongodb-3.4.10.sierra.bottle.tar.gz ==> Caveats To have launchd start mongodb now and restart at login: brew services start mongodb Or, if you don't want/need a background service you can just run: mongod --config /usr/local/etc/mongod.conf ==> Summary 🍺 /usr/local/Cellar/mongodb/3.4.10: 19 files, 287.8MB |
3. data 폴더 생성 및 설정
MongoDB는 /data/db 에 데이터베이스를 저장하므로 아래와 같이 폴더를 생성한다.
/data/db 폴더 생성
sudo mkdir -p /data/db
/data/db 폴더에 USER 권한 설정
sudo chown [USERNAME] /data/db
4. mongoDB 서버 실행
설치가 끝났으니 서버를 실행해보자.
mongod
위 명령어를 입력하면, MongoDB 서버가 실행된다.
아래같은 WARNING 메시지가 나온다.
** WARNING: Access control is not enabled for the database. ** Read and write access to data and configuration is unrestricted. ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 |
5. mongoDB 실행
mongo 명령어를 입력하면 mongodb를 실행한다.
mongo
정상적으로 실행되며, 버전 및 정보가 표기된다.
MongoDB shell version v3.4.10 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.10 Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user |
Server has startup warnings: ** WARNING: Access control is not enabled for the database. ** Read and write access to data and configuration is unrestricted. ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 |
WARNING이 뜨긴 하는데, 실행에는 지장 없다.
자세한 내용은 구글링이 필요할듯 싶다.
mongoDB 설치 끝 !