Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between pidfilepath and mongod.lock of mongod command

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "what is the difference between the pidfilepath of mongod command and mongod.lock". In daily operation, I believe many people have doubts about what is the difference between the pidfilepath of mongod command and mongod.lock. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to answer your doubts about "what is the difference between the pidfilepath of mongod command and mongod.lock" Next, please follow the small series to learn together!

--fork

fork=true

fork server process

fork means to run in background process mode, and generate a process number for this background process. If fork is not enabled, the mongod command runs in front mode, and the mongod command exits the process.

Fork is not enabled, and when ctrl+c is cancelled, the mongodb process exits

[mongodb@zabbixtest1 mongodb]$ cat /mongodb/mongodb33333.conf |grep fork

#fork=true

[mongodb@zabbixtest1 mongodb]$ mongod -f /mongodb/mongodb33333.conf

^C[mongodb@zabbixtest1 mongodb]$

Enabling fork, running in background process mode, produces a background process number of 9330

[mongodb@zabbixtest1 mongodb]$ cat /mongodb/mongodb33333.conf |grep fork

fork=true

[mongodb@zabbixtest1 mongodb]$ mongod -f /mongodb/mongodb33333.conf

about to fork child process, waiting until server is ready for connections.

forked process: 9330

child process started successfully, parent exiting

[mongodb@zabbixtest1 mongodb]$

-f equals--config

specify a profile

configuration file specifying additional options

verbose

verbose=true

vvv

vvv=true

quiet

quiet=true

The log level of mongodb is determined by the verbose and quiet parameters

By default, mongodb log files are very large, and a large number of debugging information such as connections will be recorded every second. You need to modify its default log level. verbose means debug information will be printed, vvv means verbose verbose information, there are vv-vv, the more v the log information recorded is more detailed.

If the quiet=true parameter is set, it means that the output will be quiet, that is, there will be no debug information, and only some key information will be printed in the log, such as automatic failover, system errors and other information, equivalent to error log. You need to comment out the verbose parameter.

--pidfilepath

pidfilepath=/mongodb/mongodb27001.pid

Specify a file location to hold the process ID of the mongod process where mongod will write its PID. This is useful for tracking mongod progress with the--fork option. If the--pidfilepath option is not specified, the process will not create PID files.

If pidfilepath parameter is not added to the configuration file, the process number will pop up when starting. The only difference is that after adding pidfilepath, there will be an extra file to store this pid. If not, mongod.lock file will also store pid. However, after mongod --shutdown, the contents of mongod.lock file will be empty, while the contents of the corresponding file of pidfilepath are still there.

In fact, if you don't add the pidfilepath parameter, because ps can still see the pid process number.

[mongodb@zabbixtest1 ~]$ ps -ef|grep mongo

mongodb 28572 1 1 23:07 ? 00:00:01 mongod -f /mongodb/mongodb.conf

--pidfilepath differs from mongod.lock file

1. The corresponding file of pidfilepath stores pid file, and the mongod.lock file also stores pid file.

2. If the--pidfilepath parameter is added, there will be both the corresponding file of pidfilepath and the mongod.lock file.

3, do not add--pidfilepath parameter, only mongod.lock file

4. After mongod --shutdown, the contents of mongod.lock file will be emptied, while the contents of pidfilepath corresponding file are still in

5. After mongod is started, the corresponding file of pidfilepath will clear the pid corresponding to the last startup and regenerate the pid of this startup.

At this point, the study of "what is the difference between pidfilepath and mongod.lock of mongod command" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report