mc config

在 “MinIO客户端mc命令” 介绍了 mc 命令的基础用法,本章节将介绍怎样使用 mc config 命令配置 MinIO 客户端。

使用 mc config -h 命令查看 mc config 的帮助信息,如下:

C:\> mc config -h
NAME:
  mc config - configure MinIO client

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

COMMANDS:
  host  add, remove and list hosts in configuration file

FLAGS:
  --config-dir value, -C value  path to configuration folder (default: "C:\\Users\\Administrator\\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

其中,host 命令用来添加、删除和列出配置文件中的服务主机。

我们继续使用 “mc config host -h” 命令查看 mc config host 子命令的帮助信息,如下:

C:\> mc config host -h
NAME:
  mc config host - add, remove and list hosts in configuration file

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

COMMANDS:
  add, a      add a new host to configuration file(添加新的host到配置文件)
  remove, rm  remove a host from configuration file(从配置文件中删除host)
  list, ls    list hosts in configuration file(查看配置文件件中的host列表)

FLAGS:
  --config-dir value, -C value  path to configuration folder (default: "C:\\Users\\Administrator\\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

示例

查看 HOST 列表

使用 mc config host list 命令列出 MinIO 客户端中的所有 host,如下:

D:\server\minio>mc config host list
gcs
  URL       : https://storage.googleapis.com
  AccessKey : YOUR-ACCESS-KEY-HERE
  SecretKey : YOUR-SECRET-KEY-HERE
  API       : S3v2
  Path      : dns

local
  URL       : http://127.0.0.1:9000
  AccessKey : root
  SecretKey : mypassword
  API       : s3v4
  Path      : auto
...省略...
s3
  URL       : https://s3.amazonaws.com
  AccessKey : YOUR-ACCESS-KEY-HERE
  SecretKey : YOUR-SECRET-KEY-HERE
  API       : S3v4
  Path      : dns

当然,也可以直接编辑 C:\Users\Administrator\mc\config.json 文件查看,该文件部分内容如下:

{
    "version": "10",
    "aliases": {
        "gcs": {
            "url": "https://storage.googleapis.com",
            "accessKey": "YOUR-ACCESS-KEY-HERE",
            "secretKey": "YOUR-SECRET-KEY-HERE",
            "api": "S3v2",
            "path": "dns"
        },
        "local": {
            "url": "http://127.0.0.1:9000",
            "accessKey": "root",
            "secretKey": "mypassword",
            "api": "s3v4",
            "path": "auto"
        },
        //...
        "s3": {
            "url": "https://s3.amazonaws.com",
            "accessKey": "YOUR-ACCESS-KEY-HERE",
            "secretKey": "YOUR-SECRET-KEY-HERE",
            "api": "S3v4",
            "path": "dns"
        }
    }
}

添加新的 HOST

先看看 mc config host add 命令的帮助信息,如下:

D:\server\minio>mc config host add -h
NAME:
  mc config host add - add a new host to configuration file

USAGE:
  mc config host add [command options] [arguments...]

FLAGS:
  --lookup value                bucket lookup supported by the server. Valid options are '[dns, path, auto]' (default: "auto")
  --api value                   API signature(API 签名). Valid options are '[S3v4, S3v2]'
  --config-dir value, -C value  path to configuration folder (default: "C:\\Users\\Administrator\\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

命令模板:

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

其中:

  • ALIAS 别名就是给你的云存储服务起了一个短点的外号。

  • YOUR-S3-ENDPOINT 云存储的主机和端口,如:http://127.0.0.1:9000

  • YOUR-ACCESS-KEY 云存储服务的 Access Key

  • YOUR-SECRET-KEY 云存储服务的 Secret Key

  • API-SIGNATURE API签名是可选参数,默认情况下它被设置为 "S3v4"

示例-MinIO云存储

从MinIO服务获得URL、access key和secret key:

mc config host add minio http://127.0.0.1 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4

示例-Amazon S3云存储

参考AWS Credentials指南获取你的AccessKeyID和SecretAccessKey:

mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4

示例-Google云存储

参考Google Credentials Guide获取你的AccessKeyID和SecretAccessKey:

mc config host add gcs  https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v2

注意:Google 云存储只支持旧版签名版本 V2,所以你需要选择 S3v2

删除 HOST

删除名为 minio 的 HOST 配置,如下:

D:\server\minio>mc config host remove minio
Removed `minio` successfully.
说说我的看法
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号