1、從官網下載最新的mongodb,選擇Linux,再根據自己原生linux系統選擇相應的版本。
2、解壓下載的mongodb的tar包
解壓之後主要的運行指令碼都在bin目錄中,建立軟連結:ln -s /usr/soft/mongodb/bin/* /usr/local/bin。這樣就可以直接使用mongo的各種命令
3、運行mongo
建立資料檔案夾db、記錄檔夾logs、設定檔夾conf
建立三個指令檔:startMongo.sh、stopMongo.sh、mongoStat.sh
(1)startMongo.sh 啟動mongo指令碼
/usr/soft/mongodb/bin/mongod -f /usr/soft/mongodb/conf/mongodb_27021.conf --jour nal
(2)stopMongo.sh 停止mongo指令碼
/usr/soft/mongodb/bin/mongod -f /usr/soft/mongodb/conf/mongodb_27021.conf --shut
down
(3)mongoStat.sh 每隔10秒鐘查看一次mongo狀態
./mongostat --port 27021 10
4、附上mongodb_27021.conf的配置內容
# mongo.conf
#where to log logpath=/usr/soft/mongodb/logs/mongo_27021.log
logappend=true
# fork and run in background fork = true
port = 27021 # dbpath=/var/lib/mongo
dbpath=/usr/soft/mongodb/db/
# Disables write-ahead journaling
# Enables periodic logging of CPU utilization and I/O wait #cpu = true
# Turn on/off security. Off is currently the default noauth = true #auth = true
# Verbose logging output. #verbose = true
# Inspect all client data for validity on receipt (useful for # developing drivers) #objcheck = true
# Enable db quota management #quota = true
# Set oplogging level where n is # 0=off (default) # 1=W # 2=R # 3=both # 7=W+some reads
# Ignore query hints #nohints = true
# Disable the HTTP interface (Defaults to localhost:27018). #nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited # functionality #noscripting = true
# Turns off table scans. Any query that would do a table scan fails. #notablescan = true
# Disable data file preallocation. #noprealloc = true
# Specify .ns file size for new databases. # nssize =
# Accout token for Mongo monitoring server. #mms-token =
# Server name for Mongo monitoring server. #mms-name =
# Ping interval for Mongo monitoring server. #mms-interval =
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master #slave = true #source = master.example.com # Slave only: specify a single database to replicate #only = master.example.com # or #master = true #source = slave.example.com #rest = true |
轉載來源:http://www.16boke.com/article/detail/37