MongoDB upgrade operations

Source: Internet
Author: User
Tags mongodb server mongodump

1. First back up data to another machine

Http://www.mongodb.org/display/DOCS/Backups#Backups-Mongodump

The preceding describes several backup cases.

Non-stop service backup

Service stop backup

This backup is just to prevent it from being simple. It can be backed up when the service is running.

mongodump --host IP -d kaimei -o ~/kaimei_bk

The above command runs on my own computer and MongoDB is also installed. The kaimei database is backed up from the address specified by the IP address to the local directory ~ /Kaimei_bk

In case of an accident, you can use the following command to restore the database.

mongorestore --host IP -d kaimei ~/kaimei_bk/kaimei

2. install a new MongoDB Server

Run the following command on the server:

wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz

Decompress the package and put it in the/usr directory.

3. Modify the Startup Script

The change is small, but the value of program is changed from 2.0.1 to 2.0.4.

#!/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 server### END INIT INFO. /lib/lsb/init-functionsPROGRAM=/usr/mongodb-linux-x86_64-2.0.4/bin/mongodMONGOPID=`ps -ef | grep 'mongod' | grep -v grep | awk '{print $2}'`test -x $PROGRAM || exit 0case "$1" in  start)     ulimit -n 2000     log_begin_msg "Starting MongoDB server"     $PROGRAM --fork --quiet -journal -maxConns=1900 -rest --logpath /data/db/journal/mongdb.log     log_end_msg 0     ;;  stop)     log_begin_msg "Stopping MongoDB server"     if [ ! -z "$MONGOPID" ]; thenkill -15 $MONGOPID     fi     log_end_msg 0     ;;  status)     ;;  *)     log_success_msg "Usage: /etc/init.d/mongodb {start|stop|status}"     exit 1esacexit 0

4. Start and Test

Service MongoDB stop

Service MongoDB start

Restart the server and check again. Everything is OK.

Upgrade successful.

These manual operations should also be automatically executed by scripts.

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.