CentOS7安装MongoDB

参考 MongoDB 官方网站:https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-red-hat/

1.配置 yum 源

  • 创建yum源文件 
  touch  /etc/yum.repos.d/mongodb-enterprise.repo
  • 修改配置文件 
  vim  /etc/yum.repos.d/mongodb-enterprise.repo
  [mongodb-enterprise]
  name=MongoDB Enterprise Repository
  baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.0/$basearch/
  gpgcheck=1
  enabled=1
  gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

 

2.使用 yum 安装MongoDB

 yum install -y mongodb-enterprise

 

3.检查是否安装成功

    [root@Slave ~]# rpm -qa | grep mongodb
    mongodb-enterprise-4.0.4-1.el7.x86_64
    mongodb-enterprise-shell-4.0.4-1.el7.x86_64
mongodb-enterprise-mongos-4.0.4-1.el7.x86_64
mongodb-enterprise-tools-4.0.4-1.el7.x86_64
mongodb-enterprise-server-4.0.4-1.el7.x86_64

 

4.配置SELinux

  • 安装semanage命令
  yum -y install policycoreutils-python
  • 如果SELinux处于enforcing模式,则启用对MongoDB部署将使用的相关端口的访问(例如27017
  semanage port -a -t mongod_port_t -p tcp 27017
  • SELINUX配置文件设置为 disabled 模式,禁用SELinux
  vim /etc/selinux/config

  SELINUX=disabled
  • 将SELinux配置文件设置为 permissive 模式,解除限制
  vim /etc/selinux/config

  SELINUX=permissive

5.MongoDB的使用

  • 启用/停止/重启 MongoDB 服务
   systemctl start mongod.service  
   systemctl stop  mongod.service  
   systemctl restart mongod.service

      CentOS6用一下方法      

   service mongod start
   service mongod stop  
   service mongod restart

6.设置随机启动

   chkconfig mongod on(CentOS6)  systemctl enbale mongod.service (CentOS7)

 

参考:https://www.cnblogs.com/xiaoerjun/p/9841987.html

 

posted @ 2018-12-17 22:16  代码的味道  阅读(357)  评论(0编辑  收藏  举报