Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 202Data · MinIO

How to store files in MinIO with the S3 API

Backups, uploads and build artifacts need object storage, but not every system can use a public cloud. MinIO speaks the same S3 API on your own servers, so the AWS CLI, restic, Velero and every S3 library work with it. This how-to creates a bucket with versioning and an expiry rule, a user that can only write to that bucket, and uses it from mc and the AWS CLI.

  • 5 Lessen
  • 2 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

202.1

The quick answer

mc alias set s3 https://s3.example.com:9000 minio-admin 'ROOT-PASSWORD'
mc mb s3/backups
mc version enable s3/backups
mc ilm rule add --expire-days 90 --noncurrent-expire-days 30 s3/backups
mc cp backup.tar.gz s3/backups/web1/
mc ls s3/backups/web1/

Commando's in deze les

202.2

Step by step

  1. Alias (quick answer, line 1) — mc stores the address and keys in ~/.mc/config.json (mode 600). Use the root user only for setup.
  2. Bucket with versioning — an overwritten or deleted file keeps its old version; together with the lifecycle rule old versions go away after 30 days.
  3. A user with a small policy — only this bucket, only what backups need:
backup-writer.json
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow", "Action": ["s3:ListBucket"], "Resource": ["arn:aws:s3:::backups"] },
    { "Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject"], "Resource": ["arn:aws:s3:::backups/*"] }
  ]
}
mc admin policy create s3 backup-writer backup-writer.json
mc admin user add s3 web1-backup 'LONG-RANDOM-SECRET'
mc admin policy attach s3 backup-writer --user web1-backup

No DeleteObject: a hacked server cannot delete its backups.

  1. Use the AWS CLI — any S3 tool works with the endpoint:
aws --profile minio --endpoint-url https://s3.example.com:9000 s3 cp report.csv s3://backups/web1/
aws --profile minio --endpoint-url https://s3.example.com:9000 s3 ls s3://backups/web1/
  1. Share one file for a short time — a signed URL that expires:
mc share download --expire 2h s3/backups/web1/backup.tar.gz
  1. Protect against ransomware — object lock (mc mb --with-lock at creation, then mc retention set --default GOVERNANCE 30d) makes objects undeletable for 30 days.
  2. Watch it — mc admin info s3 (disks, health), and the Prometheus metrics endpoint for capacity alerts.

Commando's in deze les

202.3

Check that it worked

mc ls lists the file; mc version info s3/backups shows versioning enabled; with the web1-backup keys an upload works but mc rm and access to other buckets fail with Access Denied; mc ilm rule ls s3/backups shows the rule.

Commando's in deze les

202.4

Common problems

ProblemCauseFix
Access Denied for the new userPolicy covers bucket/* but not bucket (or the reverse).List both resources as in the policy above.
x509: certificate signed by unknown authorityPrivate CA.Put the CA in the system trust store or ~/.mc/certs/CAs/.
AWS CLI goes to amazonaws.comNo --endpoint-url.Add it, or endpoint_url in the profile.
Path-style errors with some toolsTool expects virtual-host style.Enable path-style (s3ForcePathStyle, addressing_style = path).
Disk fills although files were deletedVersioning keeps old versions.Noncurrent expiry rule; check mc du --versions.
mc ilm command not foundOld mc with old syntax.Update mc; current syntax is mc ilm rule add.

Commando's in deze les

202.5

Go further

1Why give the backup user no DeleteObject right?

If the server is hacked, the attacker can upload but cannot delete the existing backups.

2How do other S3 tools talk to MinIO?

They use the normal S3 API with MinIO's address as the endpoint URL.

Commando's in deze les

Alle commando's in dit hoofdstuk