MinIO 是一个基于 Apache License v2.0 开源协议的对象存储服务。它兼容亚马逊 S3 云存储服务接口,很是适合于存储大容量非结构化的数据,例如图片、视频、日志文件、备份数据和容器/虚拟机镜像等,而一个对象文件能够是任意大小,从几 kb 到最大 5T 不等。linux
MinIO 是一个很是轻量的服务,能够很简单的和其余应用的结合,相似 NodeJS, Redis 或者 MySQL。git
官方对 Minio 的定义是一个高性能的对象存储。github
Build high performance data infrastructure
for machine learning, analytics and
application data workloads with MinIO 。docker
Minio 的官方网站是 https://min.io ,
Minio 的官方文档是 https://docs.min.io/cn/ ,
GitHub 仓库地址是:https://github.com/minio/minio ,目前有 18.8k Stars (2019.11.9)安全
Minio 的 benchmark 说明:服务器
https://min.io/resources/docs/MinIO-vs-HDFS-MapReduce-performance-comparison.pdf
https://min.io/resources/docs/MinIO-throughput-benchmarks-on-NVMe-SSD.pdf
https://min.io/resources/docs/Performance-comparison-Starburst-Presto-SQL.pdf
https://min.io/resources/docs/MinIO-throughput-benchmarks-on-HDD.pdf
https://min.io/resources/docs/Performance-comparison-Apache-Spark.pdfapp
MinIO 分为服务端和客户端,服务端提供一个对象存储,也提供一个 Web 的管理页面。客户端是用来管理、查看服务端的一个工具。服务端的二进制文件是 minio
,客户端的二进制文件是 mc
。dom
首先先下载服务端的二进制文件,其次准备一个用来存储的磁盘或者目录,ide
下载好之后赋予执行权限,可使用以下命令快速启动。工具
chmod +x minio ./minio server /erdong/data
启动后能够经过访问 http://localhost:9000 来访问你的对象存储。
MinIO 须要一个持久卷来存储配置和应用数据。不过, 若是只是为了测试一下, 您能够经过简单地传递一个目录(在下面的示例中为 /erdong/data
)启动 MinIO 。这个目录会在容器启动时在容器的文件系统中建立,不过全部的数据都会在容器退出时丢失。
要建立具备永久存储的 MinIO 容器,您须要将本地持久目录从主机操做系统映射到虚拟配置 ~/.minio 并导出 /data 目录。 为此,请运行如下命令
docker run -p 9000:9000 --name minio \ -e "MINIO_ACCESS_KEY=minioadmin" \ -e "MINIO_SECRET_KEY=minioadminpassword" \ -v /erdong/minio/data:/data \ -v /erdong/minio/config:/root/.minio \ minio/minio server /data
启动后,便可访问 http://localhost:9000 来访问你的对象存储。
上述命令中设置了以下参数:
若是须要指定端口可使用以下参数
--address ":9000"
接下来咱们看看如何在 linux 上配置 MinIO 服务使用 TLS 。
使用 TLS 的前提是先下载好 MinIO Server 。
若是你已经有私钥和公钥证书,你须要将他们拷贝到 MinIO 的 $HOME/.minio/certs
文件夹,私钥的名字必须是 private.key
,公钥证书的名字必须是 public.crt
。 MinIO 在 Linux 只支持使用 PEM 格式的秘钥和证书,在 Windows 上只支持 PEM 格式的秘钥和证书,目前不支持 PFX 证书。
若是这个证书是被证书机构签发的,public.crt
应该是服务器的证书。
Linux 可使用以下工具来生成证书
Windows 可使用以下工具来生成证书
Minio 也能够配置成链接其它服务,无论是 Minio 节点仍是像 NATs、Redis 这些。若是这些服务用的不是在已知证书机构注册的证书,你可让 Minio 服务信任这些 CA ,怎么作呢,将这些证书放到Minio配置路径下(~/.minio/certs/CAs/ Linux 或者 C:\Users\<Username>.minio\certs\CAs Windows).
使用以下命令生成私钥,私钥会生成在执行命令的目录下
openssl genrsa -out private.key 2048
生成自签名的证书,证书会生成在执行命令的目录下
openssl req -new -x509 -days 3650 -key private.key -out public.crt -subj "/C=US/ST=state/L=location/O=organization/CN=domain"
其中相关内容能够按照实际状况修改,好比 /C
是国家,中国是 CN ,/ST
是州或者省, /L
是市或者区, /CN
是域名。
秘钥和证书生成好之后,按照上边的要求放置在对应的目录便可。
Thanos 在链接 MinIO 的时候遇到了一些问题,日志里有不少错误提示,列在下边供参考。
日志报错以下所示:
level=info ts=2019-11-08T02:43:40.981858805Z caller=main.go:170 msg="Tracing will be disabled" level=info ts=2019-11-08T02:43:40.982326667Z caller=factory.go:39 msg="loading bucket configuration" level=error ts=2019-11-08T02:43:40.982682262Z caller=main.go:200 err="store command failed: create bucket client: create S3 client: initialize s3 client: address http://127.0.0.1:9000: too many colons in address"
日志描述直译过来就是冒号太多了,缘由是在配置文件中,填写了 MinIO 提供的 S3 协议的 endpoint 的时候,多填写了 http://
,致使提示该错误。本意是在内网使用, HTTP 协议就能够了,不须要要开启 HTTPS ,可是 Thanos 在链接 S3 存储的时候默认是使用 HTTPS 的,不能经过这种方式来使用 HTTP 。
错误的配置以下:
type: S3 config: bucket: "disk1" endpoint: "http://127.0.0.1:9000"
正确的配置以下:
type: S3 config: bucket: "disk1" endpoint: "127.0.0.1:9000"
日志报错以下
level=info ts=2019-11-08T02:42:04.366000876Z caller=main.go:170 msg="Tracing will be disabled" level=info ts=2019-11-08T02:42:04.366417674Z caller=factory.go:39 msg="loading bucket configuration" level=info ts=2019-11-08T02:42:04.384413714Z caller=cache.go:172 msg="created index cache" maxItemSizeBytes=131072000 maxSizeBytes=262144000 maxItems=math.MaxInt64 level=error ts=2019-11-08T02:42:04.385632149Z caller=main.go:200 err="store command failed: bucket store initial sync: sync block: iter: Get https://127.0.0.1:9000/prometheus-store/?delimiter=%2F&max-keys=1000&prefix=: http: server gave HTTP response to HTTPS client"
这是 Thanos 链接的对象存储只提供了 HTTP ,没有提供 HTTPS,这个时候须要让对象存储添加证书,启用 HTTPS 。
日志报错以下:
level=info ts=2019-11-08T03:06:57.90508837Z caller=main.go:170 msg="Tracing will be disabled" level=info ts=2019-11-08T03:06:57.905445182Z caller=factory.go:39 msg="loading bucket configuration" level=info ts=2019-11-08T03:06:57.923283984Z caller=cache.go:172 msg="created index cache" maxItemSizeBytes=131072000 maxSizeBytes=262144000 maxItems=math.MaxInt64 level=error ts=2019-11-08T03:06:57.927125234Z caller=main.go:200 err="store command failed: bucket store initial sync: sync block: iter: Get https://10.23.80.18:9000/prometheus-store/?delimiter=%2F&max-keys=1000&prefix=: x509: cannot validate certificate for minio-erdong.site because it doesn't contain any IP SANs"
由于 Thanos 链接 Minio 的 HTTP 配置里,有一个 insecure_skip_verify
选项,该选项默认为 false ,须要对域名的证书进行验证,因为使用了自签证书,没有在权威的 CA 机构作认证,因此在链接过程当中会提示不安全,将值改成 true,跳过这个验证就能够了。
http_config: idle_conn_timeout: 90s response_header_timeout: 2m insecure_skip_verify: true