操作场景
通过 DescribeInvocationTasks 查询到的命令输出限制最多24 KB。本⽂以云服务器为例,介绍如何配置使完成的命令输出上传⾄指定 COS 桶中。
前提条件
1. 运⾏命令的⽬标实例是云服务器 CVM,此功能暂时不⽀持 Lighthouse。
2. ⽬标实例状态需处于 运⾏中,且已安装⾃动化助⼿客户端,详情请参⻅ 安装自动化助手客户端 。
3. 已创建⽤于存储命令输出的 COS 存储桶。
操作步骤
1. 进⼊访问管理⻚⾯,单击 新建⻆⾊。![](https://qcloudimg.tencent-cloud.cn/image/document/98aca61fe82d3657201eec1663750229.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/98aca61fe82d3657201eec1663750229.png)
2. 选择⻆⾊载体是 腾讯云产品服务。
![](https://qcloudimg.tencent-cloud.cn/image/document/5c4506d481ac0204bd4b017da30a6c4a.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5c4506d481ac0204bd4b017da30a6c4a.png)
3. 选择⻆⾊载体信息是云服务器(cvm)。![](https://qcloudimg.tencent-cloud.cn/image/document/c7bbeaf9c444cc63d4d4b4a10e179ee8.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c7bbeaf9c444cc63d4d4b4a10e179ee8.png)
4. 搜索并配置预设策略 QcloudCOSDataWriteOnly。![](https://qcloudimg.tencent-cloud.cn/image/document/b8569cd6d63704177f8d7eb3c9d26223.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/b8569cd6d63704177f8d7eb3c9d26223.png)
5. 输⼊⾃定义⻆⾊名称,完成⻆⾊创建。![](https://qcloudimg.tencent-cloud.cn/image/document/f0e297a07841ae081524c30fe4e63d73.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/f0e297a07841ae081524c30fe4e63d73.png)
6. 找到目标实例,打开实例设置>绑定/修改角色。![](https://qcloudimg.tencent-cloud.cn/image/document/9ea4882fc5f31578e92b9946937c51ab.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/9ea4882fc5f31578e92b9946937c51ab.png)
选择已创建的角色并绑定。
![](https://qcloudimg.tencent-cloud.cn/image/document/66fd09a639df26a152cc78c501b77f6b.png)
7. 创建存储桶并复制其访问域名。![](https://qcloudimg.tencent-cloud.cn/image/document/a5e3aa2827258afc9707a72b50d27110.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a5e3aa2827258afc9707a72b50d27110.png)
8. RunCommand、InvokeCommand 接⼝均⽀持 COS 相关的参数,OutputCOSBucketUrl 填写步骤7中复制的存储桶域名,OutputCOSKeyPrefix 可选填。![](https://qcloudimg.tencent-cloud.cn/image/document/9719ae7ec96273a5957ea49120ed7edb.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/9719ae7ec96273a5957ea49120ed7edb.png)
9. 执⾏命令后可在 COS ⽂件列表中查看命令的完整输出。⽂件路径按以下格式组织:![](https://qcloudimg.tencent-cloud.cn/image/document/408f90c39ae321a1be36033a5db7b441.png)
/{OutputCOSKeyPrefix}/{实例ID}/{InvocationTaskID}.log
例如: /test/ins-s023oibx/invt-pvmkhci0.log
。![](https://qcloudimg.tencent-cloud.cn/image/document/408f90c39ae321a1be36033a5db7b441.png)