MinIO客戶端快速入門指南


官方文檔地址:http://docs.minio.org.cn/docs/master/minio-client-quickstart-guide

MinIO Client (mc)為ls,cat,cp,mirror,diff,find等UNIX命令提供了一種替代方案。它支持文件系統和兼容Amazon S3的雲存儲服務(AWS Signature v2和v4)。

ls       列出文件和文件夾。
mb       創建一個存儲桶或一個文件夾。
cat      顯示文件和對象內容。
pipe     將一個STDIN重定向到一個對象或者文件或者STDOUT。
share    生成用於共享的URL。
cp       拷貝文件和對象。
mirror   給存儲桶和文件夾做鏡像。
find     基於參數查找文件。
diff     對兩個文件夾或者存儲桶比較差異。
rm       刪除文件和對象。
events   管理對象通知。
watch    監聽文件和對象的事件。
policy   管理訪問策略。
session  為cp命令管理保存的會話。
config   管理mc配置文件。
update   檢查軟件更新。
version  輸出版本信息。

GNU/Linux 二進制文件

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
./mc --help

添加一個雲存儲服務

添加一個或多個S3兼容的服務,請參考下面說明。mc將所有的配置信息都存儲在~/.mc/config.json文件中。

mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> [--api API-SIGNATURE]

別名就是給你的雲存儲服務起了一個短點的外號。S3 endpoint,access key和secret key是你的雲存儲服務提供的。API簽名是可選參數,默認情況下,它被設置為"S3v4"。

示例-MinIO雲存儲

從MinIO服務獲得URL、access key和secret key。

URL需要指定端口
access key和secret key在新版里是指用戶名和密碼

# ./mc config host add minio https://192.168.20.102:9000 admin 12345678 --api s3v4
Added `minio` successfully.

說明:

  1. https://192.168.20.102:9000

根據實際啟動后的MinIO服務端地址來定

  • https: 自定義生成的證書,需要在服務器中進行有關設置,否則會報錯:Get "https://192.168.20.102:9001/": x509: certificate signed by unknown authority
# cp /root/.minio/certs/public.crt  /etc/pki/ca-trust/source/anchors/
cp /usr/local/minio/etc/certs/public.crt  /etc/pki/ca-trust/source/anchors/ # 配置路徑目錄下的certs目錄下的證書,參考Minio配置TLS訪問
ln -s /etc/pki/ca-trust/source/anchors/public.crt  /etc/ssl/certs/public.crt
update-ca-trust
  • 不加端口號,表示使用的是https默認的443端口號,可以添加成功,但是訪問服務端則會報錯:Get "https://192.168.20.102/": dial tcp 192.168.20.102:443: connect: connection refused
  • 使用9001端口,可以添加成功,但是訪問服務端則會報錯:S3 API Request made to Console port. S3 Requests should be sent to API port.
  1. admin 12345678
    web頁面訪問使用的用戶名和密碼

mc配置信息:

# cat ~/.mc/config.json
{
        "version": "10",
        "aliases": {
                "minio": {
                        "url": "https://192.168.20.102:9000",
                        "accessKey": "admin",
                        "secretKey": "12345678",
                        "api": "s3v4",
                        "path": "auto"
                },
                "gcs": {
                        "url": "https://storage.googleapis.com",
                        "accessKey": "YOUR-ACCESS-KEY-HERE",
                        "secretKey": "YOUR-SECRET-KEY-HERE",
                        "api": "S3v2",
                        "path": "dns"
                },
                "local": {
                        "url": "http://localhost:9000",
                        "accessKey": "",
                        "secretKey": "",
                        "api": "S3v4",
                        "path": "auto"
                },
                "play": {
                        "url": "https://play.min.io",
                        "accessKey": "Q3AM3UQ867SPQQA43P2F",
                        "secretKey": "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
                        "api": "S3v4",
                        "path": "auto"
                },
                "s3": {
                        "url": "https://s3.amazonaws.com",
                        "accessKey": "YOUR-ACCESS-KEY-HERE",
                        "secretKey": "YOUR-SECRET-KEY-HERE",
                        "api": "S3v4",
                        "path": "dns"
                }
        }
}

Shell別名

可以添加shell別名來覆蓋默認的Unix工具命令。

alias ls='mc ls'
alias cp='mc cp'
alias cat='mc cat'
alias mkdir='mc mb'
alias pipe='mc pipe'
alias find='mc find'

Shell自動補全

下載autocomplete/bash_autocomplete到/etc/bash_completion.d/,然后將其重命名為mc。別忘了在這個文件運行source命令讓其在你的當前shell上可用。

sudo wget https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete -O /etc/bash_completion.d/mc
source /etc/bash_completion.d/mc

mc <TAB>
admin    config   diff     ls       mirror   policy   session  update   watch
cat      cp       events   mb       pipe     rm       share    version

mc命令參數

NAME:
  mc - MinIO Client for cloud storage and filesystems.

USAGE:
  mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]

COMMANDS:
  alias      manage server credentials in configuration file
  ls         list buckets and objects
  mb         make a bucket
  rb         remove a bucket
  cp         copy objects
  mv         move objects
  rm         remove object(s)
  mirror     synchronize object(s) to a remote site
  cat        display object contents
  head       display first 'n' lines of an object
  pipe       stream STDIN to an object
  find       search for objects
  sql        run sql queries on objects
  stat       show object metadata
  tree       list buckets and objects in a tree format
  du         summarize disk usage recursively
  retention  set retention for object(s)
  legalhold  manage legal hold for object(s)
  support    support related commands
  share      generate URL for temporary access to an object
  version    manage bucket versioning
  ilm        manage bucket lifecycle
  encrypt    manage bucket encryption config
  event      manage object notifications
  watch      listen for object notification events
  undo       undo PUT/DELETE operations
  anonymous  manage anonymous access to buckets and objects
  tag        manage tags for bucket and object(s)
  diff       list differences in object name, size, and date between two buckets
  replicate  configure server side bucket replication
  admin      manage MinIO servers
  update     update mc to latest release
  
GLOBAL FLAGS:
  --autocompletion              install auto-completion for your shell
  --config-dir value, -C value  path to configuration folder (default: "/root/.mc")
  --quiet, -q                   disable progress bar display
  --no-color                    disable color theme
  --json                        enable JSON lines formatted output
  --debug                       enable debug output
  --insecure                    disable SSL certificate verification
  --help, -h                    show help
  --version, -v                 print the version
  
TIP:
  Use 'mc --autocompletion' to enable shell autocompletion

VERSION:
  RELEASE.2022-03-09T02-08-36Z


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM