Mongodb參數說明

來源:互聯網
上載者:User
Mongodb啟動命令mongod參數說明

mongod的主要參數有:

 基本配置

--------------------------------------------------------------------------------

--quiet # 安靜輸出
--port arg # 指定服務連接埠號碼,預設連接埠27017
--bind_ip arg # 綁定服務IP,若綁定127.0.0.1,則只能本機訪問,不指定預設本地所有IP
--logpath arg # 指定MongoDB記錄檔,注意是指定檔案不是目錄
--logappend # 使用追加的方式寫日誌
--pidfilepath arg # PID File 的完整路徑,如果沒有設定,則沒有PID檔案
--keyFile arg # 叢集的私密金鑰的完整路徑,只對於Replica Set 架構有效
--unixSocketPrefix arg # UNIX域通訊端替代目錄,(預設為 /tmp)
--fork # 以守護進程的方式運行MongoDB,建立伺服器處理序
--auth # 啟用驗證
--cpu # 定期顯示CPU的CPU利用率和iowait
--dbpath arg # 指定資料庫路徑
--diaglog arg # diaglog選項 0=off 1=W 2=R 3=both 7=W+some reads
--directoryperdb # 設定每個資料庫將被儲存在一個單獨的目錄
--journal # 啟用日誌選項,MongoDB的資料操作將會寫入到journal檔案夾的檔案裡
--journalOptions arg # 啟用日誌診斷選項
--ipv6 # 啟用IPv6選項
--jsonp # 允許JSONP形式通過HTTP訪問(有安全影響)
--maxConns arg # 最大同時串連數 預設2000
--noauth # 不啟用驗證
--nohttpinterface # 關閉http介面,預設關閉27018連接埠訪問
--noprealloc # 禁用資料檔案預分配(往往影響效能)
--noscripting # 禁用指令碼引擎
--notablescan # 不允許表掃描
--nounixsocket # 禁用Unix通訊端監聽
--nssize arg (=16) # 設定信資料庫.ns檔案大小(MB)
--objcheck # 在收到客戶資料,檢查的有效性,
--profile arg # 檔案參數 0=off 1=slow, 2=all
--quota # 限制每個資料庫的檔案數,設定預設為8
--quotaFiles arg # number of files allower per db, requires --quota
--rest # 開啟簡單的rest API
--repair # 修複所有資料庫run repair on all dbs
--repairpath arg # 修複庫產生的檔案的目錄,預設為目錄名稱dbpath
--slowms arg (=100) # value of slow for profile and console log
--smallfiles # 使用較小的預設檔案
--syncdelay arg (=60) # 資料寫入磁碟的時間秒數(0=never,不推薦)
--sysinfo # 列印一些診斷系統資訊
--upgrade # 如果需要升級資料庫
 * Replicaton 參數

--------------------------------------------------------------------------------

--fastsync # 從一個dbpath裡啟用從庫複製服務,該dbpath的資料庫是主庫的快照,可用於快速啟用同步
--autoresync # 如果從庫與主庫同步資料差得多,自動重新同步,
--oplogSize arg # 設定oplog的大小(MB)
 * 主/從參數

--------------------------------------------------------------------------------

--master # 主庫模式
--slave # 從庫模式
--source arg # 從庫 連接埠號碼
--only arg # 指定單一的資料庫複寫
--slavedelay arg # 設定從庫同步主庫的延遲時間
 * Replica set(複本集)選項:

--------------------------------------------------------------------------------

--replSet arg # 設定複本集名稱
 * Sharding(分區)選項

--------------------------------------------------------------------------------
--configsvr # 聲明這是一個叢集的config服務,預設連接埠27019,預設目錄/data/configdb
--shardsvr # 聲明這是一個叢集的分區,預設連接埠27018
--noMoveParanoia # 關閉偏執為moveChunk資料儲存

# 上述參數都可以寫入 mongod.conf 配置文檔裡例如:

dbpath = /data/mongodb
logpath = /data/mongodb/mongodb.log
logappend = true
port = 27017
fork = true
auth = true
 

e.g:./mongod -shardsvr -replSet shard1 -port 16161 -dbpath /data/mongodb/data/shard1a -oplogSize 100 -logpath /data/mongodb/logs/shard1a.log -logappend -fork -rest



mongod Synopsis

mongod is the primary daemon process for the MongoDBsystem. It handles data requests, manages data format, and performsbackground management operations.

This document provides a complete overview of all command line optionsfor mongod. These options are primarily useful for testingpurposes. In common operation, use theconfiguration fileoptions to control the behavior ofyour database, which is fully capable of all operations describedbelow. Options Core Options mongod
--help , -h

Returns information on the options and use of mongod. --version

Returns the mongod release number. --config <filename> , -f

Specifies a configuration file for runtime configuration options. Theconfiguration file is the preferred method for runtime configuration ofmongod. The options are equivalent to the command-lineconfiguration options. See Configuration File Options formore information.

Ensure the configuration file uses ASCII encoding. The mongodinstance does not support configuration files with non-ASCII encoding,including UTF-8. --verbose , -v

Increases the amount of internal reporting returned on standard outputor in log files. Increase the verbosity with the-v form byincluding the option multiple times, (e.g.-vvvvv.) --quiet

Runs the mongod in a quiet mode that attempts to limit the amountof output. This option suppresses: output from database commands replication activity connection accepted events connection closed events --port <port>

Default: 27017

Specifies the TCP port on which the MongoDB instance listens forclient connections. --bind_ip <ip address>

Default: All interfaces. .. versionchanged:: 2.6.0 The deb andrpm packages include a default configuration file that sets{{role}} to127.0.0.1.

Specifies the IP address that mongod binds to in order to listenfor connections from applications. You may attachmongod to anyinterface. When attachingmongod to a publicly accessibleinterface, ensure that you have implemented proper authentication andfirewall restrictions to protect the integrity of your database. --maxConns <number>

The maximum number of simultaneous connections that mongod willaccept. This setting has no effect if it is higher than your operatingsystem’s configured maximum connection tracking threshold.

Changed in version 2.6: MongoDB removed the upward limit on themaxIncomingConnections setting. --syslog

Sends all logging output to the host’s syslog system ratherthan to standard output or to a log file. , as with--logpath.

The --syslog option is not supported on Windows. --syslogFacility <string>

Default: user

Specifies the facility level used when logging messages to syslog.The value you specify must be supported by youroperating system’s implementation of syslog. To use this option, youmust enable the--syslog option. --logpath <path>

Sends all diagnostic logging information to a log file instead of tostandard output or to the host’ssyslog system. MongoDB createsthe log file at the path you specify.

By default, MongoDB overwrites the log file when the process restarts.To instead append to the log file, set the--logappend option. --logappend

Appends new entries to the end of the log file rather than overwritingthe content of the log when themongod instance restarts. --timeStampFormat <string>

Default: iso8601-local

The time format for timestamps in log messages. Specify one of thefollowing values:

Value Description
ctime Displays timestamps as WedDec 3118:17:54.811.
iso8601-utc Displays timestamps in Coordinated Universal Time (UTC) in theISO-8601 format. For example, for New York at the start of theEpoch:1970-01-01T00:00:00.000Z
iso8601-local Displays timestamps in local time in the ISO-8601format. For example, for New York at the start of the Epoch:1969-12-31T19:00:00.000+0500
--diaglog <value>

Default: 0

Deprecated since version 2.6.

--diaglog is for internal use and not intended for most users.

Creates a very verbose diagnostic log for troubleshooting andrecording various errors. MongoDB writes these log files in thedbPath directory in a series of files that begin with thestring diaglog and end with the initiation time of the logging as ahex string.

The specified value configures the level of verbosity:

Value Setting
0 Off. No logging.
1 Log write operations.
2 Log read operations.
3 Log both read and write operations.
7 Log write and some read operations.

You can use the mongosniff tool to replay this output forinvestigation. Given a typical diaglog file located at/data/db/diaglog.4f76a58c, you might use a command in the followingform to read these files:

  mongosniff --source DIAGLOG /data/db/diaglog.4f76a58c.. warning::   Setting the diagnostic level to ``0`` will cause :program:`mongod`   to stop writing data to the :term:`diagnostic log` file. However,   the :program:`mongod` instance will continue to keep the file open,   even if it is no longer writing data to the file. If you want to   rename, move, or delete the diagnostic log you must cleanly shut   down the :program:`mongod` instance before doing so.
--traceExceptions

For internal diagnostic use only. --pidfilepath <path>

Specifies a file location to hold the process ID of the mongodprocess. This is useful for tracking the mongod process incombination with the --fork option. Without a specified--pidfilepath option, the process creates no PID file. --keyFile <file>

Specifies the path to a key file to that stores the shared secretthat MongoDB processes use to authenticate to each other in asharded cluster or replica set.--keyFile implies--auth. See Authentication Between MongoDB Instances for moreinformation. --setParameter <options>

Specifies one of the MongoDB parameters described inMongoDB Server Parameters. You can specify multiplesetParameterfields. --httpinterface

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.