MinIO Object Storage

Sets up MinIO S3-compatible object storage server

Script Author

Rowan de Haas's avatar
Rowan de Haas
Script Author

Script Details

Created 7 months ago
Size 3 KB

Tags

Script Content

Raw
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#cloud-config
package_update: true
package_upgrade: true

packages:
  - wget

users:
  - name: minio
    system: true
    shell: /bin/false
    home: /opt/minio

write_files:
  - path: /etc/default/minio
    content: |
      MINIO_ROOT_USER=minioadmin
      MINIO_ROOT_PASSWORD=SecureMinIOPassword123!
      MINIO_OPTS="--console-address :9001"
      MINIO_VOLUMES="/opt/minio/data"
    permissions: '0640'
    owner: minio:minio

  - path: /etc/systemd/system/minio.service
    content: |
      [Unit]
      Description=MinIO
      Documentation=https://docs.min.io
      Wants=network-online.target
      After=network-online.target
      AssertFileIsExecutable=/usr/local/bin/minio

      [Service]
      WorkingDirectory=/opt/minio/
      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
      
      # Specifies the maximum number of threads this process can create
      TasksMax=infinity
      
      # Disable timeout logic and wait until process is stopped
      TimeoutStopSec=infinity
      SendSIGKILL=no

      [Install]
      WantedBy=multi-user.target

runcmd:
  # Download and install MinIO
  - cd /tmp
  - wget https://dl.min.io/server/minio/release/linux-amd64/minio
  - chmod +x minio
  - mv minio /usr/local/bin/
  # Create directories
  - mkdir -p /opt/minio/data
  - chown -R minio:minio /opt/minio
  # Enable and start MinIO
  - systemctl enable minio
  - systemctl start minio
  # Configure firewall
  - ufw allow 9000/tcp
  - ufw allow 9001/tcp
  # Display access information
  - sleep 10
  - echo "MinIO Console: http://localhost:9001"
  - echo "MinIO API: http://localhost:9000"

How to Use This Script

Cloud Provider Examples

Amazon EC2

aws ec2 run-instances
  --image-id ami-12345678
  --instance-type t3.micro
  --user-data file://script.yaml

DigitalOcean

doctl compute droplet create
  --image ubuntu-22-04-x64
  --size s-1vcpu-1gb
  --user-data-file script.yaml
  my-droplet

Google Cloud

gcloud compute instances create
  my-instance
  --metadata-from-file
  user-data=script.yaml