安裝:
sudo apt-get update
sudo apt-get install -y python-dev python-pip
sudo pip install awscli
驗證:
$ aws --version
aws-cli/1.18.162 Python/2.7.17 Linux/4.4.0-148-generic botocore/1.19.2
配置信息:
$ aws configure
AWS Access Key ID [None]: 3
AWS Secret Access Key [None]: 4
Default region name [None]: us-west-2
Default output format [None]: json
簡單使用,訪問所有bucket列表:
$ aws --endpoint-url http://192.168.2.13:8081 s3 ls
2020-09-27 19:32:05 bucket-1
2020-09-27 19:32:05 test-bucket
2020-09-27 19:32:04 bucket-10086
列出某個bucket下的所有object信息:
$ aws --endpoint-url http://192.168.2.13:8081 s3 ls s3://bucket-1
# 寫入時間 文件大小 objectID
2020-10-20 17:45:48 7650 object11111
2020-10-22 20:23:21 7650 object11111-copy1
上傳文件到服務器上:
# 用文件名即 object11111-copy1.gz 作為objectID 存儲到服務器上
$ aws --endpoint-url http://192.168.2.13:8081 s3 cp object11111-copy1.gz s3://bucket-1
# 下面這種指定objectID的方式上傳到服務器
$ aws --endpoint-url http://192.168.2.13:8081 s3 cp large-filer.zip s3://bucket-1/object11111-copy1
下載文件:
# 下載大文件4G左右時報 Max retries exceeded 的異常錯誤
$ aws --endpoint-url http://192.168.2.13:8081 s3 cp s3://bucket-1/object11111-copy1 ./object2222