3.2. 使用 CLI 在 AWS 上部署实例


您可以使用 AWS web 控制台或 CLI 中的新的 RHEL AI AMI 启动 AWS 实例。您可以使用您要启动实例的部署方法。以下流程演示了如何使用 CLI 使用自定义 AMI 启动 AWS 实例。

如果您选择将 CLI 用作部署选项,您必须创建几个配置,如"先决条件"所示。

先决条件

  • 您创建了 RHEL AI AMI。如需更多信息,请参阅"将 RHEL AI 镜像转换为 AWS AMI"。
  • 已安装 AWS 命令行工具,并使用 aws_access_key_id 和 aws_secret_access_key 正确配置。
  • 已配置了 Virtual Private Cloud (VPC)。
  • 为您的实例创建了子网。
  • 您创建了 SSH 密钥对。
  • 您在 AWS 上创建了一个安全组。

流程

  1. 对于各种参数,您需要收集 变量的 ID。

    1. 要访问镜像 ID,请运行以下命令:

      $ aws ec2 describe-images --owners self
      Copy to Clipboard Toggle word wrap
    2. 要访问安全组 ID,请运行以下命令:

      $ aws ec2 describe-security-groups
      Copy to Clipboard Toggle word wrap
    3. 要访问子网 ID,请运行以下命令:

      $ aws ec2 describe-subnets
      Copy to Clipboard Toggle word wrap
  2. 在创建实例时填充环境变量

    $ instance_name=rhel-ai-instance
    $ ami=<ami-id>
    $ instance_type=<instance-type-size>
    $ key_name=<key-pair-name>
    $ security_group=<sg-id>
    $ disk_size=<size-of-disk>
    Copy to Clipboard Toggle word wrap
  3. 运行以下命令,使用变量创建实例:

    $ aws ec2 run-instances \
        --image-id $ami \
        --instance-type $instance_type \
        --key-name $key_name \
        --security-group-ids $security_group \
        --subnet-id $subnet \
        --block-device-mappings DeviceName=/dev/sda1,Ebs='{VolumeSize='$disk_size'}' \
        --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value='$instance_name'}]'
    Copy to Clipboard Toggle word wrap

用户帐户

RHEL AI AMI 中的默认用户帐户是 cloud-user。它通过 sudo 具有所有权限,无需密码。

验证

  • 要验证您的 Red Hat Enterprise Linux AI 工具是否已正确安装,您需要运行 ilab 命令:

    $ ilab
    Copy to Clipboard Toggle word wrap

    输出示例

    $ ilab
    Usage: ilab [OPTIONS] COMMAND [ARGS]...
    
      CLI for interacting with InstructLab.
    
      If this is your first time running ilab, it's best to start with `ilab
      config init` to create the environment.
    
    Options:
      --config PATH  Path to a configuration file.  [default:
                     /home/<user>/.config/instructlab/config.yaml]
      -v, --verbose  Enable debug logging (repeat for even more verbosity)
      --version      Show the version and exit.
      --help         Show this message and exit.
    
    Commands:
      config    Command Group for Interacting with the Config of InstructLab.
      data      Command Group for Interacting with the Data generated by...
      model     Command Group for Interacting with the Models in InstructLab.
      system    Command group for all system-related command calls
      taxonomy  Command Group for Interacting with the Taxonomy of InstructLab.
    
    Aliases:
      chat      model chat
      generate  data generate
      serve     model serve
      train     model train
    Copy to Clipboard Toggle word wrap

更新 Red Hat Enterprise Linux AI

要更新到 RHEL AI 的最新 z-stream 版本,请按照 更新 Red Hat Enterprise Linux AI 文档中的步骤 操作。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat