Installation and usage

Feedback


 

Software environment

Operating system

MongoDB service can be run on Linux, Windows or Mac OS X platform, supporting 32 bit and 64 bit system. Default port is 27017. MongoDB store data to file (Linux default path is /data/db, Windows default path is C:\data\db). To improve efficiency, use memory mapping file to manage.

Software version

MongoDB version should be 2.6, 3.x.

Install MongoDB on Windows System

MongoDB is an easy-use product. MongoDB data storage default location is C:\data\db. If you don't use the default location, create the data storage location before starting the service. For example, create D:\mongodb\data\db as the storage location.

Start service

In bin folder of MongoDB, execute the mongod order to start the service:

mongod.exe --dbpath D:\mongodb\data\db --port 27010

"--dbpath" and "–-port" are the optional parameters, used to specify the storage path and port. Default storage location is C:\data\db, and port number is 27017.

Prompt information is waiting for connections.

Stop service

  1. Execute Ctrl+C to close the service.
  2. If the MongoDB service has been registered as Windows system services. Execute the stop order to stop the service. If the stop name is system service of MongoDB:

net stop MongoDB

Register MongoDB to windows system service

  1. In bin folder of MongoDB, execute the following order to register as Windows system services:

mongod.exe --dbpath D:\mongodb\data\db --install -logpath D:\mongodb\log --serviceName  MongoDB

" --logpath" is used to specify the storage path of log. "--serviceName" is used to set the registered service name.

  1. Start the service after registered successfully. Run the following orders:

net start MongoDB    

net stop MongoDB     

  1. Run the following orders to delete the registered Windows system services:

mongod.exe --dbpath "D:\mongodb\data\db" --remove --serviceName "MongoDB"

Install MongoDB on Linux System

On Linux, MongoDB can be used directly after compressing.

  1. Run the following orders to compress the product package:

tar -zxf mongodb-xxxxxxx.tgz

  1. MongoDB data storage default location is /data/db. If you don't use the default location, create the data storage location before starting the service. For example, create /data/db as the storage location.

mkdir /data

mkdir /data/db

Start service

Start the MongoDB service as the root user identity. If you use the default storage location and port, execute the following orders:

./mongodb-xxxxxxx/bin/mongod

Prompt information is waiting for connections.

Stop service

There are three types to stop the MongoDB service:

mongod --shutdown --dbpath /database/mongodb/data/

ps -ef | grep mongo  

kill -2 {PID}

Use MongoDB

After starting the service, the prompt info is waiting for connections.

Connect service through client

You can verify the service through MongoDB client. Open cmd.exe to run the following orders:

mongo.exe --host localhost --port 27010

“--host” assigns the existing MongoDB service address, “--port” assigns the started port.

Creating database

You could create a database to store map tile specially.

use sampledb

now the database: sampledb has been created, but it is not existed in the database list, you should insert at least one gather in the list

db.tile.insert({'name':'map'})

After finishing, you could check database in MongoDB by orders below:

show dbs

hecking the currently used database:

db

you could also check all gathers in one database:

show collections

When you add tile bases in the distributed map cutting service, if not assigning, iServer will create a database named smtiles and save the tile.

Creating account

To ensure the security of the database you use, you should set the user name and password for this database, Visiting will be permitted after verifying, take the sampledb database for example:

use sampledb

Create user and set user name and password.

db.addUser({user:"user1",pwd:"password",roles:["readWrite","dbAdmin"]})

then, restart MongoDB to open access control in the safety mode, you need add --auth, e.g.:

mongod.exe --dbpath D:\mongodb\data\db --auth --port 27010

After executing order above, all the database in D:\mongodb\data\db will started the safety control, when you access or use database under this directory, you will input the set user name and password to connect.

Note: if you don't open access control, user account is not started, database is still in condition of anonymity.