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时如果出现如下错误
可能原因为:
- Bucket中存在文件未删除;
- Bucket中存在碎片未删除;
- 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