Add Object Storage to Rocky Linux with MinIO

EDITOR’S NOTE: MinIO is a sponsor of The New Stack.
Object storage makes it possible to store massive amounts of unstructured data that is written once and read many times. 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).
There’s a handy open source platform that can serve your object storage needs. That project is called MinIO and was written in Go and is compatible with Amazon S3 object storage. Even better, you can install MinIO on your machines. I’m going to walk you through the process of getting MinIO installed on Rocky Linux. You can do this with Rocky Linux installed on your hardware in your data center (or developer network) or you can take this process to the cloud and your favorite cloud host. Either way you go, the process isn’t terribly difficult.
And, with that said, let’s get to said process.
What You’ll Need
To successfully pull this off, you’ll need the following:
- A running instance of Rocky Linux. I’ll be demonstrating on Rocky Linux 9.
- A user with sudo privileges.
- Enough space on your drive to house the storage (more on that in a bit).
That’s it. Time to work.
How to Install MinIO
The first thing we’ll do is install MinIO. Log in to your Rocky Linux instance and download the binary with the command:
1 |
sudo curl -o /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/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:
1 |
sudo chmod u+x /usr/local/bin/minio |
Make sure /usr/local/bin is in your user’s PATH with the command:
1 |
echo $PATH |
You should see something like this as the output:
1 |
-bash: /home/jack/.local/bin:/home/jack/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin: |
If you don’t find /usr/local/bin in your PATH, you can add it with:
1 |
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.bashrc |
Reload bashrc with:
1 |
source ~/.bashrc |
Now, when you check your PATH, you should see /usr/local/bin listed.
Verify the installation with:
1 |
minio --version |
You should see something like this in the output:
1 2 3 4 |
minio version RELEASE.2022-11-11T03-44-20Z (commit-id=bdcb485740ee2cf320c9b331ebd354df5bf6d826) Runtime: go1.19.3 linux/amd64 License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html> Copyright: 2015-2022 MinIO, Inc. |
Awesome. Let’s keep going.
How to Set up a Drive for MinIO Object Storage
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 /data.
First, created the /data directory with:
1 |
sudo mkdir /data |
Next, mount the drive with:
1 |
sudo mount /dev/sdb1 /data |
For our next trick, we’ll add an entry to fstab so the drive is always mounted, even after a reboot. Open fstab with:
1 |
sudo nano /etc/fstab |
At the bottom of that file, add the following:
1 |
/dev/sdb1 /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:
1 |
sudo mount -a |
You should see no errors.
How to Configure MinIO
First, we must add a specific user with the command:
1 |
sudo useradd -r minio -s /sbin/nologin |
Change the ownership of the data file so that it belongs to the minio user with:
1 |
sudo chown -R minio:minio /data |
Now, make a directory to house the MinIO configurations with:
1 |
sudo mkdir /etc/minio |
Give that directory the proper ownership with:
1 |
sudo chown -R minio:minio /etc/minio |
Create a configuration file for MinIO with the command:
1 |
sudo nano /etc/default/minio |
In that file, paste the following:
1 2 3 4 5 |
MINIO_ROOT_USER="minio" MINIO_VOLUMES="/minio-data" MINIO_OPTS="-C /etc/minio --address :9000 --console-address :9001" MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD="PWORD" |
Where PWORD is a strong/unique password.
Save and close the file.
Give that file the proper permissions with:
1 |
sudo chown minio:minio /etc/default/minio |
Create a systemd File for MinIO
We now must create a systemd file for MinIO. Do that with the command:
1 |
sudo nano /lib/systemd/system/minio.service |
In that file, paste the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[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:
1 |
sudo systemctl daemon-reload |
Start and enable the MinIO service with:
1 |
sudo systemctl enable --now minio |
Open the Firewall
Without the firewall open, we can’t access MinIO, which requires both 9000 and 9001 TCP ports open. Do this with the commands:
1 2 |
sudo firewall-cmd --zone=public --add-port=9000/tcp --permanent sudo firewall-cmd --zone=public --add-port=9001/tcp --permanent |
Reload the firewall with:
1 |
sudo firewall-cmd --reload |
How to Access 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 (Figure 1), 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 (Figure 2), where you can create your first storage bucket and manage things like access keys, identities, monitoring, notification, tiers, replication, and more.
-
Figure 2: The main MinIO window is ready to use.
And that’s all there is to create object storage on Rocky Linux. Enjoy that newfound ability to store your unstructured data.