CentOS7 安装 MongoDB3.6

来源:互联网 发布:电子滚动屏幕软件 编辑:程序博客网 时间:2024/05/16 09:02

安装MongoDB 3.6社区版

--配置MongoDB的yum源

vim /etc/yum.repos.d/mongodb-org-3.4.repo  

--添加以下内容:

[mongodb-org-3.6]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
-- 安装MongoDB


sudo yum install -y mongodb-org
启动MongoDB

--配置SELinux

方法一:

如果SELinux开启enforcing模式:

  • semanage port -a -t mongod_port_t -p tcp 27017
方法二:
如果禁用SELinux (修改配置文件的方式必须重启系统):

SELINUX=disabled
SELINUX=permissive
--启动MongoDB

systemctl start mongod.service

--配置防火把27017端口号加到例外:


 firewall -cmd --permanent --add-port=27017/tcp
 firewall-cmd --reload
 systemctl restart firewalld.service


--设置开机启动

systemctl enable mongod.service  

--启动Mongo shell

mongo

--设置mongodb远程访问:

编辑mongod.conf注释bindIp,并重启mongodb.

vim /etc/mongod.conf 

systemctl restart mongod.service 


--停止mongodb

systemctl stop mongod.service  









原创粉丝点击