ECS: Come eseguire le operazioni S3 di base utilizzando lo script "s3curl.pl"

Resumen: Come eseguire operazioni s3 di base su ECS 3.x utilizzando lo script "s3curl".

Este artículo se aplica a Este artículo no se aplica a Este artículo no está vinculado a ningún producto específico. No se identifican todas las versiones del producto en este artículo.

Instrucciones

Procedura di configurazione

Raccogliere le seguenti informazioni per configurare s3curl.pl:
  • Utente dell'oggetto del bucket che si sta analizzando:
    • Accedere all'interfaccia utente>> Gestione dei bucket **Selezionare il >namespace**> Annotare la colonna del proprietario per il bucket.  
  • Segreto condiviso dell'utente dell'oggetto:
    • Accedere all'interfaccia utente>Gestisci>utenti>**Modifica** utente dall'alto > Annotare il segreto condiviso per l'utente.
  • Indirizzi IP o indirizzi IP pubblici dei dati dei nodi ECS:
    • Accedere alla CLI di ECS ed eseguire getrackinfo -n
Se il client dispone di separazione della rete, vengono visualizzati gli IP per i dati e replica dal comando precedente. Annotare gli IP dei dati dei nodi.
Esempio:
Node ID       Network          Ip Address        Netmask            Gateway            VLAN
5            repl              10.###.##.##4     255.255.252.0      -                  -
5            data              10.###.##.##2     255.255.252.0      -
Se non vi è alcuna separazione di rete, ottenere gli indirizzi IP pubblici dei nodi da getrackinfo:
Esempio:
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

Procedura:

  1. Vai alla directory /usr/share/s3curl sul nodo ECS e verificare la presenza del file riportato di seguito.
provo:/usr/share/s3curl #
provo:/usr/share/s3curl # ls -lrt .s3curl
-rw------- 1 root root 2095 Mar  6 16:14 .s3curl
  1. Se il file non esiste, crearlo con il seguente contenuto. ["sample_user" viene utilizzato.]
@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>',)
); 
  1. È possibile aggiungere più utenti a questo file come indicato di seguito.
%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>',)
);
  1. Modifica delle autorizzazioni dei file.
# sudo chmod 755 s3curl.pl

# sudo chmod 600 .s3curl


Utilizzando i comandi s3curl.pl dopo la configurazione

  1. Test dell'autenticazione dell'utente ed elenco dei bucket di proprietà di tale utente. ".bucket_1" è il nome del bucket.
  • --id = l'ID impostato in precedenza nel .s3curl file "sample_user".
  • 9020 = porta TCP utilizzata per connettersi a S3
# 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>
  1. Elenco dei contenuti di un bucket specifico.
  • Una chiave in S3 si riferisce a un file.
Nota: S3 ha una struttura di file flatline, le directory non esistono.
  • s3curl.pl Mostra solo i primi 1.000 file in una directory.
# 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>
  1. Ricerca di una chiave o di un file specifico in un bucket.
  • Utilizzare il metodo di ricerca per prefisso per cercare file specifici una volta noto l'inizio del nome file.
  • Inserire il metodo dopo il nome del bucket "?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>
  1. Lettura di una chiave o di un file specifico in un bucket.
Nota: Se una chiave o un bucket contiene uno spazio nel nome, utilizzare la stringa "%20" mentre lo si interroga nell'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
  1. Scrittura di una chiave o di un file specifico nel bucket.
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
  1. Leggere i metadati di una chiave o di un file specifico nel bucket.
  • HTTP/1.1 200 OK --> Risposta HTTP specifica per la richiesta
  • x-amz-request-id --> request_id che possono essere monitorati nei registri ECS
  • ETag --> MD5SUM del file
  • Content-Length --> Dimensione o numero di byte dell'oggetto
# 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
  1. Per creare un nuovo bucket per l'utente:
# 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>
  1. Download di una chiave o di un file specifico in un bucket in un nodo 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
  1. Eliminazione di una chiave o di un file specifico nel bucket appartenente all'utente.
provo:/usr/share/s3curl # perl s3curl.pl --id <user ID> --delete -- http://<hostname or IP>:9020/<bucket>/<path1>/<path2>/<object>
 
Nota: Se il nome dell'oggetto ha uno spazio in mezzo, è necessario racchiudere tra virgolette l'intero percorso e aggiungere " + " nello spazio.
Nome dell'oggetto di esempio: 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"
  1. Eliminazione di un bucket appartenente all'utente.
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user --delete -- http://10.##.##.##7:9020/new_bucket_name

Il bucket non esiste dopo aver elencato i bucket appartenenti all'utente:
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>
  1. Leggere parzialmente un file utilizzando l'intestazione "byte: range" (vengono letti al di sotto dei primi sette caratteri)
  • Intervallo: i valori in byte includono:
I primi 500 byte: "byte 0-499/1234" I secondi 500 byte: "bytes 500-999/1234" Tutti tranne i primi 500 byte: "byte 500-1233/1234" Gli ultimi 500 byte: "byte 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.

Nota: L'opzione debug può essere utilizzata per qualsiasi 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
  1. Caricamento di un batch di file o chiavi in un bucket specifico.
  • Creare un file di esempio.
# vi /usr/share/s3curl/test

# cat /usr/share/s3curl/test

Questo file viene caricato 1000 volte in ECS.

  • Creare lo script seguente.
# 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
  • Modificare le autorizzazioni dello script.
# cd /usr/share/s3curl

# sudo chmod +755 
  • Eseguire lo script.
# sh script.s
  1. Scrittura di un file con uno spazio o un carattere speciale
  • Scrivere un file con un carattere di spazio chiamato "test file.txt" (richiede il valore ASCII %20)
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="test file.txt" -- http://10.##.##.##:9020/bucket_name/test%20file.txt
  • Scrivere un file con una parentesi speciale chiamata "testfile (1).txt" (richiede una barra " \ " per ignorare i caratteri speciali)
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="testfile (1).txt" -- http://10.##.##.##:9020/bucket_name/testfile%20\(1\).txt

Productos afectados

Elastic Cloud Storage

Productos

Elastic Cloud Storage
Propiedades del artículo
Número del artículo: 000014704
Tipo de artículo: How To
Última modificación: 20 oct. 2025
Versión:  5
Encuentre respuestas a sus preguntas de otros usuarios de Dell
Servicios de soporte
Compruebe si el dispositivo está cubierto por los servicios de soporte.