本文档仅适用于 Amazon CLI 版本 1。有关 Amazon CLI 版本 2 的相关文档,请参阅版本 2 用户指南。
使用 Amazon CLI 的 DataSync 示例
以下代码示例演示了如何通过将 Amazon Command Line Interface与 DataSync 结合使用,来执行操作和实现常见场景。
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。
每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例演示了如何使用 update-location-azure-blob。
- Amazon CLI
-
使用新代理更新您的传输位置
以下
update-location-object-storage示例使用新代理更新 Microsoft Azure Blob Storage 的 DataSync 位置。aws datasync update-location-azure-blob \ --location-arnarn:aws:datasync:us-west-2:123456789012:location/loc-abcdef01234567890\ --agent-arnsarn:aws:datasync:us-west-2:123456789012:agent/agent-1234567890abcdef0\ --sas-configuration '{ \ "Token": "sas-token-for-azure-blob-storage-access" \ }'此命令不生成任何输出。
有关更多信息,请参阅《Amazon DataSync 用户指南》中的更换代理。
-
有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 UpdateLocationAzureBlob
。
-
以下代码示例演示了如何使用 update-location-hdfs。
- Amazon CLI
-
使用新代理更新您的传输位置
以下
update-location-hdfs示例使用新代理更新您的 DataSync HDFS 位置。只有当您的 HDFS 集群使用 Kerberos 身份验证时,才需要--kerberos-keytab和--kerberos-krb5-conf选项。aws datasync update-location-hdfs \ --location-arnarn:aws:datasync:us-west-2:123456789012:location/loc-abcdef01234567890\ --agent-arnsarn:aws:datasync:us-west-2:123456789012:agent/agent-1234567890abcdef0\ --kerberos-keytabfile://hdfs.keytab--kerberos-krb5-conffile://krb5.confhdfs.keytab的内容:N/A. The content of this file is encrypted and not human readable.krb5.conf的内容:[libdefaults] default_realm = EXAMPLE.COM dns_lookup_realm = false dns_lookup_kdc = false rdns = true ticket_lifetime = 24h forwardable = true udp_preference_limit = 1000000 default_tkt_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 des3-cbc-sha1 default_tgs_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 des3-cbc-sha1 permitted_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 des3-cbc-sha1 [realms] EXAMPLE.COM = { kdc = kdc1.example.com admin_server = krbadmin.example.com default_domain = example.com } [domain_realm] .example.com = EXAMPLE.COM example.com = EXAMPLE.COM [logging] kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kerberos/kadmin.log default = FILE:/var/log/krb5libs.log此命令不生成任何输出。
有关更多信息,请参阅《Amazon DataSync 用户指南》中的更换代理。
-
有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 UpdateLocationHdfs
。
-
以下代码示例演示了如何使用 update-location-nfs。
- Amazon CLI
-
使用新代理更新您的传输位置
以下
update-location-nfs示例使用新代理更新您的 DataSync NFS 位置。aws datasync update-location-nfs \ --location-arnarn:aws:datasync:us-west-2:123456789012:location/loc-abcdef01234567890\ --on-prem-configAgentArns=arn:aws:datasync:us-west-2:123456789012:agent/agent-1234567890abcdef0此命令不生成任何输出。
有关更多信息,请参阅《Amazon DataSync 用户指南》中的更换代理。
-
有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 UpdateLocationNfs
。
-
以下代码示例演示了如何使用 update-location-object-storage。
- Amazon CLI
-
使用新代理更新您的传输位置
以下
update-location-object-storage示例使用新代理更新您 DataSync 对象的存储位置。aws datasync update-location-object-storage \ --location-arnarn:aws:datasync:us-west-2:123456789012:location/loc-abcdef01234567890\ --agent-arnsarn:aws:datasync:us-west-2:123456789012:agent/agent-1234567890abcdef0\ --secret-keysecret-key-for-object-storage此命令不生成任何输出。
有关更多信息,请参阅《Amazon DataSync 用户指南》中的更换代理。
-
有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 UpdateLocationObjectStorage
。
-
以下代码示例演示了如何使用 update-location-smb。
- Amazon CLI
-
使用新代理更新您的传输位置
以下
update-location-smb示例使用新代理更新您的 DataSync SMB 位置。aws datasync update-location-smb \ --location-arnarn:aws:datasync:us-west-2:123456789012:location/loc-abcdef01234567890\ --agent-arnsarn:aws:datasync:us-west-2:123456789012:agent/agent-1234567890abcdef0\ --passwordsmb-file-server-password此命令不生成任何输出。
有关更多信息,请参阅《Amazon DataSync 用户指南》中的更换代理。
-
有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 UpdateLocationSmb
。
-