{"id":35022,"date":"2024-10-04T11:51:50","date_gmt":"2024-10-04T04:51:50","guid":{"rendered":"http:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/04\/use-s4cmd-with-object-storage\/"},"modified":"2024-10-04T11:51:50","modified_gmt":"2024-10-04T04:51:50","slug":"use-s4cmd-with-object-storage","status":"publish","type":"post","link":"https:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/04\/use-s4cmd-with-object-storage\/","title":{"rendered":"S\u1eed d\u1ee5ng s4cmd v\u1edbi Object Storage"},"content":{"rendered":"<p>Ph\u1ea7n m\u1ec1m s4cmd l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh c\u00f3 th\u1ec3 truy c\u1eadp c\u00e1c d\u1ecbch v\u1ee5 l\u01b0u tr\u1eef t\u01b0\u01a1ng th\u00edch v\u1edbi S3, ch\u1eb3ng h\u1ea1n nh\u01b0 Object Storage. N\u00f3 s\u1eed d\u1ee5ng \u1ee9ng d\u1ee5ng kh\u00e1ch S3 trong th\u01b0 vi\u1ec7n boto3 c\u1ee7a Amazon. So v\u1edbi c\u00f4ng c\u1ee5 s3cmd ph\u1ed5 bi\u1ebfn, s4cmd th\u01b0\u1eddng nhanh h\u01a1n nhi\u1ec1u nh\u01b0ng n\u00f3 c\u00f3 \u00edt t\u00f9y ch\u1ecdn h\u01a1n v\u00e0 \u00edt c\u1ea5u h\u00ecnh h\u01a1n. \u0110\u1ed1i v\u1edbi nhi\u1ec1u tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng, Linode CLI ho\u1eb7c s3cmd \u0111\u01b0\u1ee3c khuy\u00ean d\u00f9ng.<\/p>\n<h2 id=\"h-cai-d\u1eb7t-s4cmd\">C\u00e0i \u0111\u1eb7t s4cmd<\/h2>\n<p>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t S3cmd tr\u00ean c\u1ea3 h\u1ec7 th\u1ed1ng Mac v\u00e0 Linux, c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng pip tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i c\u1ee7a Python.<\/p>\n<pre class=\"wp-block-code\"><code>sudo pip c\u00e0i \u0111\u1eb7t s4cmd<\/code><\/pre>\n<p>M\u1ed9t s\u1ed1 b\u1ea3n ph\u00e2n ph\u1ed1i Linux c\u0169ng c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t s4cmd t\u1eeb tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i c\u1ee7a ri\u00eang ch\u00fang, nh\u01b0ng nh\u1eefng phi\u00ean b\u1ea3n \u0111\u00f3 c\u00f3 th\u1ec3 kh\u00f4ng c\u1eadp nh\u1eadt. Xem T\u1ea3i xu\u1ed1ng S3cmd \u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin.<\/p>\n<p>B\u1ea1n c\u00f3 th\u1ec3 t\u00ecm th\u1ea5y c\u00e1c ph\u01b0\u01a1ng ph\u00e1p c\u00e0i \u0111\u1eb7t s4cmd b\u1ed5 sung trong t\u1ec7p Readme s4cmd trong ph\u1ea7n C\u00e0i \u0111\u1eb7t v\u00e0 thi\u1ebft l\u1eadp.<\/p>\n<h2>\u0110\u1ecbnh c\u1ea5u h\u00ecnh th\u00f4ng tin x\u00e1c th\u1ef1c<\/h2>\n<p>\u0110\u1ec3 truy c\u1eadp c\u00e1c nh\u00f3m v\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng Object Storage, s4cmd c\u1ea7n bi\u1ebft Access Key v\u00e0 Secret Key \u0111\u1ec3 s\u1eed d\u1ee5ng. Theo m\u1eb7c \u0111\u1ecbnh, s4cmd t\u00ecm ki\u1ebfm nh\u1eefng th\u00f4ng tin x\u00e1c th\u1ef1c n\u00e0y trong t\u1ec7p ~\/.s3cfg, \u0111\u00e2y l\u00e0 t\u1ec7p c\u1ea5u h\u00ecnh m\u00e0 s3cmd s\u1eed d\u1ee5ng. N\u1ebfu b\u1ea1n ch\u01b0a c\u00e0i \u0111\u1eb7t v\u00e0 \u0111\u1ecbnh c\u1ea5u h\u00ecnh s3cmd, h\u00e3y t\u1ea1o t\u1ec7p n\u00e0y v\u00e0 th\u00eam c\u00e1c n\u1ed9i dung sau.<\/p>\n<pre class=\"wp-block-code\"><code>&#91;default]\naccess_key = YOUR_ACCESS_KEY\nsecret_key = YOUR_SECRET_KEY<\/code><\/pre>\n<p>Thay th\u1ebf YOUR_ACCESS_KEY v\u00e0 YOUR_SECRET_KEY b\u1eb1ng access key v\u00e0 secret key \u0111\u00e3 t\u1ea1o tr\u00ean t\u00e0i kho\u1ea3n Linode c\u1ee7a b\u1ea1n. N\u1ebfu b\u1ea1n ch\u01b0a t\u1ea1o nh\u1eefng th\u00f4ng tin x\u00e1c th\u1ef1c n\u00e0y, h\u00e3y l\u00e0m theo h\u01b0\u1edbng d\u1eabn Qu\u1ea3n l\u00fd kh\u00f3a truy c\u1eadp.<\/p>\n<p>B\u1ea1n c\u00f3 th\u1ec3 t\u00ecm th\u1ea5y c\u00e1c ph\u01b0\u01a1ng ph\u00e1p \u0111\u1ecbnh c\u1ea5u h\u00ecnh th\u00f4ng tin x\u00e1c th\u1ef1c b\u1ed5 sung tr\u00ean t\u1ec7p s4cmd Readme trong ph\u1ea7n C\u00e0i \u0111\u1eb7t v\u00e0 Thi\u1ebft l\u1eadp<\/p>\n<h2>Ch\u1ec9 \u0111\u1ecbnh url \u0111i\u1ec3m cu\u1ed1i<\/h2>\n<p>Ban \u0111\u1ea7u, s4cmd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng cho Amazon S3. \u0110\u1ec3 cho ph\u00e9p c\u00e1c gi\u1ea3i ph\u00e1p t\u01b0\u01a1ng th\u00edch v\u1edbi S3 kh\u00e1c s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 n\u00e0y, t\u00f9y ch\u1ecdn l\u1ec7nh &#8211;endpoint-url \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o. Khi ch\u1ea1y b\u1ea5t k\u1ef3 l\u1ec7nh s4cmd n\u00e0o, b\u1ea1n s\u1ebd c\u1ea7n ch\u1ec9 \u0111\u1ecbnh url \u0111i\u1ec3m cu\u1ed1i \u0111\u1ea7y \u0111\u1ee7 c\u1ee7a C\u1ee5m l\u01b0u tr\u1eef \u0111\u1ed1i t\u01b0\u1ee3ng m\u00e0 nh\u00f3m c\u1ee7a b\u1ea1n n\u1eb1m trong \u0111\u00f3. \u0110\u1ec3 bi\u1ebft danh s\u00e1ch \u0111\u1ea7y \u0111\u1ee7 c\u00e1c C\u1ee5m v\u00e0 \u0111i\u1ec3m cu\u1ed1i S3 \u0111\u01b0\u1ee3c li\u00ean k\u1ebft c\u1ee7a ch\u00fang, h\u00e3y xem h\u01b0\u1edbng d\u1eabn Truy c\u1eadp nh\u00f3m v\u00e0 t\u1ec7p th\u00f4ng qua URL).<\/p>\n<p>V\u00ed d\u1ee5: l\u1ec7nh sau s\u1ebd li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c nh\u00f3m trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd ls --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<h2>T\u01b0\u01a1ng t\u00e1c v\u1edbi x\u00f4<\/h2>\n<p><strong>Li\u1ec7t k\u00ea c\u00e1c nh\u00f3m<\/strong><\/p>\n<p>L\u1ec7nh: s4cmd ls<\/p>\n<p>V\u00ed d\u1ee5: Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c nh\u00f3m tr\u00ean t\u00e0i kho\u1ea3n trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd ls --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<h2>T\u1ea1o bucket<\/h2>\n<p>L\u1ec7nh: s4cmd mb s3:\/\/[bucket-label], thay th\u1ebf [nh\u00e3n nh\u00f3m] b\u1eb1ng nh\u00e3n b\u1ea1n mu\u1ed1n s\u1eed d\u1ee5ng cho nh\u00f3m m\u1edbi.<\/p>\n<p>V\u00ed d\u1ee5: T\u1ea1o m\u1ed9t nh\u00f3m c\u00f3 nh\u00e3n &#8220;example-bucket&#8221; trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd mb s3:\/\/example-bucket --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<h2>X\u00f3a bucket<\/h2>\n<p>Hi\u1ec7n t\u1ea1i kh\u00f4ng c\u00f3 l\u1ec7nh x\u00e1c \u0111\u1ecbnh n\u00e0o \u0111\u1ec3 x\u00f3a nh\u00f3m th\u00f4ng qua s4cmd.<\/p>\n<p>T\u01b0\u01a1ng t\u00e1c v\u1edbi \u0111\u1ed3 v\u1eadt<\/p>\n<h2>Li\u1ec7t k\u00ea c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng<\/h2>\n<p><strong>L\u1ec7nh<\/strong>: s4cmd ls [path], trong \u0111\u00f3 [path] l\u00e0 \u0111\u01b0\u1eddng d\u1eabn c\u1ee7a th\u01b0 m\u1ee5c b\u1ea1n mu\u1ed1n xem trong m\u1ed9t nh\u00f3m.<\/p>\n<p><strong>V\u00ed d\u1ee5:<\/strong> Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng trong nh\u00f3m c\u00f3 t\u00ean l\u00e0 &#8220;example-bucket&#8221;, n\u1eb1m trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd ls s3:\/\/example-bucket\/ --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<h2>T\u1ea3i l\u00ean m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng<\/h2>\n<p><strong>L\u1ec7nh<\/strong>: s4cmd \u0111\u1eb7t [t\u1ec7p] s3:\/\/[nh\u00e3n nh\u00f3m]\/[\u0111\u01b0\u1eddng d\u1eabn], thay th\u1ebf [t\u1ec7p] b\u1eb1ng t\u00ean v\u00e0 \u0111\u01b0\u1eddng d\u1eabn c\u1ee7a t\u1ec7p b\u1ea1n mu\u1ed1n t\u1ea3i l\u00ean, [nh\u00e3n nh\u00f3m] b\u1eb1ng nh\u00e3n cho nh\u00f3m c\u1ee7a b\u1ea1n v\u00e0 [path] b\u1eb1ng th\u01b0 m\u1ee5c t\u00f9y ch\u1ecdn trong nh\u00f3m.<\/p>\n<p><strong>V\u00ed d\u1ee5<\/strong>: T\u1ea3i t\u1ec7p &#8220;file.txt&#8221; l\u00ean b\u1ed9 ch\u1ee9a c\u00f3 t\u00ean &#8220;example-bucket&#8221;, n\u1eb1m trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd \u0111\u1eb7t file.txt s3:\/\/example-bucket\/ --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#cdf9e9\">Vi\u1ec7c t\u1ea3i l\u00ean ho\u1eb7c \u0111\u1ed5i t\u00ean \u0111\u1ed1i t\u01b0\u1ee3ng b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng c\u00e1c k\u00fd t\u1ef1 \u0111\u1eb7c bi\u1ec7t kh\u00f4ng chu\u1ea9n v\u00e0 c\u00e1c k\u00fd t\u1ef1 ASCII\/Unicode b\u1ea5t th\u01b0\u1eddng c\u00f3 th\u1ec3 g\u00e2y ra s\u1ef1 c\u1ed1. \u0110i\u1ec1u n\u00e0y bao g\u1ed3m c\u00e1c k\u00fd t\u1ef1: : &#8221; &#8216; &lt; &gt; &amp; + =.<\/p>\n<h2>T\u1ea3i xu\u1ed1ng m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng ho\u1eb7c th\u01b0 m\u1ee5c<\/h2>\n<p>L\u1ec7nh: s4cmd get s3:\/\/[bucket-label]\/[path], thay th\u1ebf [bucket-label] b\u1eb1ng nh\u00e3n cho v\u00f9ng ch\u1ee9a c\u1ee7a b\u1ea1n v\u00e0 [path] b\u1eb1ng \u0111\u01b0\u1eddng d\u1eabn \u0111\u1ea7y \u0111\u1ee7 v\u00e0 t\u00ean t\u1ec7p t\u00f9y ch\u1ecdn c\u1ee7a t\u1ec7p ho\u1eb7c th\u01b0 m\u1ee5c b\u1ea1n mu\u1ed1n t\u1ea3i xu\u1ed1ng .<\/p>\n<p>V\u00ed d\u1ee5: T\u1ea3i xu\u1ed1ng t\u1ec7p &#8220;file.txt&#8221; t\u1eeb nh\u00f3m c\u00f3 t\u00ean &#8220;example-bucket&#8221;, n\u1eb1m trong trung t\u00e2m d\u1eef li\u1ec7u Newark:<\/p>\n<pre class=\"wp-block-code\"><code>s4cmd nh\u1eadn s3:\/\/example-bucket\/file.txt --endpoint-url https:\/\/us-east-1.linodeobjects.com<\/code><\/pre>\n<p>Ngu\u1ed3n: https:\/\/techdocs.akamai.com\/cloud-computing\/docs\/using-s4cmd-with-object-storage<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ph\u1ea7n m\u1ec1m s4cmd l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh c\u00f3 th\u1ec3 truy c\u1eadp c\u00e1c d\u1ecbch v\u1ee5 l\u01b0u tr\u1eef t\u01b0\u01a1ng th\u00edch v\u1edbi S3, ch\u1eb3ng h\u1ea1n nh\u01b0 Object Storage. N\u00f3 s\u1eed d\u1ee5ng \u1ee9ng d\u1ee5ng kh\u00e1ch S3 trong th\u01b0 vi\u1ec7n boto3 c\u1ee7a Amazon. So v\u1edbi c\u00f4ng c\u1ee5 s3cmd ph\u1ed5 bi\u1ebfn, s4cmd th\u01b0\u1eddng nhanh h\u01a1n nhi\u1ec1u nh\u01b0ng n\u00f3 c\u00f3<\/p>\n","protected":false},"author":1,"featured_media":36212,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103],"tags":[],"class_list":["post-35022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-clients-and-tooling"],"_links":{"self":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/comments?post=35022"}],"version-history":[{"count":0,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35022\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media\/36212"}],"wp:attachment":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media?parent=35022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/categories?post=35022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/tags?post=35022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}