通过MinIO二进制文件运行
官方文档
英文文档(推荐使用):https://min.io/docs/minio/linux/index.html
中文文档:http://docs.minio.org.cn/docs
下载MinIO
1 2 3 4 5 6 7 8
| # 进入/usr/local/bin目录下面 cd /usr/local/bin
# 下载MinIO二进制文件 wget https://dl.min.io/server/minio/release/linux-amd64/minio
# 给MinIO二进制文件添加可执行权限 chmod +x minio
|
运行MinIO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| # 指定用户名和密码(可选,有默认用户名和密码) export MINIO_ROOT_USER=admin export MINIO_ROOT_PASSWORD=JD6shvxDf2APuyM
# 格式 minio server 挂载目录 --console-address :控制台端口
# 例 mkdir ~/minio minio server ~/minio --console-address :9090
# 在Web浏览器中打开http://192.168.17.6:9000 / http://127.0.0.1:9000以访问MinIO控制台
# 默认用户名和密码 minioadmin
|
安装MinIO客户端
1 2 3 4 5 6 7 8
| # 进入/usr/local/bin目录下面 cd /usr/local/bin
# 下载MinIO客户端 wget https://dl.min.io/client/mc/release/linux-amd64/mc
# 给MinIO客户端添加可执行权限 chmod +x mc
|
通过Docker安装
官方文档
英文文档(推荐):https://min.io/docs/minio/container/index.html
中文文档:http://docs.minio.org.cn/docs
下载运行
docker
1 2 3 4 5 6 7 8 9 10 11 12 13
| # 创建文件挂载目录 mkdir -p ~/minio/data
# 下载镜像和启动容器 docker run \ -d --restart always \ -p 9000:9000 \ -p 9090:9090 \ --name minio \ -e "MINIO_ROOT_USER=ROOTUSER" \ -e "MINIO_ROOT_PASSWORD=CHANGEME123" \ -v ${HOME}/minio/data:/data \ minio/minio server /data --console-address ":9090"
|
docker-compose
启动命令,传入GID、UID UID=${UID} GID=${GID} docker-compose up
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| version: "3.8"
services: minio: container_name: minio image: minio/minio restart: always environment: MINIO_ROOT_USER: 'admin' MINIO_ROOT_PASSWORD: '12345678' ports: - "9000:9000" - "9090:9090" volumes: - ./minio/data:/data command: server /data --console-address ":9090"
|
Java中使用MinIO
官方文档
快速开始文档:https://min.io/docs/minio/linux/developers/java/minio-java.html
API文档:https://min.io/docs/minio/linux/developers/java/API.html
官方代码案例:https://github.com/minio/minio-java
依赖下载
maven
1 2 3 4 5
| <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.4.5</version> </dependency>
|
gradle
1 2 3
| dependencies { implementation("io.minio:minio:8.4.5") }
|
jar包下载
下载地址:https://repo1.maven.org/maven2/io/minio/minio/
SpringBoot整合MinIO
导入依赖
1 2 3 4 5 6 7 8 9 10 11 12
| <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.4.5</version> </dependency>
<dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.9.3</version> </dependency>
|
编写配置类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import io.minio.MinioClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
@Configuration public class MinIOConfiguration { @Resource private MinIOProperties minIOProperties;
@Bean public MinioClient minioClient() { return MinioClient.builder() .endpoint(minIOProperties.getEndpoint()) .credentials(minIOProperties.getUsername(), minIOProperties.getPassword()) .build(); } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component;
@Component @ConfigurationProperties(prefix = "minio") @Data public class MinIOProperties { private String endpoint; private String username; private String password; }
|
1 2 3 4
| minio: endpoint: http: username: ROOTUSER password: CHANGEME123
|
其他参考
https://blog.csdn.net/qq_39641842/article/details/122687512