前些天发现了一个人工智能学习网站,通俗易懂,风趣幽默,最重要的屌图甚多,忍不住分享一下给大家。点击跳转到网站。
下面开始:
前往官网下载需要的二进制文件
wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/local/bin/minio
不清楚系统是amd64、arm64、ppc64le、s390x中的一个可以使用:
uname -m
返回值举例:x86_64,则说明系统为amd64。
[bash: wget: command not found]: 表示系统中没有安装 wget 命令。Debian/Ubuntu 的系统:sudo apt-get update, sudo apt-get install wget;Red Hat/CentOS 的系统:sudo yum install wget;Arch Linux 的系统:sudo pacman -S wget。
为下载的minio文件赋予权限:
chmod +x /usr/local/bin/minio
创建一个存放数据的文件夹(注意,我这里没有且文件夹,所以这个data是创建在了root下面,你们可以根据需求自己调整):
mkdir data
运行minio(在本地主机的端口号9001上启动MinIO服务器,并将数据存储在data
目录中):
cd /usr/local/bin/minio
./minio server /data --console-address ":9001"
将会看到类似下面的输出:
Formatting 1st pool, 1 set(s), 1 drives per set.
WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable.
MinIO Object Storage Server
Copyright: 2015-2024 MinIO, Inc.
License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html
Version: RELEASE.2024-06-29T01-20-47Z (go1.22.4 linux/amd64)
API: http://你的ip:9000 http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin
WebUI: http://你的ip:9001 http://127.0.0.1:9001
RootUser: minioadmin
RootPass: minioadmin
CLI: https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart
$ mc alias set 'myminio' 'http://你的ip:9000' 'minioadmin' 'minioadmin'
Docs: https://min.io/docs/minio/linux/index.html
Status: 1 Online, 0 Offline.
STARTUP WARNINGS:
- Detected Linux kernel version older than 4.0.0 release, there are some known potential performance problems with this kernel version. MinIO recommends a minimum of 4.x.x linux kernel version for best performance
- Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables
- The standard parity is set to 0. This can lead to data loss.
判断一下是否可以打开控制台(注意防火墙设置):
curl -I http://你的ip:9001
可以看到返回值第一行是:HTTP/1.1 200 OK ,则说明连接成功。
但这种只是一个简陋的安装过程,实际上我们可能要用systemd 服务单元文件来管理 MinIO 服务。
接着往下走,在目前文件夹中创建一个minio.service文件:
vi minio.service
写入内容:
[Unit]
Description=MinIO
Documentation=https://docs.minio.io/
After=network-online.target
[Service]
WorkingDirectory=/path/to/data
User=root
ProtectSystem=full
ProtectHome=true
#注意--address :9000这里的空格
ExecStart=/path/to/minio server --address :9000 --console-address 0.0.0.0:38555 /path/to/data
TimeoutStopSec=600
Restart=always
LimitNOFILE=4096
LimitNPROC=8192
Environment="MINIO_ACCESS_KEY=your_root_username"
Environment="MINIO_SECRET_KEY=your_root_password"
[Install]
WantedBy=multi-user.target
在上面的内容中,将/path/to/minio
替换为MinIO二进制文件的实际路径(本文中为/usr/local/bin/minio),将/path/to/data
替换为希望存储数据的目录路径(本文中为 /data)。另外,将your_root_username
和your_root_password
替换为你的MinIO根用户的用户名和密码。
保存该文件,并将文件复制到/etc/systemd/system
目录:
sudo cp minio.service /etc/systemd/system/minio.service
为之前创建的文件赋权:
sudo chown -R root:root /usr/local/bin/minio
sudo chmod -R 755 /usr/local/bin
sudo chown -R root:root /data
sudo chmod -R 755 /data
重新加载配置:
sudo systemctl daemon-reload
使用下面的命令管理minio服务:
# 启动MinIO服务
sudo systemctl start minio.service
# 查看MinIo服务状态
sudo systemctl status minio.service
# 停止MinIO服务
sudo systemctl stop minio.service
# 重启MinIO服务(如果已启动)
sudo systemctl restart minio.service
# 设置开机启动
sudo systemctl enable minio
# 验证开机启动(输出为 enabled)
sudo systemctl is-enabled minio
设置SSL证书(自 2018 年 6 月 30 日起, SSL 已经被MinIO完全弃用,所以我们只能搞点小动作将TLS改为SSL):
# 可以看到minio默认的隐藏文件夹 .minio
ls -a
#将SSL证书改为:private.key 和 public.crt 放到这里即可
cd .minio/certs/
或者在配置文件指定文件夹(指定的文件夹必须实现创建,且有对应权限):
ExecStart=/path/to/minio server --address :9000 --certs-dir /etc/minio/certs --console-address 0.0.0.0:38555 /path/to/data
遇到问题?
sudo systemctl start minio.service 命令报错:Assertion failed on job for minio.service.
解决方案:1、检查各个文件权限(特别是配置文件)是否赋予。2、检查 /etc/systemd/system/minio.service 配置文件内容是否出错。
检查无误后仍然出错?
运行 以下代码查看日志:
sudo journalctl -u minio.service -b
将会看到类似这样报错信息(问题不一样,打印出的日志也会不一样。切勿硬套!!!)
Jul 01 10:12:23 app systemd[41619]: Failed at step CHDIR spawning /home/minio: No such file or directory
Jul 01 10:12:23 app systemd[1]: minio.service: main process exited, code=exited, status=200/CHDIR
Jul 01 10:12:23 app systemd[1]: Unit minio.service entered failed state.
Jul 01 10:12:23 app systemd[1]: minio.service failed.
Jul 01 10:12:29 app systemd[1]: minio.service holdoff time over, scheduling restart.
Jul 01 10:12:29 app systemd[1]: Stopped MinIO.
Jul 01 10:12:29 app systemd[1]: Started MinIO.
Jul 01 10:12:29 app systemd[41626]: Failed at step CHDIR spawning /home/minio: No such file or directory
Jul 01 10:12:29 app systemd[1]: minio.service: main process exited, code=exited, status=200/CHDIR
可以看出我的问题是:Failed at step CHDIR spawning /home/minio: No such file or directory。
以上都没解决问题?
尝试手动启动
#注意路径换成自己的
sudo /path/to/minio server --address :9000 --console-address 0.0.0.0:38555 /path/to/data
如果手动启动可以正常启动,通过systemd 启动失败,则问题可能出在 systemd 服务单元配置上。
如果一切都检查了,什么都没问题。请运行
sudo journalctl -xe -u minio.service
会看到更加详细的日志报告
-- The error number returned by this process is 2.
Jul 01 11:21:11 app systemd[1]: minio.service: main process exited, code=exited, status=200/CHDIR
Jul 01 11:21:11 app systemd[1]: Unit minio.service entered failed state.
Jul 01 11:21:11 app systemd[1]: minio.service failed.
Jul 01 11:21:11 app systemd[1]: minio.service holdoff time over, scheduling restart.
Jul 01 11:21:11 app systemd[1]: Stopped MinIO.
-- Subject: Unit minio.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit minio.service has finished shutting down.
Jul 01 11:21:11 app systemd[1]: Started MinIO.
-- Subject: Unit minio.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit minio.service has finished starting up.
--
-- The start-up result is done.
Jul 01 11:21:11 app systemd[45855]: Failed at step CHDIR spawning /home/minio/minio: No such file or directory
-- Subject: Process /home/minio/minio could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /home/minio/minio could not be executed and failed.
--
-- The error number returned by this process is 2.
Jul 01 11:21:11 app systemd[1]: minio.service: main process exited, code=exited, status=200/CHDIR
Jul 01 11:21:11 app systemd[1]: Unit minio.service entered failed state.
Jul 01 11:21:11 app systemd[1]: minio.service failed.
Jul 01 11:21:11 app systemd[1]: minio.service holdoff time over, scheduling restart.
Jul 01 11:21:11 app systemd[1]: Stopped MinIO.
-- Subject: Unit minio.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit minio.service has finished shutting down.
Jul 01 11:21:11 app systemd[1]: start request repeated too quickly for minio.service
Jul 01 11:21:11 app systemd[1]: Failed to start MinIO.
-- Subject: Unit minio.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit minio.service has failed.
--
-- The result is failed.
Jul 01 11:21:11 app systemd[1]: Unit minio.service entered failed state.
Jul 01 11:21:11 app systemd[1]: minio.service failed.
看以看到失败原因:The process /home/minio/minio could not be executed and failed.
还有问题?
重装吧,重装可以解决99%的问题。