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