在CentOS上安装MongoDB主要有两种方法:通过包管理器(如yum)或从源代码编译
sudo yum install epel-release
sudo yum install mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod
sudo systemctl status mongod
如果一切正常,你将看到类似以下的输出:
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-06-21 10:00:00 UTC; 1min ago
Main PID: 9876 (mongod)
CGroup: /system.slice/mongod.service
└─9876 /usr/bin/mongod --config /etc/mongod.conf
现在你已经在CentOS上成功安装了MongoDB。接下来,你可以开始使用MongoDB数据库了。