MongoDB BASICS (iv) Red Hat Enterprise 6.4x64 install MongDB 3.0 and configure mongodbmongdb

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

MongoDB BASICS (iv) Red Hat Enterprise 6.4x64 install MongDB 3.0 and configure mongodbmongdb

Mongodb-org this package is a metadata package. The following four package packages are automatically installed during installation.
Mongodb-org-server this package contains the mongod daemon, related configurations, and initial scripts mongodb-org-mongos this package contains the mongos daemon mongodb-org-shell this package contains the mongo shell mongodb- org-tools this package contains the following mongodb tools: export Import bsondump, mongodump, export, program files, mongooplog, mongoperf, mongorestore, mongostat, andw.top.


1. Create a yum source repository file:
vi /etc/yum.repos.d/mongodb-org-3.0.repo
[mongodb-org-3.0]name=MongoDB Repositorybaseurl=http://repo.mongodb.org/yum/redhat/6/mongodb-org/3.0/x86_64/gpgcheck=0enabled=1


2. Install the MongoDB package and related tools:

yum install -y mongodb-org


To install MongoDB of the specified version, you must specify each component package and the version number appended to the package name, for example:

Sudo yum install-y mongodb-org-3.0.2 mongodb-org-server-3.0.2 mongodb-org-shell-3.0.2 mongodb-org-mongos-3.0.2


You can also define any available MongoDB version. When an updated version is available, yum will automatically update the Mongodb package. To prevent unintentional updates, you can use the exclude command in/etc/yum. conf, for example:
Exclude = mongodb-org, mongodb-org-server, mongodb-org-shell, mongodb-org-mongos, mongodb-org-tools


3. Related Configuration:

If the firewall is enabled, SELinux must be configured to allow MongoDB to run on Red Hat or CentOS Linux. The Administrator should set the following three options: 1. allow port 27017 access (if not, download the tool semanage first): yum-y install policycoreutils-pythonsemanage port-a-t d_d_port_t-p tcp 270172. in the configuration file/etc/selinux/config, set SELinux to permissive: vi/etc/selinux/configSELINUX = enforcing to SELINUX = permissive3. disable SELinux thoroughly: SELINUX = disabled

The default data file path for Mongodb instances to store data is/var/lib/mongo, and the log file path is/var/log/mongodb, which runs with the mongod account. You can also configure the directory of the data file and log file in the/etc/mongod. conf file.
vi /etc/mongod.conf
# mongod.conf#where to loglogpath=/var/log/mongodb/mongod.loglogappend=true# fork and run in backgroundfork=true#port=27017dbpath=/var/lib/mongo# location of pidfilepidfilepath=/var/run/mongodb/mongod.pid# Listen to local interface only. Comment out to listen on all interfaces.bind_ip=127.0.0.1# Disables write-ahead journaling# nojournal=true# Enables periodic logging of CPU utilization and I/O wait#cpu=true# Turn on/off security.  Off is currently the default#noauth=true#auth=true# Verbose logging output.#verbose=true# Inspect all client data for validity on receipt (useful for# developing drivers)#objcheck=true# Enable db quota management#quota=true# Set oplogging level where n is#   0=off (default)#   1=W#   2=R#   3=both#   7=W+some reads#diaglog=0# Ignore query hints#nohints=true# Enable the HTTP interface (Defaults to port 28017).#httpinterface=true# Turns off server-side scripting.  This will result in greatly limited# functionality#noscripting=true# Turns off table scans.  Any query that would do a table scan fails.#notablescan=true# Disable data file preallocation.#noprealloc=true# Specify .ns file size for new databases.# nssize=<size># Replication Options# in replicated mongo databases, specify the replica set name here#replSet=setname# maximum size in megabytes for replication operation log#oplogSize=1024# path to a key file storing authentication info for connections# between replica set members#keyFile=/path/to/keyfile


4. Run mongodb

Set Mongodb to start with the system: chkconfig mongod on enable Mongodb service: service mongod start verify that Mongodb has been started successfully :( check whether the log has information waiting for connection) tail-5/var/log/mongodb/mongod. log [initandlisten] waiting for connections on port <port>

Now we can see that the data has been generated:



Directly enter mongo in the command line to enter the database:



So far, complete !~

Official reference: Install MongoDB on Red Hat Enterprise or CentOS Linux



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.