ECS:如何使用 s3test.sh 指令檔測試 S3 建立容器、上傳物件、讀取物件、刪除物件、刪除容器
Summary: 如何使用 s3test 指令檔測試 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 知識文章,以協助確認 S3 功能:
ECS:如何使用 s3curl.pl 指令檔執行基本的 S3 作業。
1: 以根使用者身分,透過 SSH 登入 ECS 節點。
2: 使用 vi 建立檔案:
/usr/share/s3curl/s3test.sh
3: 將以下內容複製到檔案中。請務必 修改目標 IP 以符合您的 ECS IP,因為指令檔會在目標中所放置的任何 IP 上執行。關於 S3CURL_ID,請參閱 ECS:如何使用 s3curl.pl 指令檔執行基本的 S3 作業。
!/bin/bash
TARGET="10.xx.xx.xx7 10.xx.xx.xx8 10.xx.xx.xx9 10.xx.xx.xx0"
S3CURL="/usr/share/s3curl/s3curl.pl"
S3CURL_ID="--id=friendlymick"
OBJECT_NAME="newfile"cat
echo "s3curl upload test" > $OBJECT_NAME
PASS="echo -e \e[32mPASSED\e[0m"
FAIL="echo -e \e[31mFAILED\e[0m"
for ip in $(echo $TARGET)
do
echo
echo "Node - $ip"
BUCKET_NAME="bucket_$(date +%d%b_%H%M)_${ip}"
echo "Bucket/Object name: $BUCKET_NAME/$OBJECT_NAME"
echo "---------------------------------------------------------"
# Test bucket creation
echo -n "Create Bucket: "
STATUS=$($S3CURL $S3CURL_ID --createBucket -- http://${ip}:9020/${BUCKET_NAME} -s -w "%{http_code}" -o /dev/null 2> /dev/null)
test ${STATUS:-0} -eq 200 && $PASS || { $FAIL; continue; }
# Upload Object
echo -n "Upload Object: "
STATUS=$($S3CURL $S3CURL_ID --put $OBJECT_NAME -- http://${ip}:9020/${BUCKET_NAME}/${OBJECT_NAME} -s -w "%{http_code}" -o /dev/null 2> /dev/null)
test ${STATUS:-0} -eq 200 && $PASS || $FAIL
# Read Object
echo -n "Read Object: "
STATUS=$($S3CURL $S3CURL_ID -- http://${ip}:9020/${BUCKET_NAME}/${OBJECT_NAME} -s 2> /dev/null)
test "$STATUS" == "s3curl upload test" && $PASS || $FAIL
# Delete Object
echo -n "Delete Object: "
STATUS=$($S3CURL $S3CURL_ID --delete -- http://${ip}:9020/${BUCKET_NAME}/${OBJECT_NAME} -s -w "%{http_code}" -o /dev/null 2> /dev/null)
test ${STATUS:-0} -eq 204 && $PASS || $FAIL
# Delete Bucket
echo -n "Delete Bucket: "
STATUS=$($S3CURL $S3CURL_ID --delete -- http://${ip}:9020/${BUCKET_NAME} -s -w "%{http_code}" -o /dev/null 2> /dev/null)
test ${STATUS:-0} -eq 204 && $PASS || $FAIL
# Verifying Deletion
echo -n "Verify Deletion of bucket: "
STATUS=$($S3CURL $S3CURL_ID -- http://${ip}:9020/${BUCKET_NAME} -s -w "%{http_code}" -o /dev/null 2> /dev/null)
test ${STATUS:-0} -eq 404 && $PASS || $FAIL
done
4:送出下列命令以執行指令檔:
# SH s3test.sh
所有測試都應顯示為通過。如果某些測試未傳回「通過」,請聯絡 ECS 支援。
provo:/usr/share/s3curl # sh s3test.sh Node - 10.xx.xx.xx7 Bucket/Object name: bucket_14Apr_1009_10.xx.xx.xx7/newfile --------------------------------------------------------- Create Bucket: PASSED Upload Object: PASSED Read Object: PASSED Delete Object: PASSED Delete Bucket: PASSED Verify Deletion of bucket: PASSED Node - 10.xx.xx.xx8 Bucket/Object name: bucket_14Apr_1009_10.xx.xx.xx8/newfile --------------------------------------------------------- Create Bucket: PASSED Upload Object: PASSED Read Object: PASSED Delete Object: PASSED Delete Bucket: PASSED Verify Deletion of bucket: PASSED Node - 10.xx.xx.xx9 Bucket/Object name: bucket_14Apr_1009_10.xx.xx.xx9/newfile --------------------------------------------------------- Create Bucket: PASSED Upload Object: PASSED Read Object: PASSED Delete Object: PASSED Delete Bucket: PASSED Verify Deletion of bucket: PASSED Node - 10.xx.xx.xx0 Bucket/Object name: bucket_14Apr_1009_10.xx.xx.xx0/newfile --------------------------------------------------------- Create Bucket: PASSED Upload Object: PASSED Read Object: PASSED Delete Object: PASSED Delete Bucket: PASSED Verify Deletion of bucket: PASSED
Affected Products
ECS Appliance Hardware Gen1 U-SeriesProducts
ECS Appliance Hardware Gen1 U-Series, ECS Appliance Software with Encryption, ECS Appliance Software without EncryptionArticle Properties
Article Number: 000023816
Article Type: How To
Last Modified: 08 Sep 2025
Version: 6
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.