Object storage is a computer data storage that manages data as objects, as opposed to other storage architectures like file systems which manages data as a file hierarchy, and block storage which manages data as blocks within sectors and tracks.
Object storage is used for housing videos and photos, music, and files for online collaboration. In object storage, data is sectioned off into units (aka “objects”) where it is stored in a flat environment. Each object includes:
- Data
- Metadata
- Unique identifier
All data blocks for a file are contained together as an object and are stored in what is called a storage pool. To access data, the storage system uses a unique identifier and metadata to find the object. Data can be accessed using RESTful APIs, HTTP, and HTTPS.
Object storage is crucial to the functioning of cloud services and applications. And because of the way object storage works, you can scale very quickly, up to petabytes and exabytes (so long as the machine in question has the space).
MinIO is a high performance object storage solution that provides an Amazon Web Services S3-compatible API and supports all core S3 features. MinIO is built to deploy anywhere – public or private cloud, baremetal infrastructure, orchestrated environments, and edge infrastructure. It is a high performance distributed object storage server, designed for large-scale private cloud infrastructure. MinIO is designed in a cloud-native manner to scale sustainably in multi-tenant environments.
In this guide, we will explore how to deploy standalone minio server in a Rocky Linux but it should work similarly in other Linux distributions.
Related content
- How to set CORS headers on your Amazon S3 bucket
- How to store Django Static and Media files in Amazon S3
- Script to Upload files to AWS S3 Using Golang
- Using AWS S3 Programatically with Python using Boto3 SDK
- Using AWS S3 from the terminal with awscli
Running Minio server
Minio Server is distributed as an executable binary. It is hosted by the minio team. Use this command to download the file to the /usr/local/bin
directory
curl -Lo /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio
sudo chmod +x /usr/local/bin/minio
That command will download the minio executable file and save it into /usr/local/bin. You will then need to give the file executable permissions with:
sudo chmod u+x /usr/local/bin/minio
Once downloaded you can check the version
$ minio --version
minio version RELEASE.2023-01-12T02-06-16Z (commit-id=7bc95c47a322971aff7d4d4c270dcf28a933e84b)
Runtime: go1.19.4 linux/amd64
License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Copyright: 2015-2023 MinIO, Inc.
Configuring Data Directory for Minio Storage
Minio will store the files uploaded to a path in the file system. You thus need to create a directory that will be used for that purpose.
If your local storage isn’t large enough to house all of the data, you’ll need to attach an external drive and mount it. Let’s say you have a drive named /dev/sdb1 and you want to mount it to /mnt/data.
First, created the /mnt/data directory with:
sudo mkdir /data
Next, mount the drive with:
sudo mount /dev/sdb1 /mnt/data
To mount the drive on boot, we need to add an entry to fstab
. Open fstab:
sudo vim /etc/fstab
At the bottom of that file, add the following:
/dev/sdb1 /mnt/data ext4 defaults 0 0
Do note that if your drive uses another partition format, make sure to replace ext4
with the proper type.
Save and close the file. Remount all available partitions with:
sudo mount -a
You should see no errors.
Testing that Minio runs as expected
To test that the binary is working as expected, you can use this command to run the server in the terminal:
MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD=password minio server /mnt/data --console-address "0.0.0.0:9001"
This will run the service exposing admin in port 9001. Access http://localhost:9001/ using the username and password provided as part of the arguments.
Running Minio with systemd
Set up Data Directory and configurations
When running Minio in a remote server, we would want the service to run as a daemon so it persists logouts. Systemd provides us a way to achieve that.
First we will need to a system user that will be used by the service. Create it with this command:
sudo useradd -r minio -s /sbin/nologin
Change the ownership of the data diretory so that it belongs to the minio
user with:
sudo chown -R minio:minio /mnt/data
Now, make a directory to house the MinIO configurations with:
sudo mkdir /etc/minio
Give that directory the proper ownership with:
sudo chown -R minio:minio /etc/minio
Create a configuration file for MinIO with the command:
sudo vim /etc/default/minio
In that file, paste the following:
MINIO_ROOT_USER="minio"
MINIO_VOLUMES="/mnt/data"
MINIO_OPTS="-C /etc/minio --address :9000 --console-address :9001"
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD="SecretP4s$w0rd"
Where SecretP4s$w0rd
is a strong/unique password.
Save and close the file.
Give that file the proper permissions with:
sudo chown minio:minio /etc/default/minio
Create a systemd file
Once the configurations are set up, we are ready to create a systemd file. Open the file with your favourite text editor:
sudo vim /etc/systemd/system/minio.service
In that file, paste the following:
[Unit]
Description=Minio
Documentation=https://docs.minio.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local/
User=minio
Group=minio
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/bin/minio server ${MINIO_OPTS} ${MINIO_VOLUMES}
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until the process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
Save and close the file.
Reload the systemd daemon with:
sudo systemctl daemon-reload
Start and enable the MinIO service with:
sudo systemctl enable --now minio
Open the Firewall
If you have firewalld installed and enabled, you will need to configure it.
Without the firewall open, we can’t access MinIO, which requires both 9000
and 9001
TCP ports open. Do this with the commands:
sudo firewall-cmd --zone=public --add-port=9000/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9001/tcp --permanent
Reload the firewall with:
sudo firewall-cmd --reload
Accessing Minio
Open a web browser on the same network and point it to http://SERVER:9000
(where SERVER is the IP address or domain of the hosting server). You should be greeted by the login screen, where you’ll authenticate with username admin
and the password you created in the configuration file.
Once you successfully authenticate, you’ll find yourself on the main MinIO window, where you can create your first storage bucket and manage things like access keys, identities, monitoring, notification, tiers, replication, and more.
3 Comments
Pingback: Using AWS S3 from the terminal with awscli
Pingback: Script to Upload files to AWS S3 Using Golang
Pingback: Using AWS S3 Programatically with Python using Boto3 SDK