本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
eb migrate
描述
将互联网信息服务 (IIS) 网站和应用程序从 Windows 服务器迁移到 Elastic Beanstalk。该命令会打包您的应用程序,保留其配置,然后将其部署到新的 Elastic Beanstalk 环境中。
有关迁移 IIS 站点和应用程序的更多信息,请参阅将 IIS 应用程序迁移到 Elastic Beanstalk。
注意
在使用此命令之前,请确保您的系统满足以下要求:
-
互联网信息服务 (IIS) 版本 7.0 或更高版本
-
已安装 Web 部署 3.6 或更高版本
-
Windows 服务器上的管理权限
-
Amazon 配置了适当权限的凭证
-
您的源服务器对 Amazon 服务具有出站互联网访问权限。
以下步骤概述了迁移过程:
-
发现 IIS 站点及其配置。
-
Package 应用程序内容和配置。
-
创建 Elastic Beanstalk 环境和应用程序。
-
comma
-
使用保留的设置部署应用程序。
该命令在结构化目录中创建迁移项目,如以下列表所示:
C:\migration_workspace\ └── .\migrations\latest\ ├── upload_target.zip └── upload_target\ ├── [SiteName].zip # One ZIP per default application of IIS site ├── [SiteName-ApplicationName].zip # One ZIP per additional application ├── aws-windows-deployment-manifest.json └── ebmigrateScripts\ ├── site_installer.ps1 # Site installation scripts ├── permission_handler.ps1 # Permission management └── other helper scripts
eb migrate cleanup用于管理这些工件。
语法
eb migrate [options]
eb migrate explore [options]
eb migrate cleanup [options]
在不带参数的情况下运行时,在非交互模式下eb migrate运行。要在交互模式下执行它,请运行eb migrate --interactive。
交互模式命令提示输入以下信息:
-
选择要迁移的 IIS 站点
-
环境和应用程序名称
-
平台版本选择
-
实例类型和其他配置选项
子命令
explore
eb migrate explore子命令会检查您的 IIS 服务器并列出可用站点。
使用此命令显示以下信息:
-
查看服务器上的所有 IIS 站点
-
使用
--verbose
,检查详细配置,包括:-
网站绑定和端口
-
应用程序池
-
虚拟目录及其物理路径
-
身份验证设置
-
PS C:\migrations_workspace>
eb migrate explore
Default Web Site
Site2
site3
router
PS C:\migrations_workspace>
eb migrate explore --verbose
1: Default Web Site:
- Bindings:
- *
:8083:
- Application '/':
- Application Pool: DefaultAppPool
- Enabled Protocols: http
- Virtual Directories:
- /:
- Physical Path: C:\inetpub\wwwroot
- Logon Method: ClearText
- Application '/dotnet-6-0':
- Application Pool: DefaultAppPool
- Enabled Protocols: http
- Virtual Directories:
- /:
- Physical Path: C:\inetpub\AspNetCoreWebApps\CoreWebApp-6-0
- Logon Method: ClearText
- Application '/dotnet-8-0':
- Application Pool: DefaultAppPool
- Enabled Protocols: http
- Virtual Directories:
- /:
- Physical Path: C:\inetpub\AspNetCoreWebApps\CoreWebApp-8-0
- Logon Method: ClearText
2: Site2:
- Bindings:
- *
:8081:
...
清理
该eb migrate cleanup子命令通过以下操作管理迁移工件:
-
保留最近成功迁移的内容
./migrations/latest
-
正在删除较旧的迁移目录
-
维护关键配置文件
PS C:\migrations_workspace>
eb migrate cleanup
Are you sure you would like to cleanup older artifacts within `./migrations/`? (y/N):
--force
用于在清理期间跳过确认提示。
PS C:\migrations_workspace>
eb migrate cleanup --force
选项
这些选项都不是必需的。如果您在没有任何选项eb migrate的情况下运行,EB CLI 将在非交互模式下执行。使用eb migrate --interactive,EB CLI 会提示您输入或选择所需设置的值。
名称 |
描述 |
---|---|
或
|
新的 Elastic Beanstalk 应用程序的名称。 类型:字符串 默认: EBMigrated应用程序 |
|
包含先前由生成的源代码的目录或 ZIP 文件eb migrate --archive-only。 使用此选项部署先前创建的迁移包。 示例: |
或
|
仅创建目标存档目录,无需部署。 生成的目录可以使用eb create或手动部署eb deploy。 |
或
|
用于在迁移的应用程序的 CNAME DNS 条目前缀的子域名。 类型:字符串 默认值:环境名称 |
或
|
将所有具有活动绑定的 HTTP 端口的源服务器防火墙配置复制到目的地。 在中创建相应的安全组规则 Amazon。 |
或
|
要与环境关联的 Amazon EBS 快照列表 IDs ,以逗号分隔。 示例: |
|
对所有新的 Amazon EBS 卷强制加密。 重要这是一个账户范围的设置,会影响未来所有 Amazon EBS 卷的创建。 |
或
|
新 Elastic Beanstalk 环境的名称。 类型:字符串 默认: EBMigrated环境 限制:长度必须介于 4 到 40 个字符之间。只能包含字母、数字和连字符。不得以连字符开头或结尾。 |
或
|
要与环境的 Amazon EC2 实例关联的实例配置文件。 如果未指定,则创建一个具有访问 Elastic Beanstalk 资源的权限的默认实例配置文件。有关更多信息,请参阅 Elastic Beanstalk 实例配置文件。 |
或
|
您的 Elastic Beanstalk 环境的亚马逊 EC2 实例类型。 类型:字符串 默认:c5.2xlarge 有关可用的实例类型,请参阅亚马逊 EC2 用户指南中的亚马逊 EC2 实例类型。 |
或
|
强制迁移过程采用交互模式。 即使默认值可用,也会提示输入配置值。 |
或
|
用于启用 RDP 访问环境实例的 Amazon EC2 key pair。 对于调查日志中看不到的实例级问题很有用。 有效值:在 Amazon 注册的现有密钥对名称 EC2 |
或
|
适用于环境的 Elastic Beanstalk 平台运行时。如果未指定,则自动从主机 Windows 服务器版本中检测到。 示例: 有关可用平台版本的列表,请使用 eb 平台列表。 |
或
|
Elastic Beanstalk 的 IAM 服务角色用于管理相关服务。 Amazon 如果未指定,则创建具有必要权限的默认服务角色。有关更多信息,请参阅 Elastic Beanstalk 服务角色。 注意仅指定角色名称,而不是完整的 ARN。Elastic Beanstalk 会自动创建完整的 ARN。 |
或
|
以逗号分隔的待迁移的 IIS 站点列表。如果未指定,则迁移服务器上的所有可用站点。 示例: |
|
要与 Application Load Balancer 关联的 ACM SSL 证书列表 ARNs ,以逗号分隔。 迁移具有 HTTPS 绑定的网站时是必需的。 示例: |
或
|
用逗号分隔的 有关更多信息,请参阅 标记环境。 |
|
在迁移过程中显示详细信息。 与explore子命令一起使用时,显示全面的站点配置详细信息。 |
或
|
环境的 VPC 配置,指定为 JSON 文件路径或 JSON 字符串。 配置必须包括:
重要当您指定 |
|
在操作期间跳过确认提示。 与cleanup子命令一起使用时,无需确认即可删除迁移工件。 |
输出
该命令在整个迁移过程中提供状态更新:
-
VPC 配置检测(在 EC2 实例上运行时)
-
每个站点的源包生成进度
-
环境创建状态
-
部署进度
如果成功,则显示新环境的详细信息,包括:
-
环境名称和 ID
-
应用程序名称
-
区域
-
平台版本
-
环境 CNAME
对于迁移期间出现的问题,请使用eb events和eb health命令获取详细信息。
示例
基本用法
交互模式下的基本迁移:
PS C:\migrations_workspace>
eb migrate
Identifying VPC configuration of this EC2 instance (i-0123456789abcdef0):
id: vpc-1234567890abcdef0
publicip: true
elbscheme: public
ec2subnets: subnet-123,subnet-456,subnet-789
securitygroups: sg-123,sg-456
elbsubnets: subnet-123,subnet-456,subnet-789
Using .\migrations\latest to contain artifacts for this migration run.
Generating source bundle for sites, applications, and virtual directories...
Default Web Site/ -> .\migrations\latest\upload_target\DefaultWebSite.zip
Creating application version
Creating environment
Environment details for: EBMigratedEnv
Application name: EBMigratedApp
Region: us-west-2
Deployed Version: app-230320_153045
Environment ID: e-abcdef1234
Platform: 64bit Windows Server 2019 v2.7.0 running IIS 10.0
Tier: WebServer-Standard-1.0
CNAME: ebmigratedenv.us-west-2.elasticbeanstalk.com
Updated: 2023-03-20 15:30:45
使用自定义配置迁移特定站点:
PS C:\migrations_workspace>
eb migrate `
--sites "Default Web Site,InternalAPI" `
--application-name "CorporateApp" `
--environment-name "Production" `
--instance-type "c5.xlarge" `
--tags "Environment=Production,Team=WebOps" `
--copy-firewall-config
无需部署即可创建迁移存档:
PS C:\migrations_workspace>
eb migrate --archive-only
Using .\migrations\latest to contain artifacts for this migration run.
Generating source bundle for sites, applications, and virtual directories...
Default Web Site/ -> .\migrations\latest\upload_target\DefaultWebSite.zip
Generated destination archive directory at .\migrations\latest\upload_target
You can execute `eb init` and `eb create` from this directory to deploy to EB.
高级配置示例
使用 JSON 文件使用自定义 VPC 配置进行迁移:
PS C:\migrations_workspace>
cat vpc-config.json
{
"id": "vpc-1234567890abcdef0",
"publicip": "false",
"elbscheme": "internal",
"ec2subnets": [
"subnet-private1",
"subnet-private2"
],
"securitygroups": [
"sg-app",
"sg-database",
"sg-monitoring"
],
"elbsubnets": [
"subnet-private1",
"subnet-private2"
]
}
PS C:\migrations_workspace eb migrate `
--sites "InternalAPI" `
--vpc-config vpc-config.json `
--instance-type "r5.xlarge" `
--tags "Environment=Internal,Security=High"
迁移带有 SSL 证书和主机标头的站点:
PS C:\migrations_workspace>
eb migrate `
--sites "SecurePortal" `
--ssl-certificates "arn:aws:acm:region:account:certificate/cert1,arn:aws:acm:region:account:certificate/cert2" `
--verbose
INFO: Detected HTTPS bindings:
- www.example.com:443
- api.example.com:443
INFO: Configuring Application Load Balancer with SSL certificates
INFO: Creating host-based routing rules:
- www.example.com -> target group 1
- api.example.com -> target group 2
使用 EBS 快照配置迁移:fo
PS C:\migrations_workspace>
eb migrate `
--sites "Default Web Site" `
--ebs-snapshots "snap-1234567890abcdef0" "snap-0987654321fedcba1" `
--encrypt-ebs-volumes
Using .\migrations\latest to contain artifacts for this migration run.
INFO: Enabling EBS encryption for all new volumes in us-west-2
INFO: Configuring environment with specified EBS snapshots
安全配置示例
处理具有复杂防火墙规则的站点:
PS C:\migrations_workspace>
eb migrate `
--sites "Default Web Site,ReportingService" `
--copy-firewall-config `
--verbose
INFO: Detected the following Windows Firewall rules:
- Allow Web Traffic (TCP 80, 443)
- Allow Reporting Traffic (TCP 8081)
INFO: Creating corresponding security group rules
使用自定义 IAM 角色进行迁移:
PS C:\migrations_workspace>
eb migrate `
--sites "SecureApp" `
--instance-profile "CustomInstanceProfile" `
--service-role "CustomServiceRole"