Tutorial on MongoDB installation and configuration under CentOS system _mongodb

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

First, the preparatory work:
run the Yum command to view MongoDB package information

Copy Code code as follows:

[ROOT@VM ~]# Yum Info mongo-10gen

(Hint has no relevant matching information,)

The Yum source in your CentOS system does not contain MONGODB related resources, so you need to increase the MongoDB source before you install Yum with the Yum command, that is, add/etc/yum.repos.d/*.repo source profile in the Yum directory, The following are the MongoDB Yum source configuration for the CentOS 64-bit and 32-bit different systems:

We'll name the file here:/etc/yum.repos.d/10gen.repo

For 64-bit Yum Source configuration:

Copy Code code as follows:

Vi/etc/yum.repos.d/10gen.repo

[10gen]
Name=10gen Repository
Baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
Gpgcheck=0


For 32-bit Yum Source configuration:
Copy Code code as follows:

Vi/etc/yum.repos.d/10gen.repo

[10gen]
Name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
Gpgcheck=0


Select the appropriate configuration content according to your system

See how the system is 32-bit or 64-bit:

Copy Code code as follows:

$ uname-a

The description containing the x86_64 is 64-bit, for example, after my centos6.0 64bit system performs this command, it displays:
Copy Code code as follows:

Linux vm.centos6 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon June 19:49:27 BST x86_64 x86_64 x86_64 gnu/linux

After you have configured the Yum source correctly, you can query for MongoDB-related information If you configure the following command properly:

To view information about the MONGODB server package

Copy Code code as follows:

[ROOT@VM ~]# Yum Info mongo-10gen-server
(Omit multiple lines of unimportant information) *********
Available Packages
Name:mongo-10gen-server
Arch:x86_64
version:1.8.2
Release:mongodb_1
size:4.7 M
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.

[ROOT@VM ~]#


to view information about the client tools
Copy Code code as follows:

[ROOT@VM ~]# Yum Info mongo-10gen
Loaded Plugins:fastestmirror
* * (Omit multiple lines of unimportant information) * *
Installed Packages
Name:mongo-10gen
Arch:x86_64
version:1.8.2
Release:mongodb_1
Size:55 M
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.

[ROOT@VM ~]#

Second, the installation of MongoDB server-side and client tools

1. Install Server side:

Copy Code code as follows:

[ROOT@VM ~]# Yum Install Mongo-10gen-server
[ROOT@VM ~]# Ls/usr/bin/mongo (Tab key)
MONGO Mongod mongodump mongoexport mongofiles mongoimport mongorestore mongos mongostat

———————————————–


These are MongoDB's program files.

Because the Mongo-10gen-server package relies on Mongo-10gen, you do not need to install the Client Toolkit separately after you install the server Mongo-10gen

2. Individual installation can be client:

Copy Code code as follows:

[ROOT@VM ~]# Yum Install Mongo-10gen

3. Check
Copy Code code as follows:

[ROOT@VM ~]#/etc/init.d/mongod
Usage:/etc/init.d/mongod {Start|stop|status|restart|reload|force-reload|condrestart}
[Root@vm ~]#/etc/init.d/mongod Status
Mongod (PID 1341) is running ...
[ROOT@VM ~]#

Indicates that the rear server side is already running

4. Server configuration:/etc/mongod.conf

Copy Code code as follows:

[ROOT@VM ~]# cat/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 #数据库文件保存位置

# Enables periodic logging of CPU utilization and I/O wait
#启用定期记录CPU利用率和 I/O wait
#cpu = True

# Turn On/off Security. Off is currently the default
# is run as security authentication, default is not authenticated unsecured way
#noauth = True
#auth = True

# Verbose logging output.
# Verbose record output
#verbose = True

# Inspect all client data for validity on receipt (useful for
# Developing drivers to check the validity of client-received data when developing drivers
#objcheck = True

# Enable DB quota management enables database quota management, which can have 8 files per db By default and can be set with the Quotafiles parameter
#quota = True
# Set 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 Debug items
#nocursors = True

# Ignore Query hints Ignore inquiry hints
#nohints = True
# Disable HTTP interface, default to localhost:28017
# Disable The HTTP interface (Defaults to localhost:27018). This port number is written incorrectly.
#nohttpinterface = True

# Close server-side scripts, which will greatly restrict functionality
# Turns off server-side scripting. This'll result in greatly limited
# functionality
#noscripting = True
# Close Scan table, any query will be scan failed
# Turns off table scans. Any query so would do a table scan fails.
#notablescan = True
# Close data file pre-allocation
# Disable data File preallocation.
#noprealloc = True
# Specify the size of the. ns file for the new database, in megabytes: 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 The ping interval of the monitor server
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>

# Replication Options Replication option

# in replicated MONGO databases, specify here whether this is a slave or master in replication, specifies that the current is a subordinate relationship
#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
[ROOT@VM ~]#

These are some of the parameters in the default configuration file, and more parameters can be viewed with the mongod-h command

[ROOT@VM ~]# Mongod-h
Allowed Options:

General Options:
-H [--help] Show this usage information
--version Show version Information
-F [--config] arg configuration file specifying additional options specify boot profile path
-V [--verbose] is more verbose (include multiple
verbosity e.g.-VVVVV)
--quiet quieter output
--port ARG specify port number ports
--BIND_IP Arg comma separated list of IP addresses to listen on-
All local IPs by default bound IP can be multiple
--maxconns arg max number of simultaneous connections maximum concurrent connections
--logpath arg log file to send write to instead of Stdout-has to
Being a file, not directory log file path
--logappend Append to LogPath instead of over-writing log write mode
--pidfilepath arg full path to Pidfile (if not set, no Pidfile
Created) PID file path
--keyfile ARG private key for cluster authentication
Replica sets) cluster authentication private key, only available for replica set
--unixsocketprefix arg alternative directory for UNIX domain sockets
(Defaults to/tmp) Alternative directory
--fork Fork Server process
--auth run with Security using authentication Mode
--CPU periodically show CPU and iowait utilization periodic CPU and IO wait utilization
--dbpath arg directory for datafiles database file path
--diaglog arg 0=off 1=w 2=r 3=both 7=w+some reads Oplog record level
--directoryperdb each database would be stored in a separate directory
Each database is stored in a separate directory
--journal enable journaling log, recommended to open, in abnormal downtime can restore some data
--journaloptions ARG journal Diagnostic options
--ipv6 Enable IPV6 support (disabled by default)
--jsonp allow JSONP access via HTTP (Has security
Implications) allows JSONP to be accessed via HTTP, which has security implications
--noauth run without security without a secure authentication method
--nohttpinterface Disable HTTP interface Disable HTTP interface
--noprealloc Disable data file Preallocation-will often hurt
Performance disabling the pre-allocation of data files can often impair performance
--noscripting Disable scripting engine disable scripting engine
--notablescan does not allow table scans does not allow tables to scan
--nounixsocket Disable listening on UNIX sockets prohibit UNIX sockets listening
--nssize Arg (=16). ns file Size (in MB) for new databases set the size of the. ns files
--objcheck inspect client data for validity on receipt check the validity of the data received from the clients
--profile arg 0=off 1=slow, 2=all
--quota limits each database to a certain number of files (8
Default) enables database quota management, which can have 8 files per db and can be set with the Quotafiles parameter
--quotafiles arg number of files Allower per db, requires--quota
--rest turn on the simple Rest API to open the REST API
--repair Run Repair on all DBS repair all databases
--repairpath arg root directory for repair files-defaults to dbpath repair the root of the file, the default
considers the directory specified by DBPath
--slowms arg (=100) value of slow for profile and console log
--smallfiles use a smaller default file size
--syncdelay Arg (=60) seconds between disk syncs (0=never, but not
Recommended) time to synchronize data with the hard disk, default 60 seconds, 0 means no sync to hard drive (not recommended)
--sysinfo Print Some diagnostic system information prints some diagnostic system information
--upgrade Upgrade DB If needed upgrade the database file to a new format if necessary
(Required when <=1.0 to 1.1+ upgrade)

Replication Options: Replication option
--fastsync indicate that this instance be starting from a DBPath
Snapshot of the REPL peer sync from a dbpath snapshot
--autoresync automatically resync if slave the data is stale automatic synchronization if the from machine is not new
Automatic sync
--oplogsize arg size limit (in MB) for op log oplog

Master/slave options: Master/from configuration option
--master Master Mode
--slave slave mode dependent modes
--source Arg when slave:specify Master as <server:port> designated primary server address on secondary server
--only Arg when slave:specify a single database to replicate secondary server specifies the
Database
--slavedelay Arg specify delay (in seconds) to is used when applying
Master Ops to slave specifies the time interval in seconds to synchronize data from the primary server

Replica SET options: Replica set option
--replset arg arg is <setname>[/<optionalseedhostlist>]
Parameter:< name >[< seed Host List

Sharding Options: Fragment Setup option
--configsvr Declare this is a config db of a cluster; Default port
27019; The default Dir/data/configdb declares that this is a clustered configuration database,
The default port is 27019 the default path is/data/configdb
--shardsvr declare this is a shard db of a cluster; Default port
27018 declares that this is a fragmented database of clusters with a default port of 27018
--nomoveparanoia turn off paranoid saving of the data for Movechunk. This
is on by default to now, but default would switch
Close to save large chunks of data. Now it's the default, but it's going to change

[ROOT@VM ~]#

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.