High performance object storage minio

Introduction to MinIO

MinIO is a high-performance object store released under the Apache License v2.0. It is an API compatible with the Amazon S3 cloud storage service. MinIO is a high-performance object storage solution that natively supports Kubernetes deployment.

Minio is a very lightweight service that can store large amounts of unstructured data, such as pictures, videos, log files, backup data, and container/virtual machine images. For most enterprises, this can be said to be the most ideal storage medium. An object file can be of any size, ranging from a few kb to a maximum of 5T.

MinIO has the following features

  • Easy to deploy and support various platforms
  • High-performance mass storage, supporting a maximum of 5TB for a single object
  • Compatible with Amazon S3 interface
  • SDK support: SDK support for languages ​​like Java, Python or Go
  • Data protection: data recovery is still available even if a normal disk is damaged
  • High performance: available up to 55G per second read, 35G per second write speed

Install MinIO using Docker

Step 1: Start a miniio container, official document

docker run --name minio -p 9090:9000 -p 9999:9999 -d \
--restart=always -e \
"MINIO_ROOT_USER=minioadmin" \
-e "MINIO_ROOT_PASSWORD=minioadmin123?" \
-v /home/minio/data:/data \
-v /home/minio/config:/root/.minio minio/minio server /data --console-address '0.0.0.0:9999'

Step 2: Access the minio management interface, port 9090

insert image description here

Click create a Bucket to create a bucket (bucket), where we can understand the Bucket as a directory for file storage

insert image description here

Enter the bucket name and click create bucket. Files can be uploaded to the bucket through upload.

insert image description here

Java uploads files to minio

Step 1: Import the dependencies of minio, refer to the official document of Minio

<dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>7.1.0</version>
</dependency>

Step 2: Write a test class

public static void main(String[] args) throws Exception {
    
    
        try {
    
    
        
            // 构建一个Minio客户端
            MinioClient minioClient = MinioClient.builder()
            		//创建容器时指定的账号
                    .credentials("minioadmin", "minioadmin123?")
                    //上传地址
                    .endpoint("http://minio服务器IP:9090").build();

            File file = new File("d:/图片.jpg");

            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object("图片.jpg")	//文件名
                    .contentType("image/jpeg")	//文件类型
                    .bucket("bucket-test")  //存储目录名
                    .stream(new FileInputStream(file), file.length(), -1).build(); //文件流,以及大小,-1代表不分片

			//执行上传
            ObjectWriteResponse objectWriteResponse = minioClient.putObject(putObjectArgs);
            System.out.println("上传结果 "+objectWriteResponse);
			//上传之后的文件地址是:
            String filePath = "http://115.159.88.63:9090/bucket-test/图片.jpg";

        } catch(MinioException e) {
    
    
            System.out.println("Error occurred: " + e);
        }
    }

After executing the test code, watch the minio management interface, and there is an additional picture
insert image description here

Configure permissions

I uploaded a picture here. After uploading, the access address of the picture is: http://minio server ip:9090/storage directory/file name, but when you visit, there will be such an error, it is because of anonymity (tourists do not login) user does not have access

insert image description here

If we need our uploaded files to be accessed by anonymous users, then we need to add access permissions: find the file storage directory, click manager

insert image description here
Then find access Rules and add access rules as follows:
insert image description here

Then visit again, you can see the uploaded picture

insert image description here
That's all for the article, if you like it, it is recommended to bookmark it, and give a good review by the way, it will be even better with one click and three links! ! !

Guess you like

Origin blog.csdn.net/u014494148/article/details/126387428