Centos 安装MongoDB

1.用yum安装
建立yum源文件:mongodb

#cd /etc/yum.repos.d vim

#vim mongodb-org.repo 阿里云

添加如下内容:url

[mngodb-org]
name=MongoDB Repository baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/4.4/x86_64/ gpgcheck=0 enabled=1

这里注意地址用的阿里云的镜像库,比mongodb官方的会快不少。spa

保存后退出编辑,用repolist 命令检查下repo文件是否生效code

而后就是yuman安装blog

yum -y install mongodb-org

安装好了,若是系统比较干净,会安装的依赖比较多,有些慢,我这里共安装了11个应用ip

 

2.修改配置文件it

先找下mongodb 安装到哪里了class

whereis mongod

看下结果,找到 mongod.conf 配置文件

mongod: /usr/bin/mongod /etc/mongod.conf /usr/share/man/man1/mongod.1

编辑位置文件

vim /etc/mongod.conf

而后只改下bindip

 

 

 看到说明了,改为 0.0.0.0 就是不限制ip绑定

 

3.启动mongodb

启动mongodb服务

systemctl start mongod.service

启动后能够用下面的命令查看状态

systemctl status mongod.service

 

 也能够经过http访问来验证,http://39.102.116.84:27017/,若是看到下面的提示表明启动正常

It looks like you are trying to access MongoDB over HTTP on the native driver port.

 

4.设置开机自动启动

systemctl enable mongod.service
相关文章
相关标签/搜索