架构师_程序员_码农网

查看: 131|回复: 1

MinIO 存储(一)将 MinIO 在 Windows 下安装成服务

[复制链接]
发表于 2021-3-7 18:17:11 | 显示全部楼层
Minio是GlusterFS创始人之一Anand Babu Periasamy发布新的开源项目。Minio兼容Amason的S3分布式对象存储项目,采用Golang实现,客户端支持.NET、Java、Python、Javacript、Golang语言。
Minio可以做为云存储的解决方案用来保存海量的图片,视频,文档。由于采用Golang实现,服务端可以工作在Windows,Linux, OS X和FreeBSD上。配置简单,基本是复制可执行程序,单行命令可以运行起来。

文档:https://docs.min.io/

不推荐查看官方中文版本文档,因为不完整!
提示:MinIO 在 Windows 下分布式部署,只是实验性产品,不推荐,单机的话,还可以!

下载

Windows 版本下载地址:https://dl.min.io/server/minio/release/windows-amd64/minio.exe

安装

通过如下命令,可以快去启动一个实例:


D:\dev_tools\minio>minio.exe server D:\dev_tools\file_attach
Endpoint: http://192.168.50.243:9000  http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin

Browser Access:
   http://192.168.50.243:9000  http://127.0.0.1:9000

Command-line Access: https://docs.min.io/docs/minio-client-quickstart-guide
   $ mc.exe alias set myminio http://192.168.50.243:9000 minioadmin minioadmin

Object API (Amazon S3 compatible):
   Go:         https://docs.min.io/docs/golang-client-quickstart-guide
   Java:       https://docs.min.io/docs/java-client-quickstart-guide
   Python:     https://docs.min.io/docs/python-client-quickstart-guide
   JavaScript: https://docs.min.io/docs/javascript-client-quickstart-guide
   .NET:       https://docs.min.io/docs/dotnet-client-quickstart-guide
Detected default credentials 'minioadmin:minioadmin', please change the credentials immediately using 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD'

QQ截图20210307174429.jpg

同时,D:\dev_tools\file_attach 目录下面会自动创建一个 .minio.sys 文件夹

浏览器访问:http://127.0.0.1:9000 默认账号和密码为:minioadmin

QQ截图20210307174606.jpg

设置访问账号和密码

MinIO 设置账号和密码是通过环境变量:MINIO_ROOT_USER、MINIO_ROOT_PASSWORD 来实现的,同时,一些其他的参数也是通过环境变量的形式设置。

从网上看到说修改"D:\dev_tools\file_attach\.minio.sys\config\config.json"文件的 access_key 和 secret_key 后面 value 中的值就可以。这种方式虽然可以做到修改账号和密码,但是不安全,也不推荐。


config.json 文件内容:

{"api":{"_":[{"key":"requests_max","value":"0"},{"key":"requests_deadline","value":"10s"},{"key":"cluster_deadline","value":"10s"},{"key":"cors_allow_origin","value":"*"},{"key":"remote_transport_deadline","value":"2h"},{"key":"list_quorum","value":"strict"},{"key":"extend_list_cache_life","value":"0s"},{"key":"replication_workers","value":"100"}]},"audit_webhook":{"_":[{"key":"enable","value":"off"},{"key":"endpoint","value":""},{"key":"auth_token","value":""},{"key":"client_cert","value":""},{"key":"client_key","value":""}]},"cache":{"_":[{"key":"drives","value":""},{"key":"exclude","value":""},{"key":"expiry","value":"90"},{"key":"quota","value":"80"},{"key":"after","value":"0"},{"key":"watermark_low","value":"70"},{"key":"watermark_high","value":"80"},{"key":"range","value":"on"},{"key":"commit","value":"writethrough"}]},"compression":{"_":[{"key":"enable","value":"off"},{"key":"allow_encryption","value":"off"},{"key":"extensions","value":".txt,.log,.csv,.json,.tar,.xml,.bin"},{"key":"mime_types","value":"text/*,application/json,application/xml,binary/octet-stream"}]},"credentials":{"_":[{"key":"access_key","value":"minioadmin"},{"key":"secret_key","value":"minioadmin"}]},"etcd":{"_":[{"key":"endpoints","value":""},{"key":"path_prefix","value":""},{"key":"coredns_path","value":"/skydns"},{"key":"client_cert","value":""},{"key":"client_cert_key","value":""}]},"heal":{"_":[{"key":"bitrotscan","value":"off"},{"key":"max_sleep","value":"1s"},{"key":"max_io","value":"10"}]},"identity_ldap":{"_":[{"key":"server_addr","value":""},{"key":"username_format","value":""},{"key":"user_dn_search_base_dn","value":""},{"key":"user_dn_search_filter","value":""},{"key":"group_search_filter","value":""},{"key":"group_search_base_dn","value":""},{"key":"sts_expiry","value":"1h"},{"key":"tls_skip_verify","value":"off"},{"key":"server_insecure","value":"off"},{"key":"server_starttls","value":"off"},{"key":"lookup_bind_dn","value":""},{"key":"lookup_bind_password","value":""}]},"identity_openid":{"_":[{"key":"config_url","value":""},{"key":"client_id","value":""},{"key":"claim_name","value":"policy"},{"key":"claim_prefix","value":""},{"key":"scopes","value":""},{"key":"jwks_url","value":""}]},"kms_kes":{"_":[{"key":"endpoint","value":""},{"key":"key_name","value":""},{"key":"cert_file","value":""},{"key":"key_file","value":""},{"key":"capath","value":""}]},"kms_vault":{"_":[{"key":"endpoint","value":""},{"key":"key_name","value":""},{"key":"auth_type","value":"approle"},{"key":"auth_approle_id","value":""},{"key":"auth_approle_secret","value":""},{"key":"capath","value":""},{"key":"key_version","value":""},{"key":"namespace","value":""}]},"logger_webhook":{"_":[{"key":"enable","value":"off"},{"key":"endpoint","value":""},{"key":"auth_token","value":""}]},"notify_amqp":{"_":[{"key":"enable","value":"off"},{"key":"url","value":""},{"key":"exchange","value":""},{"key":"exchange_type","value":""},{"key":"routing_key","value":""},{"key":"mandatory","value":"off"},{"key":"durable","value":"off"},{"key":"no_wait","value":"off"},{"key":"internal","value":"off"},{"key":"auto_deleted","value":"off"},{"key":"delivery_mode","value":"0"},{"key":"queue_limit","value":"0"},{"key":"queue_dir","value":""}]},"notify_elasticsearch":{"_":[{"key":"enable","value":"off"},{"key":"url","value":""},{"key":"format","value":"namespace"},{"key":"index","value":""},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"},{"key":"username","value":""},{"key":"password","value":""}]},"notify_kafka":{"_":[{"key":"enable","value":"off"},{"key":"topic","value":""},{"key":"brokers","value":""},{"key":"sasl_username","value":""},{"key":"sasl_password","value":""},{"key":"sasl_mechanism","value":"plain"},{"key":"client_tls_cert","value":""},{"key":"client_tls_key","value":""},{"key":"tls_client_auth","value":"0"},{"key":"sasl","value":"off"},{"key":"tls","value":"off"},{"key":"tls_skip_verify","value":"off"},{"key":"queue_limit","value":"0"},{"key":"queue_dir","value":""},{"key":"version","value":""}]},"notify_mqtt":{"_":[{"key":"enable","value":"off"},{"key":"broker","value":""},{"key":"topic","value":""},{"key":"password","value":""},{"key":"username","value":""},{"key":"qos","value":"0"},{"key":"keep_alive_interval","value":"0s"},{"key":"reconnect_interval","value":"0s"},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"}]},"notify_mysql":{"_":[{"key":"enable","value":"off"},{"key":"format","value":"namespace"},{"key":"dsn_string","value":""},{"key":"table","value":""},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"},{"key":"max_open_connections","value":"2"}]},"notify_nats":{"_":[{"key":"enable","value":"off"},{"key":"address","value":""},{"key":"subject","value":""},{"key":"username","value":""},{"key":"password","value":""},{"key":"token","value":""},{"key":"tls","value":"off"},{"key":"tls_skip_verify","value":"off"},{"key":"cert_authority","value":""},{"key":"client_cert","value":""},{"key":"client_key","value":""},{"key":"ping_interval","value":"0"},{"key":"streaming","value":"off"},{"key":"streaming_async","value":"off"},{"key":"streaming_max_pub_acks_in_flight","value":"0"},{"key":"streaming_cluster_id","value":""},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"}]},"notify_nsq":{"_":[{"key":"enable","value":"off"},{"key":"nsqd_address","value":""},{"key":"topic","value":""},{"key":"tls","value":"off"},{"key":"tls_skip_verify","value":"off"},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"}]},"notify_postgres":{"_":[{"key":"enable","value":"off"},{"key":"format","value":"namespace"},{"key":"connection_string","value":""},{"key":"table","value":""},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"},{"key":"max_open_connections","value":"2"}]},"notify_redis":{"_":[{"key":"enable","value":"off"},{"key":"format","value":"namespace"},{"key":"address","value":""},{"key":"key","value":""},{"key":"password","value":""},{"key":"queue_dir","value":""},{"key":"queue_limit","value":"0"}]},"notify_webhook":{"_":[{"key":"enable","value":"off"},{"key":"endpoint","value":""},{"key":"auth_token","value":""},{"key":"queue_limit","value":"0"},{"key":"queue_dir","value":""},{"key":"client_cert","value":""},{"key":"client_key","value":""}]},"policy_opa":{"_":[{"key":"url","value":""},{"key":"auth_token","value":""}]},"region":{"_":[{"key":"name","value":""}]},"scanner":{"_":[{"key":"delay","value":"10"},{"key":"max_wait","value":"15s"}]},"storage_class":{"_":null}}

首先关闭刚才打开的控制台应用,正确的方法如下:

当然,也可以使用 setx 设置永久变量,参考:

cmd 设置永久环境变量命令
https://www.itsvse.com/thread-9230-1-1.html

MinIO 会将配置信息加密存储,如下图:
Attempting encryption of all config, IAM users and policies on MinIO backend

QQ截图20210307175358.jpg

注意:账号最少为3个字符,密码最好为8个字符。否则,会报错如下:

Access key length should be at least 3, and secret key length at least 8 characters

MinIO 在 Windows 下安装成服务

每次通过命令行的方法启动 MinIO 很不方便,也容易关闭窗口,MinIO 应用就会被关闭了,将 MinIO 部署成 Windows 服务最方便,跟随电脑开机启动。

可以通过 NSSM 工具部署成 Windows 服务,参考:

通过 NSSM 将应用程序部署成 Windows 服务
https://www.itsvse.com/thread-9551-1-1.html

首先,将 NSSM.exe 添加到系统 path 变量里面。(略)

新建一个 install.cmd 文件,脚本命令如下:

右击使用管理员身份运行,如下图:

QQ截图20210307180212.jpg

重新打开网站,账号:itsvse 密码:Ttsvse123456 登录即可。

我们创建一个名称为 test 的 bucket,并尝试上传一个文件,可以将文件分享给朋友,还可以设置链接有效期,完全可以作为一个私人网盘使用如下图:

QQ截图20210307181144.jpg

有人可能会疑问,这和直接存储到硬盘文件夹有什么区别?

1.MinIO 提供了 web 端可视化文件查看界面;
2.它核心其实是分布式,将同一个文件,分布在不同的服务器节点,保证文件的可靠性;
3.如果我们存储是远程服务器,是不是要通过其它协议,例如:ftp 上传到服务器,ftp 部署也非常麻烦;
4.它拥有一些高级功能,例如:直接将文件分享给朋友,并设置链接有效期。

所以,我们不能将它仅仅看作成只是帮你将文件存储到文件夹内的中间件。


(完)






上一篇:新人报道贴
下一篇:HTML 自定义网站图标 ico 路径地址
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2021-3-9 15:15:19 | 显示全部楼层
修改端口参数



例子:

码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2021-4-13 14:45

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表