Ubuntu 22.04搭建minio对象存储服务记录
之前一直用docker的方式搭建Minio对象存储的方式使用,这次心血来潮想要自己在VPS上进行搭建。发现minio就一个可执行文件就完事了,不得不佩服golang大法静态编译就是好啊。那么剩下的就是写个systemd启动脚本来配置自动启动了。
搭建minio服务
下载minio的可执行文件
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
先通过命令行运行
./minio server --console-address ":9090" --address ":9000" /root/minio/data
可以看到如下输出
root@instance-jw4aEb7i:~/minio/app# ./minio server --console-address ":9090" --address ":9000" /root/minio/data
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.
WARNING: Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables
MinIO Object Storage Server
Copyright: 2015-2023 MinIO, Inc.
License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Version: RELEASE.2023-12-02T10-51-33Z (go1.21.4 linux/amd64)
Status: 1 Online, 0 Offline.
S3-API: http://172.16.10.133:9000 http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin
Console: http://172.16.10.133:9090 http://127.0.0.1:9090
RootUser: minioadmin
RootPass: minioadmin
Command-line: https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart
$ mc alias set 'myminio' 'http://172.16.10.133:9000' 'minioadmin' 'minioadmin'
Documentation: https://min.io/docs/minio/linux/index.html
Warning: The standard parity is set to 0. This can lead to data loss.
接下来我们简单体验一下MINIO
由于我们没有设置用户密码,所以从运行信息中找到如下登录信息
成功登录将看到如下画面
我们按照提示创建存储桶并且随便传点东西上去
修改存储桶的访问策略,使得上传的文件可以被公网访问
创建一个Access Keys通过客户端访问数据
通过客户端上传一张图片
接下来去公网访问,输入MINIO的访问服务地址+存储桶和文件名称,就可以访问到刚上传的文件
可以看到刚刚上传的图片
编写systemd的service
将minio的目录移动到/opt/minio
编写一个配置文件存储到/etc/minio/minio.conf
,后续的启动脚本中会用到
MINIO_VOLUMES="/opt/minio/data"
MINIO_OPTS="--console-address :9090 --address :9000"
MINIO_ROOT_PASSWORD="minioadmin"
MINIO_ROOT_USER="minioadmin"
编写minio.service存储到/etc/systemd/system
[Unit]
Description=MINIO
Document=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/opt/minio/app/minio
[Service]
PermissionsStartOnly=true
EnvironmentFile=/etc/minio/minio.conf
ExecStartPre=/bin/bash -c "[ -n "${MINIO_VOLUMES}" ] || echo "Variable MINIO_VOLUMES not set in /etc/minio/minio.conf""
ExecStart=/opt/minio/app/minio server $MINIO_OPTS $MINIO_VOLUMES
Restart=always
LimitNOFILE=65536
TimeoutStopSec=infinity
SekndSIGKILL=no
StandardOutput=journal
StandardError=inherit
[Install]
WantedBy=multi-user.target
然后更新systemd配置缓存
systemctl daemon-reload
启动/停止/查询状态
systemctl [start|stop|status] minio.service
设置开机启动
systemctl enable minio.service
参考链接
感谢扫码支持