Installing MongoDB under Linux

Source: Internet
Author: User

1. Download the installation package
wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz
Download

wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz

  Unzip the package after download
 tar zxf mongodb-linux-i686-1.8.2.tgz
 
2. Installation Preparation
  Move MongoDB to/usr/ Local/mongdb folder
 mv mongodb-linux-i686-1.8.2/usr/local/mongodb
 
  CREATE database folder and log file
 mkdir/usr/local/mongodb/data
 touch/usr/local/mongodb/logs
 
3. Set boot from start
  Add MongoDB Startup Project to Rc.local to ensure MongoDB starts
 echo "/usr/local/server/mongodb/bin/mongod--dbpath=/usr/when the server is powered on local/server/mongodb/data–logpath=/usr/local/server/mongodb/logs–logappend --auth–port=27017 ">>/etc /rc.local
 
4. Start MongoDB
 cd to the Bin folder in the MongoDB directory to start MongoDB
 //This is the login method that requires permission. User connection required user name and password
 /usr/local/server/mongodb/bin/mongod--dbpath=/usr/local/server/mongodb/data--logpath=/ Usr/local/server/mongodb/logs--logappend --auth --port=27017--fork

 //This is a password not required
 /usr/local/server/mongodb/bin/mongod--dbpath=/usr/local/server/mongodb/data-- Logpath=/usr/local/server/mongodb/logs--logappend --port=27017--fork


---137 set the startup service
/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data--logpath=/usr/local/ Mongodb/logs/logs--logappend --port=27017--fork
5. Parameter explanation:--dbpath database path (data file)
       --logpath log file path
      --master designated as the primary machine
       --slave specified as the IP address of the host machine specified from machine
      --source
       --POLOGSIZE specifies that the log file size does not exceed 64M. Because the resync is very large and time-consuming, it is best to avoid resync by setting a sufficiently large oplogsize (the default The Oplog size is 5% of the free disk size).
      --logappend log file end add
      --port enable port number
      --fork run in the background
      --only specify which database to replicate only
      --slavedelay refers to the time interval from replication detection
      --auth Whether you need to verify permissions login (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] is 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 specify log storage directory
--logappend APPND to LogPath instead of over-writing Specifies whether the log is written to the log file in append or overwrite mode
--fork Fork Server process runs in a way that creates a child process
--CPU periodically show CPU and iowait utilization periodic display of CPU and IO usage
--noauth run without security no authentication mode operation
--auth run with security authentication mode
--objcheck inspect client data for validity on receipt check validity check
--quota Enable DB Quota management start management of database quotas
--quotafiles arg number of files Allower per db, requires--quota rules per database allowed
--appsrvpath arg root directory for the Babble app server
--nocursors diagnostic/debugging option Debug Diagnostics options
--nohints Ignore query hints ignores the search hit ratio
--nohttpinterface Disable HTTP interface off HTTP interface, default is 28017
--noscripting Disable scripting engine close script engines
--noprealloc Disable data file preallocation to close the size pre-allocation of database files
--smallfiles use a smaller default file size uses a smaller
--nssize Arg (=16). ns file Size (in MB) The default size for new database NS files in the databases
--diaglog arg 0=off 1=w 2=r 3=both 7=w+some reads is provided in a way that is read-only, write-only, or read-write, or the main write + part of the reading mode
--sysinfo Print Some diagnostic system Information printing systems diagnostic information
--upgrade upgrade DB If needed update database if needed
--repair Run Repair on all DBS repair all databases
--notablescan do not allow table scans does not run tables scan
--syncdelay Arg (=60) seconds between disk syncs (0 for never) the system synchronizes the time to flush disks by default is 60s

Replication options:
--master Master Mode primary Copy mode
--slave slave mode from replication
--source Arg when slave:specify master as <server:port> specifies the primary address and port when it is from
--only Arg when slave:specify a single database to replicate is specified from the primary copy
--pairwith arg address of server to pair with
--arbiter arg address of arbiter server arbiter, used in master and pair
--autoresync automatically resync if slave data is stale auto-sync from
--oplogsize arg size limit (in megabytes) for OP log specifies the sizes of the operation logs
--opidmem arg size limit (in bytes) for in memory storage of OP IDs specifies the amount of memory to store the operation log

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

6. CLI management interface into the database
CD to the Bin folder under the MongoDB directory, execute the command./mongo
Run as follows:
[Email protected] mongodb]#./bin/mongo
MongoDB Shell version:1.8.2
Connecting To:test
> Use test;
Switched to DB test

If the database appears as unable to connect, it is a data directory under the Mongod.lock file problem, you can use the following repair command,
Mongod--repair

This article is from "Ghost" blog, please make sure to keep this source http://5244706.blog.51cto.com/5234706/1439414

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.