Install mongodb rpm package and mongodbrpm package

Source: Internet
Author: User
Tags install mongodb mongo shell

Install mongodb rpm package and mongodbrpm package
MonfoDB is an open-source document database that provides common performance, high availability, and automatic scaling.

The record in MongoDB is a document, which is a structure consisting of fields and values. Mongodb documents are similar to JSON objects. Field Values can contain arrays of other documents, arrays, and documents. Records are organized into collections, which is equivalent to tables. Refer:



The advantages of using documents are:
Documents correspond to endogenous Data Objects in many programming languages
Embedded documents and arrays reduce join overhead
Dynamic schema supports smooth Polymorphism

Key features:
High performance:
Mongodb provides high-performance data persistence. In particular:
Supports embedded data models to reduce the I/O of the Database System
Indexes support quick queries and embedded documents and arrays can contain keys.

High Availability:
Mongodb provides highly available replica sets.
Automatic failover failure
Data redundancy
Replica set is a group of mongodb servers that maintain the same dataset, provide redundancy, and increase data availability.

Automatic horizontal scaling:
Horizontal scaling is the kernel function of mongodb.
Automatically share distributed data on the Cluster
Replica sets can provide eventual consistent reads for applications with low latency and high throughput.


Installation:

0
Environment
[Root @ host2 ~] # Uname-
Linux host2 2.6.32-504.3.3.el6.x86 _ 64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[Root @ host2 ~] # Cat/etc/issue
CentOS release 6.5 (Final)
Kernel \ r on an \ m

1
Configure yum Source
[Root @ host2 ~] # Vi/etc/yum. repos. d/mongodb. repo
[Mongodb]
Name = MongoDB Repository
Base url = http://downloads-distro.mongodb.org/repo/redhat/ OS /x86_64/
Gpgcheck = 0
Enabled = 1

2
Run the $ yum install-y mongodb-org command to install the following four packages.
Mongodb-org-server: This package contains the specified D daemon and associated configuration and init 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, and mongotop.

To install a specific version, you can use the command yum install-y mongodb-org-2.6.1 mongodb-org-server-2.6.1 mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1

Currently, 2.6.7 is installed using the yum install-y mongodb-org command.
[Root @ host2 ~] # Yum install-y mongodb-org
....
Installed:
Mongodb-org.x86_64 0: 2. 6.7-1

Dependency Installed:
Mongodb-org-mongos.x86_64 0: 2. 6.7-1 mongodb-org-server.x86_64 0: 2. 6.7-1
Mongodb-org-shell.x86_64 0: 2. 6.7-1 mongodb-org-tools.x86_64 0: 2. 6.7-1

Complete!
[Root @ host2 ~] #

3
To prevent automatic updates, add the following lines in/etc/yum. conf:
Exclude = mongodb-org, mongodb-org-server, mongodb-org-shell, mongodb-org-mongos, mongodb-org-tools

4
Configure selinux
Semanage port-a-t mongod_port_t-p tcp 27017

$ Yum search semanage
$ Yum-y install libsemanage-python.x86_64

Or
In/etc/selinux. conf
SELINUX = permissive/SELINUX = disabled

Or
[Root @ host2 ~] # Getenforce
Enforcing
[Root @ host2 ~] # Setenforce 0
[Root @ host2 ~] # Getenforce
Permissive

5
View
The default data file is in/var/lib/mongo, and the log file is in/var/log/mongodb,
You can change the directory of data and log files in the configuration file/etc/mongod. conf.
Run as user mongod. If you are running as another user, you need to change the access permission of the data directory and log directory.

Data File Problems
[Root @ host2 ~] # Ll/var/lib/
...
Drwxr-xr-x. 2 mongod 4096 07:15 mongo
[Root @ host2 ~] # Ll/var/lib/mongo
Total usage 0

Log Files
[Root @ host2 ~] # Ll/var/log/
...
Drwxr-xr-x. 2 mongod 4096 February 2 14:35 mongodb
[Root @ host2 ~] # Ll/var/log/mongodb/
Total usage 0
-Rw-r -----. 1 mongod 0 January 14 07:15 mongod. log

6
Run mongodb
[Root @ host2 ~] #/Etc/init. d/mongod status
Mongod stopped
[Root @ host2 ~] # Service ready D status
Specified D is stopped
[Root @ host2 ~] # Service producer D start
Starting mongod: [OK]

7
Check:
[Root @ host2 ~] # Netstat-ntpl | grep mongod
Tcp 0 0 127.0.0.1: 27017 0.0.0.0: * LISTEN 5334/mongod

[Root @ host2 ~] # Ll/var/lib/mongo/
Total usage 81936
Drwxr-xr-x. 2 mongod 4096 February 2 15:16 journal
-Rw -------. 1 mongod 67108864 February 2 15:16 local.0
-Rw -------. 1 mongod 16777216 February 2 15:16 local. ns
-Rwxr-xr-x. 1 release d 5 August 5 15:16 release d. lock
Drwxr-xr-x. 2 mongod 4096 February 2 15:16 _ tmp

8
Configure startup
Chkconfig mongod on

9
Enter the command line for testing
[Root @ host2 ~] # Mongo
MongoDB shell version: 2.6.7
Connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help ".
For more comprehensive documentation, see
Http://docs.mongodb.org/
Questions? Try the support group
Http://groups.google.com/group/mongodb-user
> Show dbs
Admin (empty)
Local 0.078 GB
> Db. version ();
2.6.7
>
>
> Help
Db. help () help on db methods
Db. mycoll. help () help on collection methods
Sh. help () sharding helpers
Rs. help () replica set helpers
Help admin administrative help
Help connect ing to a db help
Help keys key shortcuts
Help misc things to know
Help mr mapreduce

Show dbs show database names
Show collections in current database
Show users in current database
Show profile show most recent system. profile entries with time> = 1 ms
Show logs show the accessible logger names
Show log [name] prints out the last segment of log in memory, 'global' is default
Use <db_name> set current database
Db. foo. find () list objects in collection foo
Db. foo. find ({a: 1}) list objects in foo where a = 1
It result of the last line evaluated; use to further iterate
DBQuery. shellBatchSize = x set default number of items to display on shell
Exit quit the mongo shell
>
> Exit
Bye
[Root @ host2 ~] #

10
Stop
Sudo service producer D stop

You can view the errors and related information of the mongod process in the log file/var/log/mongodb/mongod. log.


Refer:
Http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/


-----------------

Please refer to the following source for reprinting:
Blog.csdn.net/beiigang

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.