LoginSignup
3
3

More than 3 years have passed since last update.

minioクライアント(mc コマンド)の使い方

Posted at

はじめに

mcコマンドにより、minio(S3, GCS等でも可)をクライアント側からCUIで操作できる。インストール手順から簡単な使い方まで説明する。

インストール方法

下記URLの通りだが、記載しておく。
https://docs.min.io/docs/minio-client-quickstart-guide.html#test-your-setup

macOS

$ brew install minio/stable/mc

GNU/Linux

# 64-bit Intel Architectureの場合
$ wget https://dl.min.io/client/mc/release/linux-amd64/mc
# 64-bit PPC Architectureの場合
$ wget https://dl.min.io/client/mc/release/linux-ppc64le/mc
$ chmod +x mc

Microsoft Windows

下記から実行ファイルをダウンロードする。
https://dl.min.io/client/mc/release/windows-amd64/mc.exe

設定方法

立ち上げたminioの設定を~/.mc/config.jsonに記載して、mcコマンドが使えるようになる。
私の環境だと"lookup": "dns"とするとうまくいかなかった。

下記のようなminioの設定の場合で~/.mc/config.jsonを記載する。
host名 : hoge
ipアドレス or ドメイン : hoge.com
ポート : 9000
アクセスキー : minio
シークレットキー : minio123

~/.mc/config.json
{
        "version": "9",
        "hosts": {
                "hoge": {
                        "url": "http://hoge.com:9000/",
                        "accessKey": "minio",
                        "secretKey": "minio123",
                        "api": "S3v4",
                        "lookup": "auto"
                }
        }
}

コマンド

簡単な使い方を記載する。詳しくはhelpを参照。

# バケットを作成する
$ mc mb hoge/test
Bucket created successfully `hoge/test`.
# バケットとオブジェクトを確認する
$ mc ls hoge
[2020-02-19 11:07:39 JST]      0B test/
# ローカルからminioにコピーする
$ touch test.txt
$ mc cp test.txt hoge/test
$ mc ls hoge/test
[2020-02-19 11:10:27 JST]      0B test.txt
# minioからローカルにコピーする
$ rm test.txt
$ mc cp hoge/test/test.txt ./
# オブジェクトを削除する
$ mc rm hoge/test/test.txt
Removing `hoge/test/test.txt`.
$ mc ls hoge/test
# バケットを削除する
$ mc rb hoge/test
Removed `hoge/test` successfully.
$ mc ls hoge
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3