CentOS system MongoDB installation and configuration tutorial

  • 2020-05-13 03:45:35
  • OfStack

1. Preparation:
Run the yum command to see the package information for MongoDB


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

(there is no relevant matching information,)

Explain your centos yum source in the system does not contain MongoDB related resources, so need to increase before use yum command to install MongoDB yum source, namely in/etc/yum repos. d increased * / directory repo yum source configuration file, the following are respectively for centos 64 - bit and 32-bit different system MongoDB yum source configuration content:

We here will be a name for the file: / etc/yum repos. d / 10. gen repo

For 64-bit yum source configuration:


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:

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 corresponding configuration content according to your own system

To see if the system is 32-bit or 64-bit:


$ uname -a

The instruction with x86_64 is 64-bit, for example, my centos6.0 64bit system displays after executing this command:

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

Once you have configured the yum source, you can query the MongoDB information if the following command is executed correctly:

View the server package information for mongoDB


[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 ~]#

View information about the client tool

[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 ~]#

2. Install MongoDB's server-side and client-side tools

1. Installation of server:


[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 the program files of MongoDB

Since the mongo-10gen-server package relies on mongo-10gen, there is no need to install the client toolkit mongo-10gen separately once the server is installed

2. Separately install the client:


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

3. Check

[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 ~]#

Post - server is already running

4. Server configuration: /etc/ mongod.conf


vi /etc/yum.repos.d/10gen.repo [10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
0


Related articles: