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

How to start mongodb service under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to start mongodb service under Linux", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to start mongodb service under Linux" article.

Start command

The copy code is as follows:

/ usr/local/mongodb/bin/mongod-dbpath=/usr/local/mongodb/data/-logpath=/data/mongodb.log-logappend &

I see! Because he does not start with nohup, as long as his terminal is offline or closed, mongodb will automatically exit! The solution is simple, just start it as follows:

The copy code is as follows:

Nohup / usr/local/mongodb/bin/mongod-- dbpath=/usr/local/mongodb/data/-- logpath=/data/mongodb.log-- logappend > / dev/null 2 > & 1 &

Mongodb service script:

#! / bin/sh##mongod-startup script for mongod## chkconfig:-85 "description: mongodb database.# processname: mongod# source function library. / etc/rc.d/init.d/functions# things from mongod.conf get there by mongod reading it# optionsoptions= "- dbpath=/home/data/mongodb/-logpath=/home/data/mongodb/mongodb.log-logappend &" # mongodmongod= "/ usr/local/mongodb/bin/mongod" lockfile=/var/lock/subsys/mongodstart () {echo-n $"starting mongod:" daemon $mongod $options retval=$? Echo [$retval-eq 0] & & touch $lockfile} stop () {echo-n $"stopping mongod:" killproc $mongod-quit retval=$? Echo [$retval-eq 0] & & rm-f $lockfile} restart () {stop start} ulimit-n 12000retval=0 case "$1" in start) start;; stop) stop;; restart | reload | force-reload) restart;; condrestart) [- f $lockfile] & restart | |:; status) status $mongod retval=$?;; *) echo "usage: $0 {start | stop | status | restart | reload | force-reload | condrestart}" retval=1esacexit $retval

Save the code to / etc/init.d/mongodb, and then use chmod + x / etc/init.d/mongodb to add execute permissions.

Now you can use the service command to control mongodb:

The copy code is as follows:

Service mongodb start | stop | restart

# or

/ etc/init.d/mongodb start | stop | restart

The above is about the content of this article on "how to start mongodb Services under Linux". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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

Development

Wechat

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

12
Report