Brief Introduction to MongoDB (installation)

Source: Internet
Author: User
1. Installation preparation [root @ chendownload] # tarzxvfmongodb-linux-x86_64-2.2.0.tgz [root @ chendownload] # cpmongodb-linux-x86_64-

1. Installation preparation [root @ chen download] # tar zxvf mongodb-linux-x86_64-2.2.0.tgz [root @ chen download] # cp mongodb-linux-x86_64-

1. Installation preparation

[Root @ chen download] # tar zxvf mongodb-linux-x86_64-2.2.0.tgz

[Root @ chen download] # cp mongodb-linux-x86_64-2.2.0/usr/local/mongodb-r

2. Create Database folders and log files

[Root @ chen download] # mkdir/usr/local/mongodb/data

[Root @ chen download] # touch/usr/local/mongodb/logs

Set auto-start

Add the mongodb startup project to rc. local to ensure that mongodb is started when the server is started.

[Root @ chen download] # echo "/usr/local/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data-logpath =/usr/local/mongodb/ logs-logappend -- auth-port = 27017 ">/etc/rc. local

Start mongodb

Cd to the bin folder in the mongodb directory to start mongodb

// The following is the logon method that requires permissions. the user name and password are required for user connection.

[Root @ chen download] #/usr/local/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data -- logpath =/usr/local/mongodb/logs -- logappend -- auth -- port = 27017 -- fork

// No password is required.

[Root @ chen download] #/usr/local/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data -- logpath =/usr/local/mongodb/logs -- logappend -- port = 27017 -- fork

Parameter description: -- dbpath database path (data file)

-- Logpath: Log File Path

-- Master is specified as the master machine.

-- Slave is specified as the slave machine

-- Source: Specifies the IP address of the host.

-- PologSize: the size of the specified log file cannot exceed 64 MB. because resync is very large and time-consuming, it is best to set a large enough oplogSize to avoid resync (the default oplog size is 5% of the idle disk size ).

-- Add at the end of the logappend Log File

-- Port enables the port number

-- Fork runs in the background

-- Only specifies which database to copy

-- Slavedelay indicates the interval between slave replication detection.

-- Does auth need to verify the permission to log on (user name and password)

-H [-- help] show this usage information

-- Version show version information

-F [-- config] arg configuration file specifying additional options

-- Port arg specify port number

-- Bind_ip arg local ip address to bind listener-all local ips

Bound by default

-V [-- verbose] be more verbose (include multiple times for more

Verbosity e.g.-vvvvv)

-- Dbpath arg (=/data/db/) directory for datafiles specifies the data storage directory

-- Quiet quieter output silent mode

-- Logpath arg file to send all output to instead of stdout specifies the log storage directory

-- Logappend appnd to logpath instead of over-writing specifies whether to append or overwrite a log file.

-- Fork server process is run by creating a sub-process

-- Cpu periodically show cpu and iowait utilization periodically displays cpu and io usage

-- Noauth run without security run in No Authentication Mode

-- Auth run with security Authentication Mode

-- Objcheck inspect client data for validity on receipt check the validity of client input data

-- Quota enable db quota management

-- QuotaFiles arg number of files allower per db, requires -- quota specifies the number of files allowed by each database

-- Initialize rvpath arg root directory for the babble app server

-- Nocursors diagnostic/debugging option debug diagnostic options

-- Nohints ignore query hints ignore query hit rate

-- Nohttpinterface disable http interface: disable the http interface. The default value is 28017.

-- Noscripting disable scripting engine shut down the Script engine

-- Noprealloc disable data file preallocation disable database file size pre-allocation

-- Smallfiles use a smaller default file size

-- Nssize arg (= 16). ns file size (in MB) for new databases default size of the ns file in the new database

-- Diaglog arg 0 = off 1 = W 2 = R 3 = both 7 = W + some reads: Read-only, write-only, or read/write, or the primary write + part Read mode

-- Sysinfo print some diagnostic system information print system diagnostic information

-- Upgrade db if needed update the database if necessary

-- Repair run repair on all dbs fix all databases

-- Notablescan do not allow table scans does not run table Scan

-- Syncdelay arg (= 60) seconds between disk syncs (0 for never) the time when the system refreshes the disk synchronously. The default value is 60 s.

Replication options:

-- Master mode master replication mode

-- Slave mode slave replication mode

-- Source arg when slave: specify master When it is a slave, specify the Master Address and Port

-- Only arg when slave: specify a single database to replicate when it is set to slave, specify a single database to be copied from the master

-- Pairwith arg address of server to pair

-- Arbiter arg address of arbiter server arbitration server, used in master and pair

-- Autoresync automatically resync if slave data is stale automatically synchronize slave data

-- OplogSize arg size limit (in MB) for op log specifies the size of the operation log

-- OpIdMem arg size limit (in bytes) for in memory storage of op ids specifies the memory size for storing operation logs.

Sharding options:

-- Configsvr declare this is a config db of a cluster specifies the configuration server in the shard.

-- Shardsvr declare this is a shard db of a cluster specified shard Server

Go to the CLI management interface of the database

Cd to the bin folder in the mongodb directory and execute the command./mongo

Run the following command:

If the database cannot be connected, it is a problem with the mongod. lock file under the data Directory. You can use the following repair command,

Mongod -- repair

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.