Installing Minio as a Service on CentOS 7.3+

Introduction

This document outlines the procedures to install Minio as a Service on a new CentOS 7.3 Minimal server. It provides a little more detail to the procedures in the references at the bottom of this article.

My Test Environment

I’m using VirtualBox on a Windows 10 Workstation, with a fresh install of CentOS 7.3 Minimal. Also installed is a copy of Git Bash for Windows.

The reason I use Git Bash is because I can copy/paste text from the examples below into the Git Bash prompt.

Starting Up

Install CentOS 7.3 Minimal in VirtualBox configured with bridged networking.

Start it up and run:

$ ip a                                                # and find the IP address of your CentOS server
 
inet 192.168.1.81

Install and run Git Bash on your Windows workstation and login to your server:

mynmame@COMPUTER MINGW64 ~
$ ssh username@192.168.1.81
username@192.168.1.81’s password:
Last login: Sun Jun 25 15:51:55 2017 from 192.168.1.70
[username@centest ~]$

Install wget on the CentOS Server

$ sudo yum -y install wget

Download and Install Minio

$ wget https://dl.minio.io/server/minio/release/linux-amd64/minio
$ chmod 755 minio
$ sudo chown root:root minio
$ sudo mv minio /usr/local/bin

Open Firewall Port for Minio

$ sudo firewall-cmd --zone=public --add-port=9000/tcp --permanent
$ sudo firewall-cmd --reload

 

Basic Test of Minio

$ mkdir miniodir
$ minio server miniodir

You should see something along the lines of (record the AccessKey and SecretKey for later):

Endpoint:  http://192.168.1.81:9000  http://172.17.0.1:9000  http://127.0.0.1:9000
AccessKey: 5D0EN4B8SF7EYUJH1V8I
SecretKey: BjtgRNuLHBSEUU4e2Yzz/lBVjoFVnIvCr6rGFRXo
Browser Access:
http://192.168.1.81:9000  http://172.17.0.1:9000  http://127.0.0.1:9000
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
$ mc config host add myminio http://192.168.1.81:9000 5D0EN4B8SF7EYUJH1V8I BjtgRNuLHBSEUU4e2Yzz/lBVjoFVnIvCr6rGFRXo
Object API (Amazon S3 compatible):
Go:         https://docs.minio.io/docs/golang-client-quickstart-guide
Java:       https://docs.minio.io/docs/java-client-quickstart-guide
Python:     https://docs.minio.io/docs/python-client-quickstart-guide
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
.NET:       https://docs.minio.io/docs/dotnet-client-quickstart-guide
Drive Capacity: 38 GiB Free, 40 GiB Total

On your Windows Web browser, you should now be able to access the host via web browser, i.e.

http://192.168.1.81:9000

Copy and paste the AccessKey and SecretKey from the Git Bash shell into the browser to login.

Once done, go back to Git Bash and exit the test server with ^C and continue.

Configure Minio As a Service

This allows Minio to startup automatically when the system restarts.

Create a Minio user

$ sudo adduser minio-user

Create a Minio directory

$ sudo mkdir /tmp/minio
$ sudo chown minio-user:minio-user /tmp/minio

Create a Configuration File

$ sudo su
# cat <<EOT >> /etc/default/minio
MINIO_VOLUMES="/tmp/minio/"
MINIO_OPTS="--address :9000"
EOT

 

Update the Keys

Rather than uses the keys below, you might want to use the keys that were created when you tested the server.

$ sudo su
# cat <<EOT >> /etc/default/minio
MINIO_ACCESS_KEY=5D0EN4B8SF7EYUJH1V8I
MINIO_SECRET_KEY=BjtgRNuLHBSEUU4e2Yzz/lBVjoFVnIvCr6rGFRXo
EOT

Add the Service to Systemd

Create a new file called minio.service in /etc/systemd/system and add the following to it:

[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-user
Group=minio-user
 
PermissionsStartOnly=true
 
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "[ -n \"${MINIO_VOLUMES}\" ] || echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\""
 
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
 
StandardOutput=journal
StandardError=inherit
 
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
 
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=0
 
# SIGTERM signal is used to stop Minio
KillSignal=SIGTERM
 
SendSIGKILL=no
 
SuccessExitStatus=0
 
[Install]
WantedBy=multi-user.target

 

Enable the Minio Service

$ sudo systemctl enable minio
 

Start the Minio Service

$ sudo systemctl start minio

Status of the Minio Service

$ sudo systemctl status minio

  • minio.service – Minio

Loaded: loaded (/etc/systemd/system/minio.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-06-22 12:55:34 PDT; 4s ago
Docs: https://docs.minio.io
Process: 6829 ExecStartPre=/bin/bash -c [ -n “${MINIO_VOLUMES}” ] || echo “Variable MINIO_VOLUMES not set in /etc/default/minio” (code=exited, status=0/SUCCESS)
Main PID: 6830 (minio)
CGroup: /system.slice/minio.service
└─6830 /usr/local/bin/minio server –address :9000 /tmp/minio/
 
Jun 22 12:55:35 centest.dev minio[6830]: http://192.168.1.81:9000  http://172.17.0.1:9000  http://127.0.0.1:9000
Jun 22 12:55:35 centest.dev minio[6830]: Command-line Access: https://docs.minio.io/docs/minio-client-qui…guide
Jun 22 12:55:35 centest.dev minio[6830]: $ mc config host add myminio http://192.168.1.81:9000 5D0EN4B8SF…GFRXo
Jun 22 12:55:35 centest.dev minio[6830]: Object API (Amazon S3 compatible):
Jun 22 12:55:35 centest.dev minio[6830]: Go:         https://docs.minio.io/docs/golang-client-quickstart-guide
Jun 22 12:55:35 centest.dev minio[6830]: Java:       https://docs.minio.io/docs/java-client-quickstart-guide
Jun 22 12:55:35 centest.dev minio[6830]: Python:     https://docs.minio.io/docs/python-client-quickstart-guide
Jun 22 12:55:35 centest.dev minio[6830]: JavaScript: https://docs.minio.io/docs/javascript-client-quickst…guide
Jun 22 12:55:35 centest.dev minio[6830]: .NET:       https://docs.minio.io/docs/dotnet-client-quickstart-guide
Jun 22 12:55:35 centest.dev minio[6830]: Drive Capacity: 37 GiB Free, 40 GiB Total
Hint: Some lines were ellipsized, use -l to show in full.
[root@centest default]#

Stop the Minio Service

$ sudo systemctl stop minio

Finish

At this point, you should be able to reboot the server and Minio should start up automatically.

References

  • http://www.installvirtual.com/how-to-install-minio-on-centos-7/
  • http://www.installvirtual.com/system-services-for-minio-centos/
Comments are closed.