- MongoDB Cookbook(Second Edition)
- Cyrus Dasadia Amol Nayak
- 318字
- 2021-07-23 14:38:56
Starting a single node instance using command-line options
In this recipe, we will see how to start a standalone single node server with some command-line options. We will see an example where we want to do the following:
- Start the server listening to port
27000
- Logs should be written to
/logs/mongo.log
- The database directory is
/data/mongo/db
As the server has been started for development purposes, we don't want to preallocate full-size database files. (We will soon see what this means.)
Getting ready
If you have already seen and executed the Installing single node MongoDB recipe, you need not do anything different. If all these prerequisites are met, we are good for this recipe.
How to do it…
- The
/data/mongo/db
directory for the database and/logs/
for the logs should be created and present on your filesystem with appropriate permissions to write to it. - Execute the following command:
> mongod --port 27000 --dbpath /data/mongo/db –logpath /logs/mongo.log --smallfiles
How it works…
Ok, this wasn't too difficult and is similar to the previous recipe, but we have some additional command-line options this time around. MongoDB actually supports quite a few options at startup, and we will see a list of the most common and important ones in my opinion:

There's more…
For an exhaustive list of options that are available, use the --help
or -h
option. This list of options is not exhaustive, and we will see some more coming up in later recipes as and when we need them. In the next recipe, we will see how to use a configuration file instead of the command-line arguments.
See also
- Single node installation of MongoDB with options from config file for using configuration files to provide start up options
- Starting multiple instances as part of a replica set to start a replica set
- Starting a simple sharded environment of two shards to set up a sharded environment
- Java逍遙游記
- C#高級(jí)編程(第10版) C# 6 & .NET Core 1.0 (.NET開(kāi)發(fā)經(jīng)典名著)
- 微服務(wù)與事件驅(qū)動(dòng)架構(gòu)
- MATLAB 2020 從入門(mén)到精通
- Mastering Google App Engine
- Mastering ServiceNow(Second Edition)
- C語(yǔ)言課程設(shè)計(jì)
- Scientific Computing with Scala
- ANSYS Fluent 二次開(kāi)發(fā)指南
- Windows Phone 7.5:Building Location-aware Applications
- C#應(yīng)用程序設(shè)計(jì)教程
- Mastering Xamarin.Forms(Second Edition)
- INSTANT Yii 1.1 Application Development Starter
- Spring Boot+MVC實(shí)戰(zhàn)指南
- SpringBoot從零開(kāi)始學(xué)(視頻教學(xué)版)