Simple and practical MongoDB installation Tutorial: Use yum in centos to install MongoDB and server configuration details

Source: Internet
Author: User
Tags install mongodb mongodb server mongo shell

Reprinted: View Original

 

I. preparations:

 

Run the yum command to view the MongoDB package information.

[Root @ VM ~] # Yum info mongo-10gen
(No matching information is displayed ,)

It indicates that the yum source in your centos system does not contain MongoDB resources. Therefore, you need to add the yum source before using the yum command to install MongoDB, that is, in/etc/yum. repos. d/Add * to the directory *. repo Yum source configuration file. The following are the configuration content of MongoDB Yum source for 64-bit centos and 32-bit different systems:

We will name this file here:/Etc/yum. Repos. d/10gen. Repo

For 64-bit Yum source Configuration:

VI/etc/yum. Repos. d/10gen. Repo

[10gen]name=10gen Repositorybaseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64gpgcheck=0

For 32-bitYum source configuration:

VI/etc/yum. Repos. d/10gen. Repo

[10gen]name=10gen Repositorybaseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686gpgcheck=0

Select the corresponding configuration content based on your system

Check whether the system is 32-bit or 64-bit:

$ Uname-

If x86_64 is contained, it indicates that it is 64-bit, for example, myCentos6.0 64bitAfter the system executes this command, it displays:

Linux vm.centos6 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux

 

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 @ VM ~] # Yum info mongo-10gen-server * (Omitted multi-row unimportant information) * Available packagesname: mongo-10gen-serverArch: x86_64version: 1.8.2release: mongodb_1size: 4.7 mrepo: 10 gensummary:Mongo server, sharding server, and support scriptsURL: http://www.mongodb.orgLicense: 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 ~] #

 

View client tool information

[Root @ VM ~] # Yum info mongo-10genLoaded plugins: fastestmirror ** (omitting multiline unimportant information) ** installed packagesname: mongo-10genArch: x86_64version: 1.8.2release: mongodb_1size: 55 mrepo: 10 gensummary:Mongo client shell and toolsURL: http://www.mongodb.orgLicense: 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 ~] #

 

Ii. Install MongoDB server and client tools

1. Install the server:

[Root @ VM ~] # Yum install mongo-10gen-server [root @ VM ~] # Ls/usr/bin/Mongo(Tab key)Mongo mongod mongodump unzip Export Program Files Export Import mongorestore mongos unzip stat ----------------------------------------------- these are MongoDB Program Files

Because the mongo-10gen-server package depends on the mongo-10gen, there is no need to install the client toolkit mongo-10gen separately after the server is installed.

 

2. Install the client separately:

[root@vm ~]# yum install mongo-10gen

 

3. Check

[root@vm ~]# /etc/init.d/mongodUsage: /etc/init.d/mongod {start|stop|status|restart|reload|force-reload|condrestart}[root@vm ~]# /etc/init.d/mongod statusmongod (pid 1341) is running...[root@vm ~]#

It indicates that the server is already running.

 

4. server configuration:/etc/mongod. conf

[Root @ VM ~] # Cat/etc/mongod. conf # Mongo. conf # Where to loglogpath =/var/log/Mongo/mongod. loglogappend = true # Write logs by append # fork and run in backgroundfork = true # Port = 27017 # port dbpath =/var/lib/Mongo # database file storage location # enables periodic Logging of CPU utilization and I/O wait # enable regular 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 unauthenticated. # noauth = true # auth = true # verbose logg Ing output. # detailed record output # verbose = true # inspect all client data for validity on receept (useful for # Developing Drivers) 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, you can set the oplog record level with the quotafiles parameter # quota = true # 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 # ig Nore query hints ignore the query prompt # nohints = true # disable the HTTP interface. The default value is localhost: 28017 # disable the HTTP interface (ults to localhost: 27018 ). this port number is written incorrectly # nohttpinterface = true # disable the server script, which will greatly limit 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 # specified for the new database. NS file size, in MB # specify. NS file size for new databases. # nssize = <size> # accout token for Mongo monitoring server. # MMS-Token = <token> # Name of the Mongo monitoring server # server name for Mongo monitoring server. # MMS-name = <server-Name> # Ping interval of the Mongo monitoring server # Ping interval for Mongo monitoring server. # MMS-interval = <seconds> # replication options replication option # In R Eplicated Mongo databases, specify here whether this is a slave or master in the copy, specify the current slave 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 ~] #

The above are some parameters in the default configuration file. For more parameters, run the mongod-H command.

 

[Root @ VM ~] # Mongod-hallowed options: General options: -H [-- help] Show this usage information -- version show version information-f [-- config] Arg configuration file specifying additional options specifies the startup configuration file path-V [-- verbose] Be More verbose (include multiple times for more verbosity e.g. -vvvvv) -- Quiet quieter output -- Port Arg specify port number port -- bind_ip Arg comma separated list of IP addresses Listen on-all local IPs by default bind IP address, multiple -- maxconns Arg Max number of simultaneous connections maximum number of concurrent connections -- logpath Arg log file to send write to instead of stdout-has to be a file, not directory log file path -- logappend append to logpath instead of over-writing log Writing Method -- pidfilepath Arg full path to pidfile (if not set, no pidfile is created) PID file path -- Keyfile Arg private key for cluster authentica Tion (only for replica sets) Cluster authentication private key, only applicable to replica set -- unixsocketprefix Arg alternative directory for Unix domain sockets (defaults to/tmp) alternative directory -- fork server process -- auth run with security run in Authentication mode -- CPU periodically show CPU and iowait utilization regularly displays 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 Will be stored in a separate directory each database is stored in a separate directory -- journal enable journaling records logs. We recommend that you enable this function, some data can be restored when an exception occurs -- journaloptions Arg journal diagnostic options -- IPv6 enable IPv6 support (disabled by default) -- jsonp allow jsonp access via HTTP (has security implications) jsonp is allowed to be accessed over HTTP. This method has a security risk -- noauth run without security authentication -- nohttpinterface disable HTTP interface -- noprealloc disabl E Data File preallocation-will often hurt performance disable data file pre-allocation, performance is often compromised -- noscripting disable scripting engine disables the script engine -- notablescan do not allow table scans does not allow table scanning -- nounixsocket disable listening on UNIX sockets disables UNIX sockets listening -- nssize Arg (= 16 ). NS file size (in MB) for new databases is set for new data. NS file size -- objcheck inspect client data for validity on receept check the validity of the data received from the client -- profile Arg 0 = off 1 = s Low, 2 = all -- quota limits each database to a certain number of files (8 default) enable database quota management. By default, each database can have 8 files, you can set the quotafiles parameter -- quotafiles Arg number of files allower per dB, requires -- quota -- rest turn on simple rest API enable rest API -- repair run repair on all DBS repair all databases -- repairpath Arg root directory for repair files-defaults to dbpath repair file root directory, it is assumed that the directory specified by dbpath -- slowms Arg (= 100) value of slow Profile and console log -- smallfiles use a smaller default file size -- syncdelay Arg (= 60) seconds between disk syncs (0 = never, but not recommended) the time when the data is synchronized to the hard disk, the default value is 60 seconds. 0 indicates that the disk is not synchronized to the hard disk (not recommended). -- sysinfo print some diagnostic system information to print some diagnostic system information -- upgrade DB if needed if necessary, update the database file to a new format (<= 1.0 to 1.1 + required during upgrade) replication options: Copy option -- fastsync indicate that this instance is starting from a dbpath Snapshot of the repl peer is synchronized from a dbpath snapshot -- autoresync automatic Resync if Slave Data is stale automatic synchronization, if the data on the slave is not automatically synchronized -- oplogsize Arg size limit (in MB) for OP log oplog size Master/Slave options: master/Slave configuration options -- master mode -- slave mode -- source Arg when slave: Specify master as <Server: port> specify the master server address on the slave server -- only Arg when slave: specify a single database to replicate specify Database -- slavedelay Arg specify delay (in seconds) to be used when applying master Ops to slave specifies the time interval of Data Synchronization from the master server, in seconds replica set options: replica set Option -- replset Arg is <setname> [/<optionalseedhostlist>] parameter: <Name> [<seed host list>] sharding options: sharding setting options -- configsvr declare this is a Config dB of a cluster; default port 27019; default DIR/data/configdb declares that this is a cluster configuration database, the default port number 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 sharded database of the cluster, and the default port is 27018 -- nomoveparanoia turn off paranoid saving of data for movechunk. this is on by default for now, but the default will switch is closed and partial to saving large data blocks. Now it is the default, but it will 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.