Object-storage MinIO: quick start for newbies
Intro
Hi everyone!
Today we will take a look at S3 compatible object storage — Minio (https://min.io/ ). It’s great if you need some object storage and you don’t want to use cloud services for any reason or you need it for the development on local environment.
On Minio you have similar possibilities as on Google Storage or on AWS S3. You can create buckets, upload files, set up data encryption and much more. To get more details you can check documentation — https://min.io/docs/minio/kubernetes/upstream/ (it is really explicit!).
Today we will focus on how easily to up & run Minio, set up it & start work with it. At the end of the article we will create new bucket on our server, upload file to it & download it back.
Up & run Minio in Docker-Compose
To up & run minio on local env you should have 2 files: nginx.conf — config for Nginx that used for Minio & docker-compose.yaml. You can take them from official repo: https://github.com/minio/minio/blob/master/docs/orchestration/docker-compose/docker-compose.yaml and here https://github.com/minio/minio/blob/master/docs/orchestration/docker-compose/nginx.conf or you can clone them from repo for this tutorial: https://github.com/xnuinside/minio-tutorial .
After downloading you can do:
docker-compose up --build
You should run command from same folder where you had been placed nginx.config & docker-compose.yaml file
If everything is okay you will see in console something like this:
Congratulations! You has your own S3 server now.
Enter UI
To enter UI you should link from console: http://127.0.0.1:9001/login and default login & passoword ‘minioadmin’:’minioadmin’.
If you want change admin credentials you should define new one in docker-compose yaml file, here:
Create Service Account
To communicate with S3 server you should have creds to access it from command line or your scripts. User that you saw upper is just a super user for admin panel.
Go to menu point Identity -> Service Account
Next, click “Create service account” and after click button “create”. Don’t forget save your creds, because you cannot restore secret key — just create new pair.
Now let’s switch to the terminal — we need to install & configure the command line tool that we will use to interact with the minio server.
Install & Configure Cli
First of all, you should install cli, official documentation store valid links for actual distributions, so better to check: https://docs.min.io/minio/baremetal/reference/minio-mc.html#install-mc
I use MacOs, so I will do it with
brew install minio/stable/mc
After you installed the command line try it:
mc
You should see the help of command line. To exit from the list press ‘Esc’ on your keyboard.
Next, lets connect to our minio server, to do this you should alias your server with creds that you got. Where ‘local’ — an alias name to our localhost minio server.
mc alias set local http://127.0.0.1:9000 YOUR_ACCESS_KEY YOUR_SECRET
Now check connection & status:
mc admin info local
You should see something like this:
Full command list you can find here: https://docs.min.io/docs/minio-client-complete-guide.html
Create a new bucket with Cli
To create new bucket lets use command (local — alias to your server, don’t forget):
mc mb local/test-bucket
Where test-bucket — is your bucket name.
To check all buckets on server, that are available for you service account you should use command:
mc ls local
Now you can see that your bucket was successfully created:
Upload file to the bucket
Let’s create an empty file for test upload to the bucket
touch our_file_to_upload.txt
Now, we will upload it to our bucket:
mc cp our_file_to_upload.txt local/test-bucket
And now we can check that file on the server:
mc ls local/test-bucket
You will see:
Check files in UI
You can also work with buckets from Admin UI.
To do it enter UI again: http://127.0.0.1:9001/buckets and go to Buckets page:
You can click on “Browse” and see your file in the bucket:
To download file from server you can use same `mc cp` command, just change paths:
mc cp local/test-bucket/our_file_to_upload.txt our_file_to_upload.txt
Thats it! Minio is a great tool with amazing possibilities and a big list of features. It is stable and production ready. Feel free to use it & experiment! I hope it will be useful to someone. Have a nice day!
All files you can find here: https://github.com/xnuinside/minio-tutorial