在Ubuntu上稳定部署MongoDB,可参考以下步骤:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
。echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
。sudo apt update
,sudo apt install -y mongodb-org
。/etc/mongod.conf
,设置bindIp
为0.0.0.0
以允许远程连接,开启security.authorization
启用认证。replication.replSetName
等相关参数。sudo systemctl start mongod
。sudo systemctl enable mongod
。mongo --version
。root
角色的用户。bindIp
,并开放防火墙相应端口。可根据服务器硬件情况,调整/etc/mongod.conf
中如storage.wiredTiger.engineConfig.cacheSizeGB
等参数,还可为常用查询字段创建索引。