centos7安装mongodb
时间: 2023-10-09 22:09:50 浏览: 79
Centos7 install MongoDB 3.6.txt
以下是在CentOS 7上安装MongoDB的步骤:
1. 添加MongoDB的Yum存储库
```
$ wget -qO- https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
$ sudo apt-get update
```
2. 安装MongoDB
```
$ sudo yum install mongodb-org
```
3. 启动MongoDB服务
```
$ sudo systemctl start mongod
```
4. 验证MongoDB是否已成功安装
```
$ mongo --eval 'db.runCommand({ connectionStatus: 1 })'
```
如果MongoDB已成功安装,则会输出类似以下内容的结果:
```
{
"authInfo" : {
"authenticatedUsers" : [ ],
"authenticatedUserRoles" : [ ]
},
"ok" : 1
}
```
现在,您已经成功地在CentOS 7上安装了MongoDB。
阅读全文