1. 安裝s3cmd工具
[root@testserver01 ~]# yum install s3cmd
2. 配置s3cmd, 按提示輸入相應的ak,sk,endpoint等信息
[root@testserver01 ~]# s3cmd --configure
3. s3cmd使用
[root@testserver01 ~]# s3cmd mb s3://abc ??? ?(創建一個桶)
Bucket 's3://abc/' created
[root@testserver01 ~]# vi policy.txt
[root@testserver01 ~]# cat policy.txt
{
? "Version": "2008-10-17",
? "Statement": [
? ? {
? ? ? "Sid": "AllowPublicRead",
? ? ? "Effect": "Allow",
? ? ? "Principal": {
? ? ? ? "AWS": "*"
? ? ? },
? ? ? "Action": [
? ? ? ? "s3:GetObject"
? ? ? ],
? ? ? "Resource": [
? ? ? ? "arn:aws:s3:::abc/*"
? ? ? ]
? ? }
? ]
}
[root@testserver01 ~]# s3cmd setpolicy ./policy.txt s3://abc ? ?(為指定桶設置policy)
s3://abc/: Policy updated
[root@testserver01 ~]# s3cmd ls s3://abc ? (ls 列出abc bucket下面的文件)
2024-03-02 12:38 ? ? ? ?42272 ?s3://abc/xxx.sql
2024-03-02 12:38 ? ? ? ?12566 ?s3://abc/pro_update.txt
[root@testserver01 ~]# s3cmd del s3://abc/xxx.sql ? ?(刪除桶里面某個文件)
delete: 's3://abc/microcloud.sql'
[root@testserver01 ~]# s3cmd ls s3://abc
2024-03-02 12:38 ? ? ? ?12566 ?s3://abc/pro_update.txt
[root@testserver01 ~]# ls
anaconda-ks.cfg ?policy.txt
[root@testserver01 ~]# s3cmd put anaconda-ks.cfg s3://abc/ ? ?(往指定桶里面上傳文件)
upload: 'anaconda-ks.cfg' -> 's3://abc/anaconda-ks.cfg' ?[1 of 1]
?1515 of 1515 ? 100% in ? ?0s ? ?27.43 KB/s ?done
[root@testserver01 ~]# s3cmd ls s3://abc
2024-03-02 12:45 ? ? ? ? 1515 ?s3://abc/anaconda-ks.cfg
2024-03-02 12:38 ? ? ? ?12566 ?s3://abc/pro_update.txt
[root@testserver01 ~]# s3cmd get s3://abc/pro_update.txt ? ?(從桶里面下載文件)
download: 's3://abc/pro_update.txt' -> './pro_update.txt' ?[1 of 1]
?12566 of 12566 ? 100% in ? ?0s ?1446.60 KB/s ?done
[root@testserver01 ~]# ls
anaconda-ks.cfg ?policy.txt ?pro_update.txt
[root@testserver01 ~]#