4.13.4. 安装 MongoDB
在内部数据库安装过程中,您只能安装与 satellite-installer 工具安装的相同的 MongoDB 版本。只要支持版本,您可以使用 Red Hat Software Collections(RHSCL)软件仓库或从外部来源安装 MongoDB。卫星支持 MongoDB 版本 3.4。
流程
要安装 MongoDB,请输入以下命令:
# yum install rh-mongodb34 rh-mongodb34-syspaths
启动并启用 rh-mongodb34 服务:
# systemctl start rh-mongodb34-mongod # systemctl enable rh-mongodb34-mongod
在 MongoDB 上为数据库 pulp_database 创建 Pulp 用户:
# mongo pulp_database \ --eval "db.createUser({user:'pulp',pwd:'pulp_password',roles:[{role:'dbOwner', db:'pulp_database'},{ role: 'readWrite', db: 'pulp_database'}]})"在
/etc/opt/rh/rh-mongodb34/mongod.conf文件中,指定绑定 IP:bindIp: your_mongodb_server_bind_IP,::1编辑
/etc/opt/rh/rh-mongodb34/mongod.conf文件,以便在security部分启用身份验证:security: authorization: enabled
重启
rh-mongodb34-mongod服务:# systemctl restart rh-mongodb34-mongod
为 MongoDB 打开端口 27017:
# firewall-cmd --add-port=27017/tcp # firewall-cmd --runtime-to-permanent
从卫星服务器,测试您可以访问数据库。如果连接成功,命令会返回
1。# scl enable rh-mongodb34 " mongo --host mongo.example.com \ -u pulp -p pulp_password --port 27017 --eval 'ping:1' pulp_database"