当前位置:网站首页>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 .
边栏推荐
- Use of generics
- TreeMap
- 4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
- How to specify the execution order for multiple global exception handling classes
- Recursion, Fibonacci sequence
- Common methods of file class
- URL programming
- Visit Google homepage to display this page, which cannot be displayed
- 4279. 笛卡尔树
- Download address collection of various versions of devaexpress
猜你喜欢
Topic | synchronous asynchronous
URL programming
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
Deep learning parameter initialization (I) Xavier initialization with code
7.2 brush two questions
论文学习——鄱阳湖星子站水位时间序列相似度研究
不出网上线CS的各种姿势
C代码生产YUV420 planar格式文件
How to specify the execution order for multiple global exception handling classes
Summary of Arduino serial functions related to print read
随机推荐
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
Some experiences of Arduino soft serial port communication
Selenium key knowledge explanation
Advanced APL (realize group chat room)
Interfaces and related concepts
"Baidu Cup" CTF game 2017 February, Web: blast-1
Basic components and intermediate components
IO stream system and FileReader, filewriter
Common architectures of IO streams
Distributed transactions
Topic | synchronous asynchronous
LeetCode
TypeScript let与var的区别
深度学习参数初始化(一)Xavier初始化 含代码
在 4EVERLAND 上存储 WordPress 媒体内容,完成去中心化存储
4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
Upgrade CentOS php7.2.24 to php7.3
Leetcode 198: 打家劫舍
SecureCRT password to cancel session recording