TNS
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
NEW! Try Stackie AI
Linux / Storage

Add Object Storage to Rocky Linux with MinIO

Nov 19th, 2022 6:00am by
Featued image for: 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:

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:

sudo chmod u+x /usr/local/bin/minio

Make sure /usr/local/bin is in your user’s PATH with the command:

echo $PATH

You should see something like this as the output:

-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:

echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.bashrc

Reload bashrc with:

source ~/.bashrc

Now, when you check your PATH, you should see /usr/local/bin listed.

Verify the installation with:

minio --version

You should see something like this in the output:

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:

sudo mkdir /data

Next, mount the drive with:

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:

sudo nano /etc/fstab

At the bottom of that file, add the following:

/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:

sudo mount -a

You should see no errors.

How to Configure MinIO

First, we must add a specific user with the command:

sudo useradd -r minio -s /sbin/nologin

Change the ownership of the data file so that it belongs to the minio user with:

sudo chown -R minio:minio /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 nano /etc/default/minio

In that file, paste the following:

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:

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:

sudo nano /lib/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

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

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.

Figure 1: Authenticate with Minio.

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.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Unit.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.