There are many ways to install MongoDB. You can install MongoDB in source code or in Centos using yum source. Because MongoDB is updated fast, I prefer the yum source installation method. The installation steps for 64-bit Centos are as follows:
1. Preparations
Run the yum command to view the MongoDB package information [root @ localhost ~] # Yum info mongo-10gen
(No matching information is displayed.) The yum source in your centos system does not contain MongoDB resources. Therefore, you need to add the yum source before installing MongoDB using the yum command, that is, in/etc/yum. repos. d/add * to the directory *. repo yum source configuration file
2. vi/etc/yum. repos. d/10gen. repo. Enter the following statement:
[10gen]
Name = 10gen Repository
Base url = http://downloads-distro.mongodb.org/repo/redhat/ OS /x86_64
Gpgcheck = 0
After configuring the yum source, if the configuration is correct, execute the following command to query MongoDB-related information:
View mongoDB server package information
[Root @ localhost geffzhang] # yum info mongo-10gen-server
* Base: centos.ustc.edu.cn
* Extras: centos.ustc.edu.cn
* Updates: centos.ustc.edu.cn
Installed Packages
Name: mongo-10gen-server
Arch: x86_64
Version: 2.0.6
Release: mongodb_1
Size: 13 M
Repo: installed
From repo: 10gen
Summary: mongo server, sharding server, and support scripts
URL: http://www.mongodb.org
License: AGPL 3.0
Description: Mongo (from "huMONGOus") is a schema-free document-oriented
: Database.
:
: This package provides the mongo server software, mongo sharding
: Server softwware, default configuration files, and init. d scripts.
View client installation status
[Root @ localhost geffzhang] # yum info mongo-10gen
* Base: centos.ustc.edu.cn
* Extras: centos.ustc.edu.cn
* Updates: centos.ustc.edu.cn
Installed Packages
Name: mongo-10gen
Arch: x86_64
Version: 2.0.6
Release: mongodb_1
Size: 69 M
Repo: installed
From repo: 10gen
Summary: mongo client shell and tools
URL: http://www.mongodb.org
License: AGPL 3.0
Description: Mongo (from "huMONGOus") is a schema-free document-oriented
: Database. It features dynamic profileable queries, full indexing,
: Replication and fail-over support, efficient storage of large
: Binary data objects, and auto-sharding.
:
: This package provides the mongo shell, import/export tools, and
: Other client utilities.
3. Install the MongoDB server and client tools
[Root @ localhost geffzhang] # yum install mongo-10gen-server
[Root @ localhost geffzhang] # yum install mongo-10gen
4. Start Mongodb
Service producer d start
Later updated, stop mongodb, execute yum update mongo-10gen mongo-10gen-server can be.
5. Server configuration:/etc/same D. conf
# Mongo. conf
# Where to log
Logpath =/var/log/mongo/mongod. log
Logappend = true # write logs by append
# Fork and run in background
Fork = true
# Port = 27017 # port
Dbpath =/var/lib/mongo # database file storage location
Directoryperdb = true
# Enables periodic logging of CPU utilization and I/O wait
# Enable periodic recording of CPU utilization and I/O wait
# Cpu = true
# Turn on/off security. Off is currently the default
# Whether to run in security authentication mode. The default mode is non-security mode.
# Noauth = true
# Auth = true
# Verbose logging output.
# Detailed record output
# Verbose = true
# Inspect all client data for validity on receept (useful
# Developing drivers) is used to check the validity of data received by the client during driver development.
# Objcheck = true
# Enable db quota management to Enable database quota management. By default, each database can have 8 files, which can be set using the quotaFiles parameter.
# Quota = true
# Set the oplog record level
# Set oplogging level where n is
#0 = off (default)
#1 = W
#2 = R
#3 = both
#7 = W + some reads
# Oplog = 0
# Diagnostic/debugging option Dynamic debugging item
# Nocursors = true
# Ignore query hints Ignore query prompt
# Nohints = true
# Disable the http interface. The default value is localhost: 28017.
# Disable the HTTP interface (Defaults to localhost: 27018). This port number is written incorrectly.
# Nohttpinterface = true
# Disable the server script, which greatly limits the function.
# Turns off server-side scripting. This will result in greatly limited
# Functionality
# Noscripting = true
# Close the scan table. Any query will fail.
# Turns off table scans. Any query that wocould do a table scan fails.
# Notablescan = true
# Disable data file pre-allocation
# Disable data file preallocation.
# Noprealloc = true
# Specify the size of the. ns file for the new database. Unit: MB
# Specify. ns file size for new databases.
# Nssize =
# Accout token for Mongo monitoring server.
# Mms-token =
# Mongo monitoring server name
# Server name for Mongo monitoring server.
# Mms-name =
# Ping interval of the mongo monitoring server
# Ping interval for Mongo monitoring server.
# Mms-interval =
# Replication Options
# In replicated mongo databases, specify here whether this is a slave or master in replication, specifying that the current is a slave
# Slave = true
# Source = master.example.com
# Slave only: specify a single database to replicate
# Only = master.example.com
# Or
# Master = true
# Source = slave.example.com