How To Install MongoDB On CentOS 7


转自:https://www.unixmen.com/install-mongodb-centos-7/

1 – Add MongoDB to Yum repo

vim /etc/yum.repos.d/mongodb.repo

[mongodb]

name=MongoDB repo

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/

gpgcheck=0

enabled=1

2 – Install Mongodb packages

[root@unixmen-centos7 ~]# yum -y install mongodb-org

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirror.denit.net

* extras: mirror.denit.net

* updates: mirror.denit.net

Resolving Dependencies

--> Running transaction check

---> Package mongodb-org.x86_64 0:2.6.4-1 will be installed

--> Processing Dependency: mongodb-org-mongos = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64

--> Processing Dependency: mongodb-org-server = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64

--> Processing Dependency: mongodb-org-tools = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64

--> Processing Dependency: mongodb-org-shell = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64

--> Running transaction check

---> Package mongodb-org-mongos.x86_64 0:2.6.4-1 will be installed

---> Package mongodb-org-server.x86_64 0:2.6.4-1 will be installed

---> Package mongodb-org-shell.x86_64 0:2.6.4-1 will be installed

---> Package mongodb-org-tools.x86_64 0:2.6.4-1 will be installed

--> Finished Dependency Resolution

3 – Enable and Start Mongodb Server

[root@unixmen-centos7 ~]# chkconfig  mongod  on

[root@unixmen-centos7 ~]# service   mongod start

Starting mongod (via systemctl):                           [  OK  ]

4 – check if its running

[root@unixmen-centos7 ~]# ps -ef  |  grep   mongo

mongod    2587     1  1 05:24 ?        00:00:08 /usr/bin/mongod -f /etc/mongod.conf

root      2984  2270  0 05:34 pts/1    00:00:00 grep --color=auto mongo

[root@unixmen-centos7 ~]# netstat  -an  |  grep   27017

tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN

unix  2      [ ACC ]     STREAM     LISTENING     20600    /tmp/mongodb-27017.sock

[root@unixmen-centos7 ~]#

5 – Open the port on firewall

[root@unixmen-centos7 ~]# firewall-cmd --zone=public --add-port=27017/tcp --permanent

success

[root@unixmen-centos7 ~]# firewall-cmd --reload

success

6 – check from other machine

[root@unixmen-centos7 ~]# telnet 10.1.1.99  27017

Trying 10.1.1.99...

Connected to 10.1.1.99.

Escape character is '^]'.

Done.

Mongodb默认启动是不带认证,也没有账号,只要能连接上服务就可以对数据库进行各种操作,下面,我们得一步步开启使用用户和认证。

你可能感兴趣的:(How To Install MongoDB On CentOS 7)