下载地址
https://www.mongodb.com/try/download/community
安装步骤
-
先安装依赖
sudo yum install libcurl openssl xz-libs
-
解压tar包
tar -zxvf mongodb-linux-*-5.0.13.tgz
-
添加环境变量
export PATH=/usr/local/mongodb5.0.6/bin:$PATH -
创建数据库文件和日志文件
sudo mkdir -p /var/lib/mongo
sudo mkdir -p /var/log/mongodb
- 授权
sudo chown -R mongod:mongod /var/lib/mongo
sudo chown -R mongod:mongod /var/log/mongodb
- 编辑/etc/mongod.conf配置
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
logAppend: true
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 0.0.0.0
port: 27017
setParameter:
enableLocalhostAuthBypass: false
security:
authorization: disabled
- 启动服务
mongod -f /etc/mongod.conf