在CentOS中配置MongoDB的步骤如下:
mongodb-linux-x86_64-rhel70-5.0.27.tgz
。tar
命令解压下载的安装包到指定目录,例如/opt/monitor/mongodb/mongodb_5.0.27/
。mkdir -p /opt/monitor/mongodb/mongodb_5.0.27/{data,conf,log}
bin
目录下创建或编辑mongodb.conf
文件,添加或修改以下配置项:systemLog:
destination: file
logAppend: true
path: /opt/monitor/mongodb/mongodb_5.0.27/log/mongodb.log
storage:
dbPath: /opt/monitor/mongodb/mongodb_5.0.27/data
net:
port: 27017
bindIp: 0.0.0.0
processManagement:
fork: true
/etc/profile
文件,在末尾添加以下内容:export PATH=/opt/monitor/mongodb/mongodb_5.0.27/bin:$PATH
source /etc/profile
使配置生效。cd /opt/monitor/mongodb/mongodb_5.0.27/bin
./mongod --config /opt/monitor/mongodb/mongodb_5.0.27/mongodb.conf
sudo systemctl enable mongod
sudo firewall-cmd --zone=public --add-port=27017/tcp --permanent
sudo firewall-cmd --reload
./mongo --port=27017
以上步骤涵盖了在CentOS上安装和配置MongoDB的基本流程。根据实际需求,可能还需要进行进一步的配置,如设置用户认证、创建数据库等。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>