How to set up Minio as an Object Storage in Rocky Linux Server

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.

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

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

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

Once downloaded you can check the version

1
2
3
4
5
6
$ 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:

1
sudo mkdir /data

Next, mount the drive with:

1
sudo mount /dev/sdb1 /mnt/data

To mount the drive on boot, we need to add an entry to fstab. Open fstab:

1
sudo vim /etc/fstab

At the bottom of that file, add the following:

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

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

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

1
sudo useradd -r minio -s /sbin/nologin

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

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

In that file, paste the following:

1
2
3
4
5
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:

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

1
sudo vim /etc/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
[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

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:

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

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.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy