github.com/minio/mc@v0.0.0-20240507152021-646712d5e5fb/README_zh_CN.md (about) 1 # MinIO客户端快速入门指南 2 [](https://slack.min.io) [](https://goreportcard.com/report/minio/mc) [](https://hub.docker.com/r/minio/mc/) 3 4 MinIO Client (mc)为ls,cat,cp,mirror,diff,find等UNIX命令提供了一种替代方案。它支持文件系统和兼容Amazon S3的云存储服务(AWS Signature v2和v4)。 5 6 7 ``` 8 ls 列出文件和文件夹。 9 mb 创建一个存储桶或一个文件夹。 10 cat 显示文件和对象内容。 11 pipe 将一个STDIN重定向到一个对象或者文件或者STDOUT。 12 share 生成用于共享的URL。 13 cp 拷贝文件和对象。 14 mirror 给存储桶和文件夹做镜像。 15 find 基于参数查找文件。 16 diff 对两个文件夹或者存储桶比较差异。 17 rm 删除文件和对象。 18 events 管理对象通知。 19 watch 监听文件和对象的事件。 20 anonymous 管理访问策略。 21 session 为cp命令管理保存的会话。 22 config 管理mc配置文件。 23 update 检查软件更新。 24 version 输出版本信息。 25 ``` 26 27 ## Docker容器 28 ### 稳定版 29 ``` 30 docker pull minio/mc 31 docker run minio/mc ls play 32 ``` 33 34 ### 尝鲜版 35 ``` 36 docker pull minio/mc:edge 37 docker run minio/mc:edge ls play 38 ``` 39 40 **注意:** 上述示例默认使用MinIO[演示环境](#test-your-setup)做演示,如果想用`mc`操作其它S3兼容的服务,采用下面的方式来启动容器: 41 42 ``` 43 docker run -it --entrypoint=/bin/sh minio/mc 44 ``` 45 46 然后使用[`mc config`命令](#add-a-cloud-storage-service)。 47 48 ## macOS 49 ### Homebrew 50 使用[Homebrew](http://brew.sh/)安装mc。 51 52 ``` 53 brew install minio/stable/mc 54 mc --help 55 ``` 56 57 ## GNU/Linux 58 ### 下载二进制文件 59 | 平台 | CPU架构 | URL | 60 | ---------- | -------- |------| 61 |GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc | 62 63 ``` 64 chmod +x mc 65 ./mc --help 66 ``` 67 68 ## Microsoft Windows 69 ### 下载二进制文件 70 | 平台 | CPU架构 | URL | 71 | ---------- | -------- |------| 72 |Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe | 73 74 ``` 75 mc.exe --help 76 ``` 77 78 ## 通过源码安装 79 通过源码安装仅适用于开发人员和高级用户。`mc update`命令不支持基于源码安装的更新通知。请从https://min.io/download/#minio-client下载官方版本。 80 81 如果您没有Golang环境,请参照[如何安装Golang](https://golang.org/doc/install)。 82 83 ``` 84 go get -d github.com/minio/mc 85 cd ${GOPATH}/src/github.com/minio/mc 86 make 87 ``` 88 89 ## 添加一个云存储服务 90 如果你打算仅在POSIX兼容文件系统中使用`mc`,那你可以直接略过本节,跳到[日常使用](#everyday-use)。 91 92 添加一个或多个S3兼容的服务,请参考下面说明。`mc`将所有的配置信息都存储在``~/.mc/config.json``文件中。 93 94 ``` 95 mc alias set <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> [--api API-SIGNATURE] 96 ``` 97 98 别名就是给你的云存储服务起了一个短点的外号。S3 endpoint,access key和secret key是你的云存储服务提供的。API签名是可选参数,默认情况下,它被设置为"S3v4"。 99 100 ### 示例-MinIO云存储 101 从MinIO服务获得URL、access key和secret key。 102 103 ``` 104 mc alias set minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4 105 ``` 106 107 ### 示例-Amazon S3云存储 108 参考[AWS Credentials指南](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html)获取你的AccessKeyID和SecretAccessKey。 109 110 ``` 111 mc alias set s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4 112 ``` 113 114 ### 示例-Google云存储 115 参考[Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys)获取你的AccessKeyID和SecretAccessKey。 116 117 ``` 118 mc alias set gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v2 119 ``` 120 121 注意:Google云存储只支持旧版签名版本V2,所以你需要选择S3v2。 122 123 ## 验证 124 `mc`预先配置了云存储服务URL:https://play.min.io,别名“play”。它是一个用于研发和测试的MinIO服务。如果想测试Amazon S3,你可以将“play”替换为“s3”。 125 126 *示例:* 127 128 列出https://play.min.io上的所有存储桶。 129 130 ``` 131 mc ls play 132 [2016-03-22 19:47:48 PDT] 0B my-bucketname/ 133 [2016-03-22 22:01:07 PDT] 0B mytestbucket/ 134 [2016-03-22 20:04:39 PDT] 0B mybucketname/ 135 [2016-01-28 17:23:11 PST] 0B newbucket/ 136 [2016-03-20 09:08:36 PDT] 0B s3git-test/ 137 ``` 138 <a name="everyday-use"></a> 139 ## 日常使用 140 141 ### Shell别名 142 你可以添加shell别名来覆盖默认的Unix工具命令。 143 144 ``` 145 alias ls='mc ls' 146 alias cp='mc cp' 147 alias cat='mc cat' 148 alias mkdir='mc mb' 149 alias pipe='mc pipe' 150 alias find='mc find' 151 ``` 152 153 ### Shell自动补全 154 你也可以下载[`autocomplete/bash_autocomplete`](https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete)到`/etc/bash_completion.d/`,然后将其重命名为`mc`。别忘了在这个文件运行source命令让其在你的当前shell上可用。 155 156 ``` 157 sudo wget https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete -O /etc/bash_completion.d/mc 158 source /etc/bash_completion.d/mc 159 ``` 160 161 ``` 162 mc <TAB> 163 admin config diff ls mirror policy session update watch 164 cat cp events mb pipe rm share version 165 ``` 166 167 ## 了解更多 168 - [MinIO Client完全指南](https://min.io/docs/minio/linux/reference/minio-mc.html?ref=gh) 169 - [MinIO快速入门](https://min.io/docs/minio/linux/index.html#quickstart-for-linux?ref=gh) 170 - [MinIO官方文档](https://min.io/docs/minio/linux/index.html?ref=gh) 171 172 ## 贡献 173 请遵守MinIO[贡献者指南](https://github.com/minio/mc/blob/master/docs/zh_CN/CONTRIBUTING.md)