Centos7安装MongoDB

1)在/etc/yum.repos.d 创建一个mongodb-org.repo 源文件

[root@qd-vpc-dev-op01 ~]$ cd /etc/yum.repos.d/
[root@qd-vpc-dev-op01 yum.repos.d]$ touch mongodb-org.repo
[root@qd-vpc-dev-op01 yum.repos.d]$ cat mongodb-org.repo
[mongodb-org]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1

2)更新yum源

[root@qd-vpc-dev-op01 yum.repos.d]$ yum update
  1. 安装MongoDB
[root@qd-vpc-dev-op01 yum.repos.d]$ yum install -y mongodb-org

4)启动MongoDB

[root@qd-vpc-dev-op01 yum.repos.d]$ service mongod start
[root@qd-vpc-dev-op01 yum.repos.d]$ chkconfig mongod on

5)配置远程访问

[root@qd-vpc-dev-op01 yum.repos.d]$cat /etc/mongod.conf|grep -v "#"|grep -v "^$"
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
processManagement:
net:
  port: 27017

编辑文件:/etc/mongodb.conf
修改后的内容如下:

    bind_ip = 0.0.0.0

    port = 27017

   auth=true
[root@qd-vpc-dev-op01 yum.repos.d]$ service mongod restart
Restarting mongod (via systemctl):                         [  OK  ]

6)打开MongoDB

[root@qd-vpc-dev-op01 yum.repos.d]$ mongo 127.0.0.1:27017

你可能感兴趣的:(Centos7安装MongoDB)