There are many ways to install MongoDB, you can install the source code, and you can use the Yum source installation method in CentOS. Since MongoDB is updated more quickly, I prefer to use the Yum source installation method. The installation steps under 64-bit CentOS are as follows:
1. Preparatory work
Run the Yum command to view MongoDB package information [root@localhost ~]# Yum info mongo-10gen
(Hint that there is no matching information) that the Yum source in your CentOS system does not contain MONGODB resources, so you need to add the Yum source before installing MongoDB with the Yum command, which means adding *.repo in the/etc/yum.repos.d/directory Yum Source configuration file
2, Vi/etc/yum.repos.d/10gen.repo, enter the following statement:
[10gen]
Name=10gen Repository
Baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
After you have configured the Yum source, you can query MongoDB-related information if the configuration correctly executes the following command:
View information for a MONGODB server package
[email protected] 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.
To view client installation conditions
[Email protected] geffzhang]#
* 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. Installing MongoDB server side and client tools
[email protected] geffzhang]# Yum install Mongo-10gen-server
[email protected] geffzhang]# Yum install Mongo-10gen
4. Start MongoDB
Service Mongod Start
Updated later, stop MongoDB, execute yum update Mongo-10gen mongo-10gen-server.
5, server configuration:/etc/mongod.conf
# mongo.conf #where to log logpath=/var/log/mongo/mongod.log logappend=true #以追加方式写入日志 # Fork and run in background fork=true #port= 27017#端口 DBPath=/var/lib/mongo #数据库文件保存位置 Directoryperdb=true# enables periodic logging of CPU utilization and I/O wait #启用定期记录CPU利用率和 I/O waits #cpu=true # Turn on/off security. OFF is currently whether the default # is run in a secure authentication mode, and is not certified as a non-secure way #noauth=true #auth=true # Verbose logging output. # Verbose logging of output #verbose=true # Inspect all client data for validity in receipt (useful for # Developing drivers) Check the validity of the client receiving data when developing the driver # Objcheck=true # Enable DB quota management enables database quota management, with a default of 8 files per db, which can be set with the Quotafiles parameter #quota=true # set Oplog record rank # 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 Debug Item #nocursors=true # Ignore queries hints ignore query hints #nohints=true # disables the HTTP interface, which defaults to localhost:28017# Disable The HTTP interface (Defaults to localhost:27018). This port number is written in the wrong #nohttpinterface=true # Closes the server-side script, which will greatly limit the functionality of the # Turns off server-side scripting. This'll result in greatly limited # functionality #noscripting=true # to close the scan table, any query will be a scan failure # Turns off table scans. Any query this would do a table scan fails. #notablescan=true # to close the data file pre-allocation # Disable data Files preallocation. #noprealloc=true # Specifies the size of the. ns file for the new database, in MB # specify. ns file size for new databases. # nssize=<size> # Accout token for Mongo monitoring server. #mms-token=<token> # Mongo The name of the monitor server # server name for Mongo monitoring server. #mms-name=<server-name> # Mongo Monitoring Server ping interval # ping interval for Mongo monitoring server. #mms-interval=<seconds> # Replication options Copy option # in replicated MONGO databases,Specify here whether the is a slave or master in replication, specifies that the current is a dependency #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
6. Enable Authorization:
[[email protected] test]# vim/etc/mongodb.conf//Remove the comments from the front of the Auth=true
[[email protected] test]#/etc/init.d/mongod Restart//restart effective
CentOS 6 installs MongoDB and server-side configuration with Yum