在Debian系统上配置MongoDB时,有几个关键要点需要注意,以确保系统的安全性、性能和可用性。以下是详细的配置要点:
sudo apt update && sudo apt upgrade -y wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - echo "deb [ archamd64,arm64 ] https://repo.mongodb.org/apt/debian bullseye/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list sudo apt update sudo apt install -y mongodb-org /etc/mongod.conf文件中的net.port和net.bindIp参数。net: port: 27017 bindIp: 0.0.0.0 # 允许任意IP地址连接 /etc/mongod.conf文件中启用身份验证。security: authorization: enabled mongo shell创建一个具有管理员权限的用户。use admin db.createUser({ user: "admin", pwd: "your_password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }) net: ssl: mode: requireSSL PEMKeyFile: /path/to/mongodb.pem CAFile: /path/to/ca.pem sudo systemctl start mongod sudo systemctl enable mongod mongo sudo ufw allow 27017 sudo ufw reload sudo apt update && sudo apt upgrade -y