当前位置:网站首页>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 .
边栏推荐
- c语言指针的概念
- Dora (discover offer request recognition) process of obtaining IP address
- Book recommendation~
- Jeecg data button permission settings
- Laravel frame step pit (I)
- 不出网上线CS的各种姿势
- [set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
- 【CMake】CMake链接SQLite库
- TreeMap
- Discussion on some problems of array
猜你喜欢
随机推荐
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
VMware virtual machine installation
TreeMap
Common operations of JSP
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
Specified interval inversion in the linked list
Upgrade CentOS php7.2.24 to php7.3
Advanced API (multithreading)
Advanced API (use of file class)
Wireshark software usage
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
docket
The embodiment of generics in inheritance and wildcards
Use of other streams
Advanced API (local simulation download file)
VMWare网络模式-桥接,Host-Only,NAT网络
Summary of abnormal mechanism of interview
Le Seigneur des anneaux: l'anneau du pouvoir
[solved] sqlexception: invalid value for getint() - 'Tian Peng‘





![[HCAI] learning summary OSI model](/img/90/66505b22e32aa00b26886a9d5c5e4c.jpg)



