Getting started with mongodb-installing mongodb on 1 windows

Source: Internet
Author: User
Tags install mongodb mongodb client unix domain socket
Getting started with mongodb-installing mongodb on 1 windows has long wanted to learn nosql, but I have never learned it. I haven't learned many things in recent time, so I just learned it myself. write a blog and take notes. if you don't want to introduce mongodb, go to Baidu. the introduction above on Baidu is very detailed, much better than I said. as for its advantages and disadvantages, we should first remember that it may be appropriate after it is used.

Mongodb entry-1 installing mongodb on windows has long wanted to learn nosql, but I have never learned it. I haven't learned many things in recent years. I just learned it myself. write a blog and take notes. if you don't want to introduce mongodb, go to Baidu. the introduction above on Baidu is very detailed, much better than I said. as for its advantages and disadvantages, we should first remember that it may be appropriate after it is used.

Mongodb entry-1 install mongodb on windows

I wanted to learn nosql for a long time, but I have never studied it. I haven't learned many things recently. I just learned it myself. write a blog and take notes.

If you don't want to introduce mongodb, go to Baidu. the introduction above on Baidu is very detailed, much better than I said. as for its advantages and disadvantages, we should first remember that we may understand it later.

When using mongodb, first download a copy of mongodb from the mongodb official website, which is a mirror.

For ease of use, we recommend that you configure the bin to the environment variable of path. When using these commands, you do not need to use this command every time you use an absolute path. as for the commands in the bin folder, we will only introduce two mongod and mongo commands.

Mongod is the command to start the mongodb database. This command has many configuration parameters. We can enter cmd, enter mongod-h to view the functions of each parameter (assuming that you have added the bin directory to the path environment variable ). Many people may not understand English. I have found a translation on the internet as follows:

[Html]

-- Quiet # quiet output

-- Port arg # specifies the service port number. The default port is 27017.

-- Bind_ip arg # bind the service IP address. If it is bound to 127.0.0.1, it can only be accessed from the local machine without specifying all the default local IP addresses.

-- Logpath arg # specify the MongoDB log file. Note that the specified file is not a directory.

-- Logappend # Use APPEND to write logs

-- Pidfilepath arg # The complete path of the PID File. If no PID File is set, no PID File exists.

-- KeyFile arg # full path of the Cluster's private key, only valid for the Replica Set architecture

-- UnixSocketPrefix arg # UNIX domain socket replacement directory (/tmp by default)

-- Fork # Run MongoDB as a daemon and create a server process

-- Auth # enable verification

-- Cpu # periodically displays CPU utilization and iowait

-- Dbpath arg # specify the database path

-- Diaglog arg # diaglog option 0 = off 1 = W 2 = R 3 = both 7 = W + some reads

-- Directoryperdb # Set that each database will be saved in a separate directory

-- Journal # enable the log option. MongoDB data operations will be written to the files in the journal folder.

-- JournalOptions arg # enable log diagnostic options

-- Ipv6 # enable IPv6

-- Jsonp # Allow access through http in the jsonp format (with security impact)

-- MaxConns arg # maximum number of simultaneous connections: 2000 by default

-- Noauth # do not enable verification

-- Nohttpinterface # disable http interface. Access from Port 27018 is disabled by default.

-- Noprealloc # disable data file pre-allocation (which often affects performance)

-- Noscripting # disable the Script Engine

-- Notablescan # Table scan not allowed

-- Nounixsocket # disable Unix socket listening

-- Nssize arg (= 16) # Set the file size of the database. ns (MB)

-- Objcheck # check the validity of the received customer data,

-- Profile arg # file parameter 0 = off 1 = slow, 2 = all

-- Quota # limit the number of files in each database. The default value is 8.

-- QuotaFiles arg # number of files allower per db, requires -- quota

-- Rest # enable simple rest APIs

-- Repair # Fix all databases run repair on all dbs

-- Repairpath arg # Fix the directory of the file generated by the database. The default directory name is dbpath.

-- Slowms arg (= 100) # value of slow for profile and console log

-- Smallfiles # use small default files

-- Syncdelay arg (= 60) # number of seconds in which data is written to the disk (0 = never, not recommended)

-- Sysinfo # print some diagnostic system information

-- Upgrade # If you need to upgrade the database * Replicaton Parameter

--------------------------------------------------------------------------------

-- Fastsync # enable the slave database replication service from a dbpath. The database in this dbpath is a snapshot of the master database and can be used to quickly enable synchronization.

-- Autoresync # If the data synchronization between the slave database and the master database is much worse, the system automatically synchronizes the data again,

-- OplogSize arg # Set the oplog size (MB) * Master/Slave Parameters

--------------------------------------------------------------------------------

-- Master # master database mode

-- Slave # slave database mode

-- Source arg # slave database port number

-- Only arg # specify a single database copy

-- Slavedelay arg # set the delay time for synchronizing data from the slave database to the master database * Replica set (Replica set) Options:

--------------------------------------------------------------------------------

-- ReplSet arg # Set the replica set name * Sharding Option

--------------------------------------------------------------------------------

-- Configsvr # declares that this is the config service of a cluster. The default port is 27019, and the default directory is/data/configdb.

-- Shardsvr # declares that this is a cluster shard. The default port is 27018.

-- NoMoveParanoia # disable the storage of paranoid moveChunk data

When using the mongod command, you must specify the location where the database files are stored, that is, the -- path parameter must be configured. Here we create a data directory to store database files. After setting up the data directory, we can use the following command to start (my data directory is the same as the bin directory ):

[Html]

Mongod.exe -- dbpath = ../data/db

At this time, we can see the following picture:

Here we can see a port 27017, which represents the mongodb listening port. We will use this port during connection, just like mysql's port 3306. Similarly, we can -- port to modify this port.

There is also a 28017 port, which is a web Service port that mongodb started for us at startup. We can use http: // localhost: 28017/to view some mongodb parameters.

In this way, we have installed and started mongodb. However, it is very troublesome to enter the command in cmd every time. I suggest saving this command to a bat file so that we can click bat to start mongodb directly.

The following describes the mongo command, which is the shell of the mongodb client. Run the mongo command in cmd. The following figure is displayed, indicating that the connection is successful.

By default, we connect to the test database of the Local Machine (127.0.0.1. Similarly, you can set mongo startup parameters. Here I will briefly introduce a few:

[Html]

-- Port: Set the port of the connected mongodb instance.

-- IP address of the mongodb connected to the host

-U Login User

-P logon Password

Install mongodb in windows. If you are interested, try it.

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.