Centos 安装mongodb

配置repo

vim /etc/yum.repos.d/mongodb-org-4.4.repo

官方镜像配置如下(很慢)

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

阿里云官方镜像站(推荐)

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://mirrors.aliyun.com/mongodb/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

安装

sudo yum install -y mongodb-org

授权

the data directory

sudo chown -R mongod:mongod /var/lib/mongo

the log directory

sudo chown -R mongod:mongod /var/log/mongodb

启动

sudo systemctl start mongod

如果在启动mongod时收到类似于下面的错误:
    Failed to start mongod.service: Unit mongod.service not found.
首先运行以下命令:

sudo systemctl daemon-reload

开机启动
sudo systemctl enable mongod
posted @ 2020-09-21 23:34  RoinBi  阅读(456)  评论(0编辑  收藏  举报