4.13.4. 安装 MongoDB

在内部数据库安装过程中,您只能安装与 satellite-installer 工具安装的相同的 MongoDB 版本。只要支持版本,您可以使用 Red Hat Software Collections(RHSCL)软件仓库或从外部来源安装 MongoDB。卫星支持 MongoDB 版本 3.4。

流程

  1. 要安装 MongoDB,请输入以下命令:

    # yum install rh-mongodb34 rh-mongodb34-syspaths
  2. 启动并启用 rh-mongodb34 服务:

    # systemctl start rh-mongodb34-mongod
    # systemctl enable rh-mongodb34-mongod
  3. 在 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'}]})"
  4. /etc/opt/rh/rh-mongodb34/mongod.conf 文件中,指定绑定 IP:

    bindIp: your_mongodb_server_bind_IP,::1
  5. 编辑 /etc/opt/rh/rh-mongodb34/mongod.conf 文件,以便在 security 部分启用身份验证:

    security:
      authorization: enabled
  6. 重启 rh-mongodb34-mongod 服务:

    # systemctl restart rh-mongodb34-mongod
  7. 为 MongoDB 打开端口 27017:

    # firewall-cmd --add-port=27017/tcp
    # firewall-cmd --runtime-to-permanent
  8. 从卫星服务器,测试您可以访问数据库。如果连接成功,命令会返回 1

    # scl enable rh-mongodb34 " mongo --host mongo.example.com \
    -u pulp -p pulp_password --port 27017 --eval 'ping:1' pulp_database"