수색…


분리 된 데이터베이스 (MONGO_URL)로 응용 프로그램 배포

응용 프로그램 계층을 데이터베이스 계층과 분리해야하므로 MONGO_URL을 지정해야합니다. 즉 번들 명령을 통해 앱을 실행하고 압축을 풀고 환경 변수를 설정 한 다음 프로젝트를 노드 앱으로 실행한다는 의미입니다. 방법은 다음과 같습니다.

#make sure you're running the node v0.10.21 or later
npm cache clean -f
npm install -g n
sudo n 0.10.21

# bundle the app
mkdir myapp
cd myapp 
git clone http://github.com/myaccount/myapp
meteor bundle --directory ../deployPath
cd ../deployPath

# make sure fibers is installed, as per the README
export MONGO_URL='mongodb://127.0.0.1:27017/mydatabase'
export PORT='3000'
export ROOT_URL='http://myapp.com'

# run the site
node main.js

복제 세트 설정

그런 다음 mongo 셸로 이동하여 다음과 같이 복제 세트를 시작합니다.

mongo

> rs.initiate()
PRIMARY> rs.add("mongo-a")
PRIMARY> rs.add("mongo-b")
PRIMARY> rs.add("mongo-c")
PRIMARY> rs.setReadPref('secondaryPreferred')

Oplogging을 사용하도록 복제 세트 구성

복제 세트는 데이터베이스에 액세스하기 위해 oplog 사용자가 필요합니다.

mongo

PRIMARY> use admin
PRIMARY> db.addUser({user:"oplogger",pwd:"YOUR_PASSWORD",roles:[],otherDBRoles:{local:["read"]}});
PRIMARY> show users

Upstart Script Oplog

복제본 세트의 여러 IP 주소를 사용하려면 시작 스크립트를 수정해야합니다.

start on started mountall
stop on shutdown

respawn
respawn limit 99 5

script
    # our example assumes you're using a replica set and/or oplog integreation
    export MONGO_URL='mongodb://mongo-a:27017,mongo-b:27017,mongo-c:27017/meteor'

    # here we configure our OPLOG URL
    export MONGO_OPLOG_URL='mongodb://oplogger:YOUR_PASSWORD@mongo-a:27017,mongo-b:27017,mongo-c:27017/local?authSource=admin'

    # root_url and port are the other two important environment variables to set
    export ROOT_URL='http://myapp.mydomain.com'
    export PORT='80'

    exec /usr/local/bin/node /var/www/production/main.js >> /var/log/node.log 2>&1
end script

샤딩

Sharded Mongo에서의 Oplog Tailing



Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow