Introduction to MongoDB Installation and startup configuration in Linux

Source: Internet
Author: User
Tags auth mongodb time interval port number

1. Download installation package

wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz
Unzip the compressed package after the download is complete
Tar zxf mongodb-linux-i686-1.8.2.tgz

2. Installation Preparation

Move MongoDB to the/usr/local/server/mongdb folder
MV Mongodb-linux-i686-1.4.4/usr/local/mongodb

Creating database folders and log files
Mkdir/usr/local/mongodb/data
Touch/usr/local/mongodb/logs

3. Set power-on self-starter

Add MongoDB Startup items to rc.local guarantee MongoDB start when server is powered on
echo "/usr/local/server/mongodb/bin/mongod–dbpath=/usr/local/server/mongodb/data–

Logpath=/usr/local/server/mongodb/logs–logappend–auth–port=27017″>>/etc/rc.local

echo "/usr/local/mongodb/bin/mongod–dbpath=/usr/local/mongodb/data–

Logpath=/usr/local/mongodb/logs–logappend–auth–port=27017″>>/etc/rc.local

4. Start MongoDB

CD to the MongoDB directory in the Bin folder boot MongoDB

Here is the login method that requires permission, user name and password to connect
/usr/local/server/mongodb/bin/mongod–dbpath=/usr/local/server/mongodb/data–

Logpath=/usr/local/server/mongodb/logs–logappend–auth–port=27017–fork

This one doesn't need a password.
/usr/local/server/mongodb/bin/mongod–dbpath=/usr/local/server/mongodb/data–

Logpath=/usr/local/server/mongodb/logs–logappend–port=27017–fork

5. Parameter explanation: –dbpath database path (data file)

–logpath log file path
–master designated as the main machine
–slave specified as from machine
–SOURCE Specifies the IP address of the primary machine
–POLOGSIZE specifies that the log file size is no more than 64M. Because Resync is very operational and time-consuming, it is best to set a large enough

Oplogsize to avoid Resync (the default Oplog size is 5% of the size of the free disk).
–logappend the end of the log file add
–port Enable port number
–fork running in the background
–only specify which database to copy only
–slavedelay refers to the time interval from replication detection
–auth whether to require authentication permission logins (username 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 addresses to bind Listener–all local IPs
Bound by default
-V [--verbose] is more verbose (include multiple
verbosity e.g.-VVVVV)
–dbpath Arg (=/data/db/) directory for datafiles specify data storage directory
–quiet Quieter output Silent mode
–logpath arg file to send all output to instead of stdout specify log storage directory
–logappend APPND to LogPath instead of over-writing Specify whether the log is appended or overwritten

Write to log file
–fork Fork Server process to create a subprocess
–CPU periodically show CPU and iowait utilization periodic display CPU and IO usage

Condition
–noauth run without security no authentication mode
–auth run with security authentication mode
–objcheck inspect client data for validity on receipt check the validity of the input data

Check
–quota Enable DB quota management start database quota management
–quotafiles arg number of files Allower per db, Requires–quota specify the text allowed for each database

Number of pieces
–appsrvpath arg root directory for the Babble app server
–nocursors diagnostic/debugging option Debug Diagnostics options
–nohints Ignore query hints ignore hit hits
–nohttpinterface Disable HTTP Interface shutdown HTTP interface, default is 28017
–noscripting Disable scripting engine shutdown script engine
–noprealloc Disable data file preallocation shutdown database File size pre-allocation
–smallfiles use a smaller default file size with a smaller defaults
–nssize Arg (=16). ns file Size (in MB) for new databases The default size of the newly-NS files
–diaglog arg 0=off 1=w 2=r 3=both 7=w+some reads provide a way to read-only, write only, or read and write

Row, or the main write + section of the read mode
–sysinfo Print Some diagnostic system Information printer diagnostic information
–upgrade upgrade DB If needed update database if needed
–repair Run Repair on all DBS repairs all databases
–notablescan does not allow table scans does not run a sheet scan
–syncdelay Arg (=60) seconds between disk syncs (0 for never) system synchronously refreshes the disk by default

60s

Replication options:
–master Master Mode primary replication mode
–slave slave mode from replication
–source Arg when slave:specify master as <server:port> specifies the address and port of the master when from
–only Arg when slave:specify a single database to replicate specifies the need to be from the primary

Single Library of the system
–pairwith ARG address of the server to pair with
–arbiter arg address of arbiter server arbiter, used in main and pair
–autoresync automatically resync if slave data is stale automatic synchronization from
–oplogsize arg size limit (in MB) for OP log specifies the size of the action logs
–opidmem arg size limit (in bytes) for in memory storage of OP IDs specifies the memory that stores the action log

Size

Sharding options:
–configsvr Declare this is a config db of a cluster specifies the configuration server in Shard
–shardsvr declare this is a shard db of a cluster specify Shard server

6. Access to the CLI management interface of the database

CD to the Bin folder in the MongoDB directory, execute the command./mongo

Run as follows:

[Root@namenode mongodb]#./bin/mongo
MongoDB Shell version:1.8.2
Connecting To:test
> Use test;
Switched to DB test

If the database appears if not connected, it is a data directory of the Mongod.lock file problem, you can use the following repair command,
Mongod–repair

Related Article

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.