啟動MongoDB有2種方式,一種是直接默認(rèn)啟動,另一種是指定配置文件。啟動方式如下:
1: /etc/init.d/mongod start 或service mongod start
2: mongod --config /etc/mongodb.conf
下面我們看看配置文件:
vi /etc/mongod.conf
# 日志文件位置
logpath=/var/log/mongo/mongod.log
# 以追加方式寫入日志
logappend=true
# 是否以守護(hù)進(jìn)程方式運(yùn)行
fork = true
# 默認(rèn)27017
#port = 27017
# 數(shù)據(jù)庫文件位置
dbpath=/var/lib/mongo
# 啟用定期記錄CPU利用率和 I/O 等待
#cpu = true
# 是否以安全認(rèn)證方式運(yùn)行,默認(rèn)是不認(rèn)證的非安全方式
#noauth = true
#auth = true
# 詳細(xì)記錄輸出
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)用于開發(fā)驅(qū)動程序時驗(yàn)證客戶端請求
#objcheck = true
# Enable db quota management
# 啟用數(shù)據(jù)庫配額管理
#quota = true
# 設(shè)置oplog記錄等級
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog=0
# Diagnostic/debugging option 動態(tài)調(diào)試項(xiàng)
#nocursors = true
# Ignore query hints 忽略查詢提示
#nohints = true
# 禁用http界面,默認(rèn)為localhost:28017
#nohttpinterface = true
# 關(guān)閉服務(wù)器端腳本,這將極大的限制功能
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# 關(guān)閉掃描表,任何查詢將會是掃描失敗
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# 關(guān)閉數(shù)據(jù)文件預(yù)分配
# Disable data file preallocation.
#noprealloc = true
# 為新數(shù)據(jù)庫指定.ns文件的大小,單位:MB
# Specify .ns file size for new databases.
# nssize = <size>
# Replication Options 復(fù)制選項(xiàng)
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#指定存儲身份驗(yàn)證信息的密鑰文件的路徑
#keyFile=/path/to/keyfile