Configure minio module, and use multiple minio nodes.
This is the multi-page printable view of this section. .
MinIO
Min.IO: S3-Compatible Open-Source Multi-Cloud Object Storage designed to be scalable, secure, and handy. It has native multi-node multi-driver HA support and can store documents, pictures, videos, and backups. It’s an optional module in Pigsty.
You can use MinIO as an optional PostgreSQL backup storage repo, in addition to the default local posix FS repo. If the MinIO repo is used,
the MINIO module should be installed before any PGSQL modules. MinIO requires a trusted CA to work, so you have to install it after NODE.
Customize minio components with 15 parameters
Create, remove, expand, shrink, upgrade minio cluster
Ansible playbooks that can be used in this module
Dashboards, metrics, record & alerting rules.
How to use the mcli and configure backup repo
1 - Usage
After MinIO cluster is configured and deployed with the playbook, you can start using and accessing the MinIO cluster by following the instructions here.
Deploy Cluster
It is straightforward to deploy a single-node MinIO instance with Pigsty.
Define it in the config inventory, then run the playbook:
The install.yml playbook will automatically create the MinIO cluster defined in the inventory, so you don’t need to run the minio.yml playbook manually, if you choose the default one-pass installation.
If you plan to deploy a production-grade large-scale multi-node MinIO cluster, we strongly recommend you to read the Pigsty MinIO configuration document and the MinIO document before proceeding.
Access Cluster
You have to access MinIO via HTTPS, so make sure the default minio service domain (sss.pigsty) point to the right place:
- You can add static resolution records in
node_etc_hostsor manually modify the/etc/hostsfile - You can add a record on the internal DNS server if you are using DNS service
- You can add a record in
dns_recordsif you are using the DNSMASQ on infra nodes
It is recommended to use the first method: static DNS resolution records to avoid MinIO’s additional dependency on DNS in production environments.
You have to point the MinIO service domain to the IP address and service port of the MinIO server node, or the IP address and service port of the load balancer. Pigsty will use the default domain name sss.pigsty and default port 9000.
For example, if you are using haproxy to expose MinIO service like this, the port may be 9002.
Adding Alias
To access the MinIO server cluster using the mcli client, you need to configure the server alias first:
There’s a pre-configured MinIO alias named sss on the admin user of the admin node, you can use it directly.
For the full functionality of the MinIO client tool mcli, please refer to the documentation: MinIO Client.
Manage User
You can manage biz users in MinIO using mcli, for example, you can create the two default biz users using the command line:
Manage Bucket
You can manage bucket with mcli:
Mange Object
You can perform object CRUD with cli, for example:
Check the Tutorial: Object Management for detail
Use rclone
Pigsty repo has rclone available, a convenient cloud object storage client that you can use to access MinIO services.
Backup Repo
The MinIO is used as a backup repository for pgBackRest by default in Pigsty. When you modify the pgbackrest_method to minio, the PGSQL module will automatically switch the backup repository to MinIO.
Beware that if you are using MinIO through load balancer, you should use the corresponding domain name and port number here.
2 - Configure
You have to define a MinIO cluster in the config inventory before deploying it.
There are 3 major deployment modes for MinIO clusters:
- SNSD: Single-Node Single-Drive: you can use any dir as a disk driver in this mode, convenient for dev/test/demo.
- SNMD: Single-Node Multi-Drive: a compromise mode, use multiple disks (>=2) on a single server, only when resources are extremely limited.
- MNMD: Multi-Node Multi-Drive: standard production deployment with the best reliability, but requires multiple servers and real drivers.
We recommend using SNSD and MNMD for development and production deployment, respectively, and SNMD only when resources are extremely limited (only one server).
Besides, you can use multi-pool deployment to scale an existing MinIO cluster, or directly deploy multiple clusters.
When using a multi-node MinIO cluster, you can access the service from any node, so the best practice is to use a load balancer and HA access.
Core Param
There’s one and only one core param for MinIO deployment, which is MINIO_VOLUMES, which specifies the nodes, drivers, pools of a minio cluster
Pigsty will auto-generate MINIO_VOLUMES according to the config inventory for you, but you can always override it directly. If not explicitly specified, Pigsty will generate it according to the following rules:
-
SNSD:
MINIO_VOLUMESpoints to any dir on local node, fromminio_data -
SNMD:
MINIO_VOLUMESpoints to a series of real drivers on local node, fromminio_data -
MNMD:
MINIO_VOLUMESpoints to multiple nodes & multiple drivers, according tominio_dataandminio_node -
Use
minio_datato specify drivers on each node, such as/data{1...4} -
Use
minio_nodeto specify node name pattern, such as${minio_cluster}-${minio_seq}.pigsty -
Multi-Pool:
MINIO_VOLUMESneed to be explicitly specified
Single-Node Single-Drive
Tutorial: deploy-minio-single-node-single-drive
To define a singleton MinIO instance, it’s straightforward:
The only required params are minio_seq and minio_cluster, which generate a unique identity for each MinIO instance.
Single-Node Single-Driver mode is for dev purposes, so you can use a common dir as the data dir. The default data dir for SNSD minio is specified by minio_data, which is /data/minio by default. Beware that in multi-driver or multi-node mode, MinIO will refuse to start if using a common dir as the data dir rather than a mount point.
We strongly recommend using a static domain name record to access MinIO. For example, the default sss.pigsty if minio_domain can be added to all nodes through:
Single-Node Multi-Drive
Reference: deploy-minio-single-node-multi-drive
To use multiple disks on a single node, you have to specify the minio_data in the format of {{ prefix }}{x...y}, which defines a series of disk mount points.
Use real drivers and mountpoint
Beware that in multi-driver or multi-node mode, MinIO will refuse to start if using a common dir as the data dir rather than a mount point.
This example defines a single-node MinIO cluster with 4 drivers: /data1, /data2, /data3, /data4. You have to mount them properly before launching MinIO:
The vagrant MinIO sandbox has a pre-defined 4-node MinIO cluster with 4 drivers. You have to properly mount them before starting MinIO (be sure to format disks with xfs):
Disk management is beyond this topic, just make sure your /etc/fstab is properly configured to auto-mount disks after reboot.
SNMD mode can utilize multiple disks on a single server to provide higher performance and capacity, and tolerate partial disk failures.
But it can do nothing with node failure, and you can’t add new nodes at runtime, so we don’t recommend using SNMD mode in production unless you have a special reason.
Multi-Node Multi-Drive
Reference: deploy-minio-multi-node-multi-drive
The extra minio_node param will be used for a multi-node deployment in addition to the minio_data
For example, this configuration defines a 4-node MinIO cluster with 4 drivers per node:
The minio_node param specifies the MinIO node name pattern, which is ${minio_cluster}-${minio_seq}.pigsty by default. The server name is very important for MinIO to identify and access other nodes in the cluster. It will be populated with minio_cluster and minio_seq, and write to /etc/hosts of all minio cluster members.
In this case, the MINIO_VOLUMES will be set to https://minio-{1...4}.pigsty/data{1...4} to identify the 16 disks on 4 nodes.
Multi-Pool
MinIO’s architecture allows for cluster expansion by adding new storage pools. In Pigsty, you can achieve this by explicitly specifying the minio_volumes param to specify nodes/disks for each pool.
For example, suppose you have already created a MinIO cluster as defined in the Multi-Node Multi-Disk example, and now you want to add a new storage pool consisting of four nodes.
You can specify minio_volumes here to allocate nodes for each pool to scale out the cluster.
Here, the two space-separated parameters represent two storage pools, each with four nodes and four disks per node.
For more information on storage pools, please refer to Management Plan: MinIO Cluster Expansion.
Multiple Clusters
You can deploy new MinIO nodes as a completely new MinIO cluster by defining a new group with a different cluster name.
The following configuration declares two independent MinIO clusters:
Please note that by default, Pigsty allows only one MinIO cluster per deployment. If you need to deploy multiple MinIO clusters, some parameters with default values need to be explicitly set and cannot be omitted to avoid naming conflicts, as shown above.
Expose Service
MinIO will serve on port 9000 by default. If a multi-node MinIO cluster is deployed, you can access its service via any node. It would be better to expose MinIO service via a load balancer, such as the default haproxy on NODE, or use the L2 vip.
To expose MinIO service with haproxy, you have to define an extra service with haproxy_services:
MinIO uses port 9000 by default. A multi-node MinIO cluster can be accessed by connecting to any one of its nodes.
Service access falls under the scope of the NODE module, and we’ll provide only a basic introduction here.
High-availability access to a multi-node MinIO cluster can be achieved using an L2 VIP or HAProxy. For example, you can use Keepalived to bind an L2 VIP to the MinIO cluster,
or use the haproxy component provided by the NODE module to expose MinIO services through a load balancer.
In the configuration above, HAProxy is enabled on all nodes of the MinIO cluster, exposing MinIO services on port 9002, and a Layer 2 VIP is bound to the cluster.
When in use, users should point the sss.pigsty domain name to the VIP address 10.10.10.9 and access MinIO services using port 9002.
This ensures high availability, as the VIP will automatically switch to another node if any node fails.
In this scenario, you may also need to globally modify the destination of domain name resolution
and adjust the minio_endpoint parameter to change the endpoint address corresponding to the MinIO alias on the management node:
Dedicate Proxies
Pigsty allows using dedicate load balancer cluster instead of the node cluster itself to run VIP & HAProxy.
For example, the prod template uses this way.
In this case, you need to manually configure the DNS resolution to point sss.pigsty to the VIP address of dedicated proxies cluster
Access Service
To use the exposed service, you have to update/append the MinIO credential in the pgbackrest_repo section:
Expose Console
MinIO has a built-in console that can be accessed via HTTPS @ minio_admin_port. If you want to expose the MinIO console to the outside world, you can add MinIO to infra_portal.
Beware that MinIO console should be accessed via HTTPS, please DO NOT expose MinIO console without encryption in production.
Which means you usually need to add m.pigsty resolution to your DNS server, or /etc/hosts on your local host, to access the MinIO console.
Meanwhile, if you are using Pigsty’s self-signed CA rather than a regular public CA, you usually need to manually trust the CA or certificate to skip the “insecure” warning in the browser.
3 - Parameter
MinIO is a S3 compatible object storage service. Which is used as an optional central backup storage repo for PostgreSQL.
You may also use it for other purposes, such as storing large files, documents, pictures & videos.
Parameters
There are 21 documented settings: 16 declared MINIO parameters, 2 derived values that may be overridden, and 3 MINIO_REMOVE flags.
| Parameter | Type | Level | Comment |
|---|---|---|---|
minio_seq |
int | I | minio instance identifier, REQUIRED |
minio_cluster |
string | C | minio cluster name, minio by default |
minio_user |
username | C | minio os user, minio by default |
minio_https |
bool | G | use https for minio, true by default |
minio_node |
string | C | minio node name pattern |
minio_data |
path | C | minio data dir(s), use {x...y} to specify multi drivers |
minio_volumes |
string | C | minio core parameter, specify nodes and disks, auto-gen by default |
minio_domain |
string | G | minio external domain name, sss.pigsty by default |
minio_port |
port | C | minio service port, 9000 by default |
minio_admin_port |
port | C | minio console port, 9001 by default |
minio_access_key |
username | C | root access key, minioadmin by default |
minio_secret_key |
password | C | root secret key, minioadmin by default |
minio_extra_vars |
string | C | extra environment variables for minio server |
minio_provision |
bool | G/C | run minio provisioning tasks? |
minio_alias |
string | G | alias name for local minio deployment |
minio_endpoint |
string | C | corresponding host:port for above minio alias |
minio_buckets |
bucket[] | C | list of minio bucket to be created |
minio_users |
user[] | C | list of minio user to be created |
MINIO_REMOVE Parameters (for minio_remove role)
| Parameter | Type | Level | Comment |
|---|---|---|---|
minio_safeguard |
bool | G/C/A | prevent accidental removal? (default: false) |
minio_rm_data |
bool | G/C/A | remove minio data during removal? (default: true) |
minio_rm_pkg |
bool | G/C/A | uninstall minio packagkes during removal? (default: false) |
The minio_volumes and minio_endpoint are auto-generated parameters, but you can explicitly override these two parameters.
Defaults
MINIO: 18 settings (including 2 derived values), defined in roles/minio/defaults/main.yml
MINIO_REMOVE: 3 Parameters, defined in roles/minio_remove/defaults/main.yml:
minio_seq
name: minio_seq, type: int, level: I
minio instance identifier, REQUIRED identity parameters. no default value, you have to assign it manually
minio_cluster
name: minio_cluster, type: string, level: C
minio cluster name, minio by default. This is useful when deploying multiple MinIO clusters
minio_user
name: minio_user, type: username, level: C
minio os user name, minio by default
minio_https
name: minio_https, type: bool, level: G
Use HTTPS or HTTP for MinIO service, true by default, means using HTTPS.
Beware that pgbackrest requires MinIO HTTPS to work properly, but if you don’t use minio for that, and don’t want to use HTTPS for MinIO, you can set this to false.
minio_node
name: minio_node, type: string, level: C
minio node name pattern, this is used for multi-node deployment
default values: ${minio_cluster}-${minio_seq}.pigsty
minio_data
name: minio_data, type: path, level: C
minio data dir(s)
default values: /data/minio, which is a common dir for single-node deployment.
For a multi-drive deployment, you can use {x...y} notion to specify multi drivers.
minio_volumes
name: minio_volumes, type: string, level: C
The only core parameter of MinIO, if not specified, it will be auto-generated by the following rule:
- In case of SNSD or SNMD deployment,
minio_volumesdirectly uses the value ofminio_data - In case of MNMD deployment,
minio_volumesuses the values ofminio_node,minio_port,minio_datato generate this param: - In case of multiple storage pool, you have to override
minio_volumesto specify multiple node pools explicitly.
It user’s responsibility to make sure the parameters used in minio_volumes are consistent with minio_node, minio_port, minio_data.
minio_domain
name: minio_domain, type: string, level: G
minio service domain name, sss.pigsty by default.
The client can access minio S3 service via this domain name. This name will be registered to local DNSMASQ and included in SSL certs.
minio_port
name: minio_port, type: port, level: C
minio service port, 9000 by default
minio_admin_port
name: minio_admin_port, type: port, level: C
minio console port, 9001 by default
minio_access_key
name: minio_access_key, type: username, level: C
root access key, minioadmin by default
minio_secret_key
name: minio_secret_key, type: password, level: C
root secret key, minioadmin by default
default values: minioadmin
It’s very important to change this password in your deployment!
minio_extra_vars
name: minio_extra_vars, type: string, level: C
extra environment variables for minio server. Check Minio Server for the complete list.
default value is empty string, you can use multiline string to passing multiple environment variables.
minio_alias
name: minio_alias, type: string, level: G
MinIO alias name for the local MinIO cluster
default values: sss, which will be written to infra nodes’ / admin users’ client alias profile.
minio_endpoint
name: minio_endpoint, type: string, level: C
The corresponding host:port for the above MinIO alias. This parameter is not defined by default.
If not defined, it will be overwritten by the following default value:
This alias & endpoint will be added to the admin user on the admin node.
minio_buckets
name: minio_buckets, type: bucket[], level: C
list of minio bucket to be created by default:
Three default buckets are created by default, with different policies.
The pgsql bucket is used for PostgreSQL backups by default. while meta and data are open buckets for other purposes.
For example, the supabase template may use the data bucket to store business data.
And if you have important metadata that requires versioning, you can use the meta bucket out-of-the-box.
Every bucket will have a corresponding policy, with names same as the bucket name. e.g., the pgsql policy have all the privileges on the pgsql bucket, and so on.
You can also add the lock flag to bucket definition, which will enable the object locking feature to prevent accidental deletion of objects in the bucket.
minio_users
name: minio_users, type: user[], level: C
list of minio users to be created, default value:
Two default users are created for PostgreSQL DBA and pgBackREST.
Please change these passwords in serious production deployments.
minio_safeguard
name: minio_safeguard, type: bool, level: G/C/A
prevent accidental removal? default value is false
If enabled, the minio-rm.yml playbook will abort and refuse to remove the MinIO cluster, providing protection against accidental deletions.
minio_rm_data
name: minio_rm_data, type: bool, level: G/C/A
remove minio data during removal? default value is true
When enabled, the minio-rm.yml playbook will remove MinIO data directories and configuration files during cluster removal.
minio_rm_pkg
name: minio_rm_pkg, type: bool, level: G/C/A
uninstall minio packages during removal? default value is false
When enabled, the minio-rm.yml playbook will uninstall MinIO packages during cluster removal. This is disabled by default to preserve the MinIO installation for potential future use.
4 - Administration
Here are some administration SOP for MinIO:
- Create Cluster
- Remove Cluster
- Expand Cluster
- Shrink Cluster
- Upgrade Cluster
- Node Failure Recovery
- Disk failure Recovery
Check ETCD: FAQ for more questions.
Create Cluster
To create a MinIO cluster, define the minio cluster in inventory first:
The minio_cluster param mark this cluster as a MinIO cluster, and the minio_seq is the sequence number of the MinIO node, which is used to generate MinIO node name like minio-1, minio-2, etc.
This snippet defines a single-node MinIO cluster, using the following command to create the MinIO cluster:
Remove Cluster
To destroy an existing MinIO cluster, use the dedicated minio-rm.yml playbook:
You can also customize the removal process with parameters:
Legacy approach (deprecated):
Since Pigsty v3.6+, MinIO cluster removal has been moved to the dedicated minio-rm.yml playbook using the minio_remove role. The prometheus monitoring targets are automatically cleaned up during the removal process.
Expand Cluster
You cannot scale MinIO at node/disk level, but you can scale at storage pool (multiple nodes) level.
Assume you have a 4-node MinIO cluster and want to double the capacity by adding another four-node storage pool.
Step 1, add 4 node definitions in the group, allocate sequence number 5 to 8.
The key step is to modify the minio_volumes param, assign the new 4 nodes to a new storage pool.
Step 2, adding these nodes to Pigsty:
Step 3, Provisioning MinIO on new nodes with minio_install subtask (user, dir, pkg, …):
Step 4: Reconfigure the entire MinIO cluster on the whole cluster with minio_config subtask
That is to say, the existing 4-nodes’
MINIO_VOLUMESconfiguration will be updated, too
Step 5: Restart the entire MinIO cluster simultaneously (be careful, do not rolling restart!):
Step 6: This is optional, if you are using a load balancer, make sure the load balancer configuration is updated.
For example, add the new four nodes to the load balancer configuration:
Then run the haproxy subtask of the node.yml playbook to update the load balancer configuration:
If node L2 VIP is also used to ensure reliable load balancer access, you also need to add new nodes (if any) to the existing NODE VIP group:
Shrink Cluster
MinIO cannot scale down at the node/disk level, but you can retire at the storage pool (multiple nodes) level —— Add a new storage pool, drain the old storage pool, migrate to the new storage pool, and then retire the old storage pool.
Upgrade Cluster
First, download the new version of the MinIO software package to the local software repository of the INFRA node:
- minio:
- mcli:
and then rebuild the software repo with:
You can upgrade all MinIO software packages with Ansible package module:
Finally, notify the MinIO cluster to restart with the mc command line tool:
Node Failure Recovery
Disk Failure Recovery
5 - Playbook
You have to configure minio cluster in the config inventory before running the playbook.
Playbook
There are two built-in playbooks for MinIO cluster management:
minio.ymlfor installing the MinIO clusterminio-rm.ymlfor removing the MinIO cluster
minio.yml
minio-id: generate minio identityminio_install: install minio/mcliminio_os_user: create os user miniominio_pkg: install minio/mcli packageminio_dir: create minio directories
minio_config: generate minio configminio_conf: minio main configminio_cert: minio ssl certminio_dns: write minio dns records
minio_launch: launch minio serviceminio_register: register minio to prometheusminio_provision: create minio aliases/buckets/usersminio_alias: create minio client aliasminio_bucket: create minio bucketsminio_user: create minio biz users
Since Pigsty v3.6+, the minio.yml playbook and minio role are focused solely on cluster installation. All removal operations have been moved to the dedicated minio-rm.yml playbook using the minio_remove role.
Trusted ca file: /etc/pki/ca.crt should exist on all nodes already. which is generated in role: ca and loaded & trusted by default in role: node.
You should install MINIO module on Pigsty-managed nodes (i.e., Install NODE first)
minio-rm.yml
To remove the MinIO cluster, run the following playbook:
Here are available sub tasks:
minio-id: generate minio identity for removal operationsminio_safeguard: safeguard against accidental removal (default:false)prometheus: remove minio targets registration from prometheusminio_svc: stop and disable minio service with systemdminio_data: remove minio data (disable withminio_rm_data=false)minio_pkg: uninstall minio packages (enable withminio_rm_pkg=true)
The removal playbook uses the new minio_remove role with configurable parameters:
minio_safeguard: Prevents accidental removal when set totrueminio_rm_data: Controls whether MinIO data is deleted (trueby default)minio_rm_pkg: Controls whether MinIO packages are uninstalled (falseby default)
Commands
MINIO Playbook cheatsheet and common commands
6 - Monitor
Dashboard
There is one dashboard for MINIO module.
MinIO Overview: Overview of one single MinIO cluster
Alert Rules
There are 3 predefined alert rules for MinIO, defined in files/prometheus/rules/minio.yml
MinioServerDownMinioNodeOfflineMinioDiskOffline
7 - FAQ
Fail to launch multi-node / multi-driver MinIO cluster.
In Multi-Driver or Multi-Node mode, MinIO will refuse to start if the data dir is not a valid mount point.
Use mounted disks for MinIO data dir rather than some regular directory. You can use the regular directory only in the single node, single drive mode.
How to deploy a multi-node multi-drive MinIO cluster?
How to add a member to the existing MinIO cluster?
You’d better plan the MinIO cluster before deployment… Since this requires a global restart
Check this: Expand MinIO Deployment
How to use a HA MinIO deployment for PGSQL?
Access the HA MinIO cluster with an optional load balancer and different ports.
Here is an example: Access MinIO Service