ECS: "s3curl.pl" 스크립트를 사용하여 기본 S3 작업을 수행하는 방법
Summary: "s3curl" 스크립트를 사용하여 ECS 3.x에서 기본적인 s3 작업을 수행하는 방법
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Instructions
구성 단계
구성을 위해 다음 정보를 수집합니다.
s3curl.pl:
- 조사 중인 버킷의 오브젝트 사용자:
- UI> 에 로그인 버킷>관리>**네임스페이스 선택**> 버킷의 소유자 열을 기록합니다.
- 오브젝트 사용자의 공유 암호:
- UI> 에 로그인 사용자 관리>>**편집** 위의 > 사용자 사용자의 공유 암호를 기록합니다.
- ECS 노드 데이터 IP 주소 또는 공용 IP 주소:
- ECS CLI에 로그인하고 다음을 실행합니다.
getrackinfo -n
- ECS CLI에 로그인하고 다음을 실행합니다.
클라이언트에 네트워크 분리가 있는 경우 위의 명령에서 데이터 및 repl 에 대한 IP가 표시됩니다. 노드의 데이터 IP를 기록해 둡니다.
예:
Node ID Network Ip Address Netmask Gateway VLAN 5 repl 10.###.##.##4 255.255.252.0 - - 5 data 10.###.##.##2 255.255.252.0 -
네트워크가 분리되지 않은 경우 다음에서 노드의 공용 IP 주소를 가져옵니다.
getrackinfo:
예:
provo:/usr/share/s3curl # getrackinfo Node private Node Public RMM Ip Address Id Status Mac Ip Address Mac Ip Address Node Name =============== ====== ====== ================= ================= ================= ================= ========= 192.###.###.1 1 MA 00:1e:67:f1:85:10 10.##.##.##7 00:1e:67:bc:c5:53 10.##.##.##3 provo-red 192.###.###.2 2 SA 00:1e:67:ab:e6:d8 10.##.##.##8 00:1e:67:6a:08:8c 10.##.##.##4 sandy-red
단계:
- 디렉토리로 이동
/usr/share/s3curlECS 노드에서 아래 파일을 확인합니다.
provo:/usr/share/s3curl # provo:/usr/share/s3curl # ls -lrt .s3curl -rw------- 1 root root 2095 Mar 6 16:14 .s3curl
- 파일이 없는 경우 다음 콘텐츠를 사용하여 파일을 만듭니다. ["
sample_user"가 사용됩니다.]
@endpoints = ECS data / public ip address gotten above.
%awsSecretAccessKeys = (
sample_user => {
id => '<Object User>',
key => '<Shared Secret>',
},
@endpoints = ('<node1_ip>','<node2_ip>','<node3_ip>','<node4_ip>',)
);
- 이 파일에 아래와 같이 여러 사용자를 추가할 수 있습니다.
%awsSecretAccessKeys = (
<sample_user> => {
id => '<object user>',
key => '<Shared Secret>',
},
<sample_user2> => {
id => '<object user>',
key => '<Shared Secret>',
},
@endpoints = ('<node1_ip>','<node2_ip>','<node3_ip>','<node4_ip>',)
);
- 파일의 사용 권한 변경
# sudo chmod 755 s3curl.pl # sudo chmod 600 .s3curl
Windows 10 1607 이하 버전에서 s3curl.pl 구성 후
- 사용자 인증을 테스트하고 해당 사용자가 소유한 버킷을 나열합니다. "
bucket_1"는 버킷의 이름입니다.
--id= 에서 이전에 설정된 ID.s3curl파일 "sample_user"9020= S3에 연결하는 데 사용되는 TCP 포트
# provo:/usr/share/s3curl # perl s3curl.pl --id <user ID> -- http://<hostname or IP>:9020 | xmllint --format -
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020 | xmllint --format -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 421 100 421 0 0 21803 0 --:--:-- --:--:-- --:--:-- 22157
<?xml version="1.0" encloding="UTF-8" standalone="yes"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01">
<Owner>
<ID>sample_user</ID>
<DisplayName>sample_user</DisplayName>
</Owner>
<Buckets>
<Bucket>
<Name>bucket_1</Name>
<CreationDate>2017-02-21T08:32:05.651Z</CreationDate>
<ServerSideEncryptionEnabled>false</ServerSideEncryptionEnabled>
</Bucket>
</Buckets>
<IsTruncated>false</IsTruncated>
</ListAllMyBucketsResult>
- 특정 버킷의 콘텐츠 나열
- S3의 키는 파일을 참조합니다.
참고: S3에는 플랫라인 파일 구조가 있으며 디렉토리가 존재하지 않습니다.
s3curl.pl디렉토리의 처음 1000개 파일만 표시합니다.
# perl s3curl.pl --id <user id> -- http://<hostname or IP>:9020/<bucket> | xmllint --format - | grep Key
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1 | xmllint --format - | grep Key
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1128 100 1128 0 0 29386 0 --:--:-- --:--:-- --:--:-- 29684
<MaxKeys>1000</MaxKeys>
<Key>2017 - emea schedule obj storage.xlsx</Key>
<Key>_$folder$</Key>
<Key>dir1/dir2/dir3/test_new_name.txt</Key>
- 버킷에서 특정 키 또는 파일 검색
- 접두사 검색 방법을 사용하여 파일 이름의 시작을 알면 특정 파일을 검색합니다.
- 버킷 이름 뒤에 메서드를 삽입합니다.
?prefix=<search_string>"
# perl s3curl.pl --id <user id> -- http://<hostname or IP>:9020/<bucket>?prefix=dir1/dir2/ | xmllint --format - | grep Key
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020/bucket_1?prefix=dir1/dir2/ | xmllint --format - | grep Key
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 599 100 599 0 0 20309 0 --:--:-- --:--:-- --:--:-- 19966
<MaxKeys>1000</MaxKeys>
<Key>dir1/dir2/dir3/test_new_name.txt</Key>
- 버킷에서 특정 키 또는 파일 읽기
참고: 키 또는 버킷 이름에 공백이 포함된 경우 "
%20"를 URL에서 쿼리하는 동안.
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt Goodbye World
- 버킷에 특정 키 또는 파일 쓰기.
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user --put=test1.txt http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt
- 버킷에 있는 특정 키 또는 파일의 메타데이터를 읽습니다.
HTTP/1.1 200 OK--> 요청에 대한 특정 HTTP 응답x-amz-request-id-->request_idECS 로그에서 추적할 수 있습니다.ETag--> 파일의 MD5SUMContent-Length--> 객체의 크기 또는 바이트 수
# perl s3curl.pl --id <user ID> --head http://<hostname or IP>:9020/<bucket>/<path1>/<path2>/<object>
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user --head http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt HTTP/1.1 200 OK Date: Wed, 08 Mar 2017 16:25:52 GMT Server: ViPR/1.0 x-amz-request-id: 0a3c23ed:15aa813368d:10e1:1 x-amz-id-2: 83769c2fcf5f8907b60b588a251bcc492d86d5829dfc2c8bee2504f0c527f256 ETag: "54aea9f06281a5df11d06f105c6fb039" Last-Modified: Wed, 08 Mar 2017 16:08:02 GMT x-emc-mtime: 1488989282859 Content-Encoding: identity Content-Type: application/octet-stream Content-Length: 14
- 사용자의 새 버킷을 생성하려면 다음을 수행합니다.
# perl s3curl.pl --id <user ID> --createBucket -- http://<hostname or IP>:9020/<new bucket name>
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user --createBucket -- http://10.##.##.##7:9020/new_bucket_name New Bucket can be seen below. # provo:/usr/share/s3curl # perl s3curl.pl --id <user> -- http:/<hostname or IP>:9020 | xmllint --format - | grep -A1 '<Bucket>'
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020 | xmllint --format - | grep -A1 '<Bucket>'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 583 100 583 0 0 31712 0 --:--:-- --:--:-- --:--:-- 32388
<Bucket>
<Name>new_bucket_name</Name>
--
<Bucket>
<Name>some_old_bucket</Name>
- 버킷의 특정 키 또는 파일을 ECS 노드로 다운로드.
# perl s3curl.pl --id <user ID> -- http://<hostname or IP>:9020/<bucket>/<path1>/<object> -o download2.txt
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -o download2.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14 100 14 0 0 1360 0 --:--:-- --:--:-- --:--:-- 1400
provo:/usr/share/s3curl #
provo:/usr/share/s3curl # cat download2.txt
Goodbye World
- 사용자에게 속한 버킷에서 특정 키 또는 파일을 삭제합니다.
provo:/usr/share/s3curl # perl s3curl.pl --id <user ID> --delete -- http://<hostname or IP>:9020/<bucket>/<path1>/<path2>/<object>
참고: 객체 이름 사이에 공백이 있으면 전체 경로를 따옴표로 묶고 "
오브젝트 이름 예:
+ "공간에서.
오브젝트 이름 예:
test_new_name test - test.txt
perl s3curl.pl --id sample_user --delete -- "http://10.##.##.##7:9020/bucket/dir1/dir2/test_new_name+test+-+test.txt"
- 버킷 삭제는 사용자의 몫입니다.
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user --delete -- http://10.##.##.##7:9020/new_bucket_name
사용자에게 속한 버킷을 나열한 후 버킷이 존재하지 않습니다.
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020 | xmllint --format - | grep -A1 '<Bucket>'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 421 100 421 0 0 19928 0 --:--:-- --:--:-- --:--:-- 21050
<Bucket>
<Name>bucket_1</Name>
- "byte: range" 헤더를 사용하여 부분적으로 파일 읽기(처음 7자 미만을 읽음)
- 범위: 바이트 값에는 다음이 포함됩니다.
처음 500바이트: "bytes 0-499/1234" 두 번째 500바이트: "바이트 500-999/1234" 처음 500바이트를 제외한 모두: "bytes 500-1233/1234" 마지막 500바이트: "바이트 734-1233/1234"
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H "Range: bytes=0-6" Goodbye Using the "--debug" option for more detailed responses.
참고: debug 옵션은 다음 중 하나에 사용할 수 있습니다.
s3curl.pl 명령을 사용합니다.
# perl s3curl.pl --debug --id <user ID> -- http://<hostname>:9020/<bucket>/<object> -H "Range: bytes=0-6"
provo:/usr/share/s3curl # perl s3curl.pl --debug --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H "Range: bytes=0-6" s3curl: Found the url: host=10.##.##.237; port=9020; uri=/thomas/dir1/dir2/dir3/test_new_name.txt; query=; s3curl: ordinary endpoint signing case s3curl: StringToSign='GET\n\n\nWed, 08 Mar 2017 17:10:59 +0000\n/bucket_1/dir1/dir2/dir3/test_new_name.txt' s3curl: exec curl -v -H 'Date: Wed, 08 Mar 2017 17:10:59 +0000' -H 'Authorization: AWS hegars5:+YrMhohkQ2HqRNkYURJMbddIwrA=' -L -H 'content-type: ' http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H 'Range: bytes=0-6' * Hostname was NOT found in DNS cache * Trying 10.##.##.##7... * Connected to 10.##.##.##7 (10.##.##.##7) port 9020 (#0) > GET /bucket_1/dir1/dir2/dir3/test_new_name.txt HTTP/1.1 > User-Agent: curl/7.37.0 > Host: 10.##.##.##7:9020 > Accept: */* > Date: Wed, 08 Mar 2017 17:10:59 +0000 > Authorization: AWS hegars5:+YrMhohkQ2HqRNkYURJMbddIwrA= > Range: bytes=0-6 > < HTTP/1.1 206 Partial Content < Date: Wed, 08 Mar 2017 17:10:59 GMT < Content-Range: bytes 0-6/14 < Accept-Ranges: bytes * Server ViPR/1.0 is not blacklisted < Server: ViPR/1.0 < x-amz-request-id: 0a3c23ed:15aa813368d:10fc:1 < x-amz-id-2: 83769c2fcf5f8907b60b588a251bcc492d86d5829dfc2c8bee2504f0c527f256 < ETag: "54aea9f06281a5df11d06f105c6fb039" < Last-Modified: Wed, 08 Mar 2017 17:02:13 GMT < x-emc-mtime: 1488992533141 < Content-Encoding: identity < Content-Type: application/octet-stream < Content-Length: 7 < * Connection #0 to host 10.##.##.##7 left intact Goodbye
- 특정 버킷에 파일 또는 키 배치 업로드
- 샘플 파일을 만듭니다.
# vi /usr/share/s3curl/test # cat /usr/share/s3curl/test
이 파일은 ECS에 1,000번 업로드됩니다.
- 다음 스크립트를 만듭니다.
# vi /usr/share/s3curl/script.sh
#!/bin/bash
# script.sh
for i in {1..1000}
do
./s3curl.pl --id=sample_user --put="test" -- "http://10.##.##.##7:9020/bucket_1/File$(printf "%04d" "$i").txt"
echo "File$(printf "%04d" "$i").txt"
done
- 스크립트의 사용 권한을 변경합니다.
# cd /usr/share/s3curl # sudo chmod +755
- 스크립트를 실행합니다.
# sh script.s
- 공백 또는 특수 문자가 있는 파일 쓰기
- "라는 공백 문자로 파일 쓰기
test file.txt"(ASCII 값 %20 필요)
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="test file.txt" -- http://10.##.##.##:9020/bucket_name/test%20file.txt
- "라는 특수 문자 브래킷을 사용하여 파일 쓰기
testfile (1).txt"(슬래시 필요"\"를 사용하여 특수 문자를 무시합니다.
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="testfile (1).txt" -- http://10.##.##.##:9020/bucket_name/testfile%20\(1\).txt
Affected Products
Elastic Cloud StorageProducts
Elastic Cloud StorageArticle Properties
Article Number: 000014704
Article Type: How To
Last Modified: 20 Oct 2025
Version: 5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.