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.