ossutil64常用操作

本文详细介绍了如何安装ossutil64,并通过实例演示了如何使用它来删除开启了版本控制的Bucket中的所有对象及历史版本,包括必要的配置步骤和命令行操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ossutil64安装

endpoint查看:
https://help.aliyun.com/document_detail/31837.html

accessKeyID、accessKeySecret:
https://ram.console.aliyun.com/manage/ak
在这里插入图片描述

>>> wget http://gosspublic.alicdn.com/ossutil/1.6.16/ossutil64
>>> sudo chmod 755 ossutil64
>>> ./ossutil64 config
The command creates a configuration file and stores credentials.

Please enter the config file name,the file name can include path(default /home/xiang/.ossutilconfig, carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):
No config file entered, will use the default config file /home/xiang/.ossutilconfig

For the following settings, carriage return means skip the configuration. Please try "help config" to see the meaning of the settings
Please enter language(CH/EN, default is:EN, the configuration will go into effect after the command successfully executed):
Please enter endpoint:oss-cn-beijing.aliyuncs.com
Please enter accessKeyID:xxxxxxx
Please enter accessKeySecret:xxxxxxx
Please enter stsToken:

删除开启版本控制的Bucket

删除Bucket时如果出现如下错误在这里插入图片描述
可能原因为:

  1. Bucket中存在文件未删除;
  2. Bucket中存在碎片未删除;
  3. Bucket开启了版本控制,因而存在历史版本object
    在这里插入图片描述

使用oss命令行工具ossutil64可进行删除
第一步:如果Bucket开启版本控制则首先删除多版本object:

>>> ./ossutil64 rm oss://xxxxx --all-versions -r
Do you really mean to remove recursively objects of oss://xxxxx(y or N)? y
Succeed: Total 3373 objects. Removed 3373 objects.       
                                                         
8.207040(s) elapsed

第二步:清除Bucket数据并删除Bucket

>>> ./ossutil rm oss://xxxxx -bar
Do you really mean to remove recursively objects and multipart uploadIds of oss://xxxxx(y or N)? y
Do you really mean to remove the Bucket: xxxxx(y or N)? y
Succeed: Total 0 objects, 0 uploadIds. Removed 0 objects, 0 uploadIds.
Removed Bucket: xxxxx                                            

3.316188(s) elapsed

如果在Bucket开启版本控制的前提下没有进行第一步而直接进行第二步则会报错:

>>> ./ossutil64 rm oss://xxxxx -bar
Do you really mean to remove recursively objects and multipart uploadIds of oss://xxxxx(y or N)? y
Do you really mean to remove the Bucket: xxxxx(y or N)? y              

Whether new objects were uploaded during the deletion?

Total 1 objects, 0 uploadIds. Removed 1 objects, 0 uploadIds. when error happens.
Error: oss: service returned error: StatusCode=409, ErrorCode=BucketNotEmpty, ErrorMessage="The bucket you tried to delete is not empty.", RequestId=5F0BF91CC90E843633D7A8B7, Bucket=xlxdsj-test

参考:https://help.aliyun.com/document_detail/120053.html?spm=a2c4g.11186623.6.744.49156901XKzhSf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值