Linux installation MongoDB tar join service and boot up __linux

Source: Internet
Author: User
Tags gz file mongodb mongodb server

Download MongoDB's tar packets and I'll put them in the/home directory.

Execute command

Cd/home
tar zxvf your mongodb.tar.gz file.

Then change the folder name to MongoDB to facilitate later operation

MV Your mongodb.tar.gz file MongoDB

Create a new data directory under the/home/mongodb/directory

Then execute the command to start the MongoDB service

Cd/home/mongodb/bin
./mongodb--dbpath/home/mongodb/data--logpath/home/mongodb/log

Finally join the boot service

Create a new MongoDB file under/etc/init.d/write script

To create a new file under Linux copy it or it will be formatted incorrectly. Cannot execute filename remove suffix

If your MongoDB directory is not the same as above, you need to modify the directory inside the script


#!/bin/sh

### BEGIN INIT INFO  
# provides:     MongoDB  
# required-start: #  
Required-stop:  
# Default-start:        2 3 4 5  
# Default-stop:         0 1 6  
# short-description:mongodb  
# Description:mongo DB ser Ver  
### End INIT INFO  
   
./lib/lsb/init-functions  
   
program=/home/mongodb/bin/mongod
mongopid= ' PS- EF | grep ' Mongod ' | Grep-v grep | awk ' {print $} '
   
Test-x $PROGRAM | | Exit 0 Case  
   
"  
  ulimit-n"  
     3000  
     log_begin_msg "St arting MongoDB Server "   
     $PROGRAM--fork--quiet--dbpath/home/mongodb/data--logpath/home/mongodb/log
     log_ End_msg 0  
     ;;  
  Stop)  
     log_begin_msg "stopping MongoDB Server"   
     if [!-Z "$MONGOPID"]; then   
        kill-15 $MONGOPID  
     fi
  log_end_msg 0  
     ;;  
  status)  
     ;;  
  *)  
     log_success_msg "Usage:/etc/init.d/mongodb {start|stop|status}"   
     exit 1  
Esac  
   
exit 0

Execute the command again to execute MongoDB this script

chmod +x/etc/init.d/mongodb

Then register for boot execution

UPDATE-RC.D MongoDB Defaults

Delete Service Use this command

Update-rc.d-f MongoDB Remove


The whole process is over.

You can use this command to open a service

Service MongoDB Start

You can end the service with this command

Service MongoDB Stop



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.