preface

In a real project, file storage is essential. At present, there are many vendors providing object storage services in the market, such as Qiuniuyun and Aliyun. But these storage services is often a fee or storage space limitation, there are some friend or will the uploaded files stored on the server directly to the local, although this way is feasible, but there are still many limitations, such as bad we uploaded file management, file preview is bad operation, and if there are multiple servers, and so on.

Today we will introduce the use of miniO to build their own file storage server, because the new version of MiniO and the old version of a certain difference, so today we introduce the new version of miniO and the old version of the build way, you can choose according to their own needs.

1. Preparation

  • One server
  • Install the docker
  • SSl certificate (if HTTPS access is required)

2. Install the old minio

(1) Docker installs the specified version of Minio

Run the command:

docker pull minio/minio:RELEASE.2021-06-17T00-10-46Z
Copy the code

(2) Run minio using Docker

Run the command:

docker run -p 9000:9000 --name minio -di --restart=always \
  -e "MINIO_ROOT_USER=minio" \
  -e "MINIO_ROOT_PASSWORD=minio123456" \
  -v /usr/local/minio/data:/data \
  -v /usr/local/minio/config:/root/.minio \
  minio/minio:RELEASE.2021-06-17T00-10-46Z server /data
Copy the code

Explanation of relevant instructions:

  • MINIO_ROOT_USER: sets the user name
  • MINIO_ROOT_PASSWORD: sets the password
  • /usr/local/minio/data: specifies the file storage address
  • /usr/local/minio/config: minio configuration file

Note You need to add the 9000 port to the security group of the server. Otherwise, the port cannot be accessed.

The following interface is displayed after the operation is successful:

To view the Docker run log, run the following command:

Docker logs run result IDCopy the code

If the above screen appears, it means miniO is running successfully, because I used SSL certificate, so IT is HTTPS.

(3) Browser access

Enter http://server IP address :9000 in the browser. The login page is displayed.

Use the login password to log in. After the login is successful, the following page is displayed:

Here I created a new bucket named Navigation, you can simply ask where the data is stored.

(4) Upload files to the miniO file service

The first:

Uploading directly to your browser is very simple:

Here I have uploaded an image, but at this point we cannot access the image directly by typing the following address:

http://server IP address :9000/ bucket name/file nameCopy the code

We need to set access rules:

Click Edit Policy and change to the following:

At this point we can access the image like this:

http://server IP address :9000/navigation/1.jpgCopy the code

(5) Enable HTTPS access

Many web sites have HTTPS enabled. For security and consistency, our minio service also has HTTPS enabled.

1. Obtain an SSL certificate

We get the following two files:

  • public.crt
  • private.key

[Note] If the certificate name or suffix is not the above two, you can directly change it. For example, the pem suffix can be directly changed to CRT suffix.

2. Upload the certificate to the minio directory of the server

The specific directories are as follows:

/usr/local/minio/config/certs
Copy the code

The specific path is related to when minio was just running. The uploaded folder is as follows:

3. Restart the Docker container

View the container in which docker is running

docker ps
Copy the code

Restart command:

Docker restart Container IDCopy the code

View logs:

Docker logs run result IDCopy the code

If the following interface appears, we can use HTTPS to access:

3. Install the new minio

The new minio installation is not much different from the old version, mainly the commands and interface are different:

(1) Docker installs the latest version of Minio

docker pull minio/minio 
Copy the code

(2) Run minio using Docker

docker run --name minio \ -p 9000:9000 \ -p 9090:9090\ -d --restart=always \ -e "MINIO_ROOT_USER=admin" \ -e "MINIO_ROOT_PASSWORD=admin123" \ -v /home/minio/data:/data \ -v /home/minio/config:/root/.minio \ minio/minio server / data \ -- the console - address '0.0.0.0:9090'Copy the code

[Note] The new version of the run command and the old version of the run command is a little different.

Other steps are basically the same as installing the old version, but the operation interface may be different:

New version of the interface:

Finally add: the new version of HTTPS access may be unable to log in the pit, so far I have not found a good solution, solution partners please answer in the comment section, thank you very much.

Xiaobian latest open source project:

[Piggy navigating

Smallpig. Site / # /] (link.zhihu.com/?target=htt…).

Technology stack:

  • Front-end: Vue2. X + Elemenu- UI + SCSS
  • Back end: Express + Node.js
  • Database: MongoDB
  • Data storage service: Minio