Installationsanleitung Debian GNU/LinuxVorbereitungGrundsaetzlich wird in diesem Dokument von einem Debian GNU/Linux ausgegangen. mongoDB beziehenmongoDB steht sowohl in Binaer-Distributionen als auch in Source-Tarballs zur Verfuegung, Die Binaer-Distributionen lassen sich unter http://www.mongodb.org/display/DOCS/Downloads finden, Herunterladen und entpacken
# cd /tmp/
# wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-0.9.2.tgz
# tar -xzf mongodb-linux-x86_64-0.9.2.tgz
In Zielorder verschieben / Datenordner anlegen
# mv mongodb-linux-x86_64-0.9.2 /opt/mongodb # mkdir /data && mkdir /data/mongodb TestlaufNach diesen Schritten ist mongoDB theoretisch bereits einsetzbar # /opt/mongodb/bin/mongod --dbpath /data/mongodb/ run mongoDB einrichtenmongoDB kommt derzeit von Haus aus ohne Start/Stop Script, jedoch laesst sich dieses relativ einfach erstellen. User anlegenEs bietet sich an einen eigenen User fuer mongodb anzulegen, in diesem Beispiel \"mongod\",
# useradd mongod -s /bin/false
# chown -R mongod:mongod /data/mongodb
Config-FileAls naechstes sollte ein Config-File angelegt werden in dem der User und die fuer den Start noetigen Optionen eingetragen werden, in diesem Beispiel der Pfad zu dem Datenordner. # mkdir /etc/mongodb # cat << EOF > /etc/mongodb/mongodb.conf MONGO_USER="mongod" MONGO_OPTS="--dbpath /data/mongodb/" EOF
Start/Stop-ScriptDas eigentliche Start/Stop Script sollte unter /etc/init.d/mongodb erzeugt und ausfuehrbar gemacht werden:
# cat << EOF > /etc/init.d/mongodb #! /bin/sh # start / stop script for mongodb ### BEGIN INIT INFO # Provides: mongod # Required-Start: \$remote_fs \$syslog # Required-Stop: \$remote_fs \$syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start mongod at boot time # Description: Enable service provided by mongod. ### END INIT INFO # Source function library. . /lib/lsb/init-functions retval=0 pidfile=/var/run/mongodb.pid exec="/opt/mongodb/bin/mongod" prog="mongod" config="/etc/mongodb/mongodb.conf" lockfile="/var/lock/mongod" [ -e \$config ] && . \$config start() { if [ ! -x \$exec ] then echo \$exec not found exit 5 fi log_daemon_msg "Starting mongoDB daemon" log_progress_msg \$prog start-stop-daemon --start --pidfile \$pidfile -m -c \$MONGO_USER \ --exec \$exec -- \$MONGO_OPTS run > /dev/null 2>&1 & retval=$? if [ \$retval -eq 0 ] then log_end_msg 0 else log_end_msg 1 fi return \$retval } stop() { log_daemon_msg "Stopping mongoDB daemon" log_progress_msg \$prog start-stop-daemon --stop --pidfile \$pidfile --retry 10 \ --exec \$exec retval=$? if [ \$retval -eq 0 ] && rm -f \$lockfile then log_end_msg 0 else log_end_msg 1 fi rm -f \$pidfile return \$retval } restart() { stop start } reload() { restart } # See how we were called. case "\$1" in start) \$1 ;; stop) \$1 ;; restart) \$1 ;; reload) \$1 ;; *) echo "Usage: \$0 {start|stop|status|restart|reload}" exit 2 esac exit \$? EOF # chmod +x /etc/init.d/mongodb Der mongoDB daemon kann nun mit # /etc/init.d/mongodb start gestartet und mit # /etc/init.d/mongodb stop beendet werden.
# update-rc.d mongodb defaults Weitere Informationen |

IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.
These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group. blog comments powered by Disqus