当前位置:网站首页>Beginners use Minio
Beginners use Minio
2022-07-03 07:24:00 【Maple Leaf pear flower】
Recently, companies have the need to store unstructured data , So you need a file storage server ,fastdfs Is an old-fashioned distributed file system , This file system is usually selected , however fastdfs Deployment is cumbersome , And maintenance is troublesome , So I found another one , Find out Minio The profile also looks good , Then the deployment is also very simple .
This article is my first learning test MinIo The record of , So it's a beginner's perspective to use Minio, After in-depth use, we will continue to update MinIO The real experience of .
start-up MinIO service
I prefer to use docker, So use Docker start-up Minio service
docker run -p 9000:9000 -p 9001:9001 --name minio \
-d --restart=always \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=12345678" \
-v /data/minio/data:/data \
-v /data/minio/config:/root/.minio \
minio/minio server --console-address ":9001" /data
There is a problem here
- MINIO_ROOT_USER: user name , Minimum length is 5 Characters
- MINIO_ROOT_PASSWORD: password , Password cannot be set too simply , Otherwise minio Will fail to start , Minimum length is 8 Characters
Because of this problem , I couldn't start it at first , I thought there was something wrong with my startup . All the way around , Later used docker Look at the log , Problems found , embarrassed .
docker logs Containers ID
Java The service call
Introduce related Jar package
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.3</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
</dependency>
Code
import io.minio.*;
/**
* @author panlf
* @date 2021/12/6
*/
public class MinioFileUpload {
public static void main(String[] args) {
try{
MinioClient minioClient = MinioClient
.builder().endpoint("http://192.168.164.130:9000")
.credentials("admin","12345678").build();
/*
The naming and definition rule of storage bucket is :
1. Bucket name must be between 3 To 63 Between characters
2. Bucket names can only be lowercase 、 Numbers 、 Period (.) And hyphens (-) form
3. Bucket names must start and end with letters or numbers
4. The bucket name must not be IP Address format
*/
String bucketName = "pdf-file";
boolean found = minioClient
.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
if(!found){
// If it doesn't exist, create it
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
}
// Upload files
minioClient.uploadObject(UploadObjectArgs.builder()
.bucket(bucketName)
.object(" Alibaba Java Development Manual 1.4.0.pdf")
.filename("C:\\Users\\panlf\\Desktop\\ Alibaba Java Development Manual 1.4.0.pdf")
.build());
// Download the file
minioClient.downloadObject(DownloadObjectArgs.builder()
.bucket(bucketName)
.object(" Alibaba Java Development Manual 1.4.0.pdf")
.filename(" Alibaba Java Development Manual 1.4.0.pdf").build());
}catch (Exception e){
e.printStackTrace();
}
}
}
Call service above , All of a sudden, an error was reported
The difference between the request time and the current time is too large
Mainly because the server time difference is too large , Then the server needs to resynchronize the time
1. install ntp ntpdate
yum -y install ntp ntpdate
2. Synchronize time with the time server
ntpdate cn.pool.ntp.org
Then it can be used normally .
summary
For beginners ,Minio Service deployment is simple , The calling code is also very simple , Be friendly to novices , Let's look at the actual experience later .
边栏推荐
- IO stream system and FileReader, filewriter
- 691. Cube IV
- Download address collection of various versions of devaexpress
- Introduction of transformation flow
- Advanced API (byte stream & buffer stream)
- [set theory] partition (partition | partition example | partition and equivalence relationship)
- Introduction of buffer flow
- 7.2刷题两个
- Sorting, dichotomy
- php artisan
猜你喜欢
随机推荐
[most detailed] latest and complete redis interview book (50)
为什么说数据服务化是下一代数据中台的方向?
The education of a value investor
[plus de détails] dernière entrevue complète redis (50)
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
【最詳細】最新最全Redis面試大全(50道)
3311. 最长算术
IPv4 address
【CMake】CMake链接SQLite库
Selenium key knowledge explanation
Warehouse database fields_ Summary of SQL problems in kingbase8 migration of Jincang database
Arduino Serial系列函数 有关print read 的总结
JS monitors empty objects and empty references
Advanced API (use of file class)
Common analysis with criteria method
691. Cube IV
Basic knowledge about SQL database
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
Flask Foundation
【无标题】









