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 does linux start mongodb

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly analyzes the relevant knowledge points of linux how to start mongodb, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "how linux starts mongodb".

MongoDB is a distributed file storage database written by C++, which provides a high-performance data storage scheme for Web applications.

Mode one

Ubuntu Editor / etc/rc.local

/ home/wyt/bin/mongodb-linux-x86_64-ubuntu1404-3.2.8/bin/mongod-dbpath=/home/wyt/bin/mongodb/data-logpath=/home/wyt/bin/mongodb/logs-logappend-port=27017-fork

Mode two

/ home/wyt/bin/mongodb-linux-x86_64-ubuntu1404-3.2.8/bin/mongod-config / home/wyt/bin/mongodb.conf

Configuration file content:

Specify database path dbpath = / home/wyt/bin/mongodb/data # specify service port number, default port 27017port = 27017 # set each database will be saved in a separate directory directoryperdb = true # enable authentication (note, later change to true) auth = false # run MongoDB as daemon, create server process fork = true # provide http interface httpinterface = true # specify MongoDB log file Note that the specified file is not a directory logpath = / home/wyt/bin/mongodb/logs # write log logappend = true by appending

Note that the data folder above needs to be created. Logs is a file, not a folder. There is no need to create a logs.

Method 3 (recommended)

The configuration file is the same as in mode 2, copy mongodb to / etc/init.d, copy mongodb.conf to the appropriate place, and then execute

Chmod 777 / etc/init.d/mongodb

Update-rc.d mongodb defaults

Update-rc.d-f mongodb remove

Attachment:

The / etc/init.d/mongodb script is as follows

#! / bin/sh### BEGIN INIT INFO# Provides: mongodb# Required-Start:# Required-Stop:# Default-Start: 23 4 "Default-Stop: 0 1" Short-Description: mongodb# Description: mongodb server### END INIT INFOEXE_FILE=/home/wyt/bin/mongodb-linux-x86_64-ubuntu1404-3.2.9/bin/mongodCONFIG_FILE=/home/wyt/bin/mongodb.conf. / lib/lsb/init-functionsMONGOPID= `ps-ef | grep mongod | grep-v grep | awk'{print $2} '`test-x $EXE_FILE | | exit 0case "$1" in start) ulimit-n 3000 log_begin_msg "Starting MongoDB server" $EXE_FILE-- config $CONFIG_FILE log_end_msg 0;; stop) log_begin_msg "Stopping MongoDB server" if [!-z "$MONGOPID"]; then kill-15$ MONGOPID fi log_end_msg 0 Status) ps-aux | grep mongod; *) log_success_msg "Usage: / etc/init.d/mongodb {start | stop | status}" exit 1esacexit 0 that's all about "how linux starts mongodb". For more information, you can search for previous articles, hoping to help you answer questions and questions. Please support the website!

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