Übersicht
MongoDB is fast, document-oriented NoSQL server. It’s complementary to key-value cache stores like Redis or Memcached and is suitable when necessary. It is available on newer platforms (v6+) without any additional compilation from source. Accounts with terminal access are eligible to use MongoDB.
Schnellstart
- From the Terminal, first create a directory to store MongoDB data:
- 
mkdir ~/mongodb- A directory named mongodbwithin your home directory will be created. If the user logged is in namedexample, then a directory named/home/example/mongodbwill be created
 
- A directory named 
 
- 
- Now start the server. Substitute PORT for a preassigned port for your account:
- mongod --bind_ip 127.0.0.1 --port PORT --dbpath ~/mongodb --logpath ~/mongo.log --pidfilepath ~/mongodb.pid --fork
- MongoDB is now running, accessible by a local TCP/IP socket bound to port PORT.
 
Hinweis: use 127.0.0.1 to prevent outside network activity. 127.0.0.1 will only allow traffic that originates from the same server. A better solution, if using Node.js oder Schiene application, is to specify --unixSocketPrefix /tmp/mongodb.sock anstelle von --bind_ip/--port to specify a local UNIX domain socket instead of a TCP socket.
Configuring & Daemonizing
Now with MongoDB up and running, you can create a long-term solution that starts up with the server and always runs in the background. Start with the configuration template provided above, making sure to update the port parameter to a port assigned to your account.
Note: as with most configuration files, any line that begins with a octothorpe/pound/hash symbol (#) denotes a comment. These are never interpreted by an application, but serve as guidance. The following configuration omits these helpful comments for brevity.
Copy and paste the following content to a file named mongodb.conf in your home directory:
bind_ip = 127.0.0.1 ############ # Substitute with a PORT assigned to your account ############ port = PORT # run as a service fork = true ############ # Substitute /home/example for your HOME DIRECTORY ############ pidfilepath = /home/example/mongod.pid logpath = /home/example/mongodb.log dbpath = /home/example/mongodb journal = true nohttpinterface = true
A quick and easy way to do this is with Vim, a text-editor available through the terminal:
- vim ~/mongodb.conf
- Type ion the keyboard to switch to “Insert” mode- Depending upon client, paste the text through CTRL + V, Shift + INS, or a suitable key combination
 
- Hit the Esc(ape) key.
- Type :wq
- Done!
Now to start MongoDB using the configuration, type: mongod -f ~/mongodb.conf
Starting on Start-up
- Visit Dev > Task Scheduler innerhalb der Bedienfeld to schedule a new task.
- Under Command, enter mongodb ~/mongodb.conf
- Under Scheduling, select Server Start
- Click Add
Siehe auch
- MongoDB Dokumentation
- The Little MongoDB Book