iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📥

Introduction to MinIO: AWS S3-Compatible Storage — Trying out mc.exe

に公開

objects

Trying out the mc command as an alternative to the S3 aws command

MinIO is a service compatible with AWS cloud storage S3, but you don't necessarily need to use the AWS cloud; you can install it on your own server to build a simple object storage (file server).

Here, I will introduce how to easily create an environment on Windows to learn the MinIO client mc, which serves as an alternative to S3's aws command. For example, you will be able to easily try the mc mb command, which corresponds to the aws mb command for creating buckets. You can also try listing items with the mc ls command and uploading/downloading with the mc cp command. By trying these out, you can get a better idea of what object storage is, making the transition to learning more about MinIO deployed in Docker or on servers much smoother.

While MinIO services become robust and high-performing when distributed across three servers, for the sake of an easy introduction, we will deploy it on a single local Windows machine here. The client will also run on the same local Windows machine.

Note that this article refers to the official MinIO documentation: https://docs.min.io/docs/minio-client-quickstart-guide.html

Structured Procedure Text

For those who want precise steps rather than ambiguous text, I'll first show them in a structured text (YAML) format compatible with typrm. General text will be provided in later chapters.

Settings:
    __FileName__: _a.txt
    __MinIO_Alias__: minioalias
    __BucketName__: bucket1
    __MinIO_ConsolePort__: 60277
    __MinIO_EndPoint__: http://localhost:9000
    __MinIO_AccessKey__: minioadmin
    __MinIO_SecretKey__: minioadmin
    __MinIO_Folder__: ${env:USERPROFILE}\AppData\Roaming\MinIO  #// USERPROFILE = C:\Users\____\

Install MinIO Server:
    Download minio.exe:
        #ref: https://dl.min.io/server/minio/release/windows-amd64/minio.exe
    Display help:
        (PowerShell): |
            & ${env:USERPROFILE}\Downloads\minio
Start MinIO Server:
    (New PowerShell): |
        - mkdir ${env:USERPROFILE}\AppData\Roaming\MinIO
            #template: __MinIO_Folder__
        - & ${env:USERPROFILE}\Downloads\minio server ${env:USERPROFILE}\AppData\Roaming\MinIO --console-address ":60277"
            #template: __MinIO_Folder__ --console-address ":__MinIO_ConsolePort__"
    Open MinIO Console in browser:  #keyword: MinIO console
        URL: http://localhost:60277  #template: __MinIO_ConsolePort__
        Username: minioadmin         #template: __MinIO_AccessKey__
        Password: minioadmin         #template: __MinIO_SecretKey__
    Display logs:
        MinIO console >> Tools >> Logs
Install MinIO client mc.exe:  #keyword: install mc MinIO
    Download mc.exe:
        #ref: https://dl.min.io/client/mc/release/windows-amd64/mc.exe
    Display help:
        (PowerShell): |
            & ${env:USERPROFILE}\Downloads\mc
    Official: #ref: https://docs.min.io/minio/baremetal/reference/minio-cli/minio-mc.html
Create a new alias:
    (PowerShell): |
        & ${env:USERPROFILE}\Downloads\mc alias set  minioalias  http://localhost:9000  minioadmin  minioadmin
            #template: mc alias set  __MinIO_Alias__  __MinIO_EndPoint__  __MinIO_AccessKey__  __MinIO_SecretKey__
    (Format):
        - mc alias set __Alias__  __EndPoint__
        - mc alias set __MinIO_Alias__  __EndPoint__  __AccessKey__  __SecretKey__  --api __API_Signature__
    __API_Signature__:
        If the --api option is omitted: S3v4
    (When setting passwords etc. in environment variables):
        export MC_HOST___Alias__=https://__AccessKey__:__SecretKey__@__EndPoint__
        #ref: https://docs.min.io/docs/minio-client-complete-guide.html >> Specify temporary host configuration through environment variable
Display connection info:
    (PowerShell): |
        & ${env:USERPROFILE}\Downloads\mc  admin info minioalias
            #template: mc  admin info __MinIO_Alias__
List buckets:  #keyword: mc ls example
    (PowerShell): |
        & ${env:USERPROFILE}\Downloads\mc  ls minioalias
            #template: mc  ls __MinIO_Alias__
    (Reference) When accessing the online playground site https://play.min.io/: |
        & ${env:USERPROFILE}\Downloads\mc  ls play
Create a new bucket:  #keyword: mc mb example
    (PowerShell): |
        & ${env:USERPROFILE}\Downloads\mc  mb minioalias/bucket1
        & ${env:USERPROFILE}\Downloads\mc  ls minioalias
            #template-at(-2): mc  mb __MinIO_Alias__/__BucketName__
            #template-at(-2): mc  ls __MinIO_Alias__
Upload a file:  #keyword: mc cp example
    (PowerShell): |
        echo a > _a.txt
            #template: __FileName__
        & ${env:USERPROFILE}\Downloads\mc  cp _a.txt  minioalias/bucket1
        & ${env:USERPROFILE}\Downloads\mc  ls minioalias/bucket1
            #template-at(-2): mc  cp __FileName__  __MinIO_Alias__/__BucketName__
            #template-at(-2): mc  ls __MinIO_Alias__/__BucketName__
        rm _a.txt
            #template: __FileName__
Exit:
    Shell where minio.exe is running >> Ctrl + C
Uninstall:
    Delete minio.exe and mc.exe:
        (PowerShell): |
            rm  ${env:USERPROFILE}\Downloads\minio.exe
            rm  ${env:USERPROFILE}\Downloads\mc.exe
    Delete folders used by minio.exe:
        (PowerShell): |
            rm -r -fo ${env:USERPROFILE}\mc
            rm -r -fo ${env:USERPROFILE}\AppData\Roaming\MinIO

Procedure

Install MinIO Server

Enter https://dl.min.io/server/minio/release/windows-amd64/minio.exe into your browser's address bar and press Enter to download minio.exe. Note that this address is the one listed in the Windows instructions on the official MinIO site: https://docs.min.io/docs/minio-client-quickstart-guide.html. For security, please ensure that the URL domain is .min.io when downloading.

Open the Windows Start menu, type "PowerShell" to open it, and enter the following:

& ${env:USERPROFILE}\Downloads\minio

If the help is displayed as follows, the download was successful.

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\minio
NAME:
  minio.exe - High Performance Object Storage

DESCRIPTION:
  Build high performance data infrastructure for machine learning, analytics and application data workloads with MinIO

USAGE:
  minio.exe [FLAGS] COMMAND [ARGS...]

COMMANDS:
  server   start object storage server
  gateway  start object storage gateway

FLAGS:
  --certs-dir value, -S value  path to certs directory (default: "C:\\Users\\ts-ne\\.minio\\certs")
  --quiet                      disable startup information
  --anonymous                  hide sensitive information from logging
  --json                       output server logs and startup information in json format
  --help, -h                   show help
  --version, -v                print the version

VERSION:
  RELEASE.2022-01-08T03-11-54Z

Start the MinIO Server

Open a new PowerShell window and enter the following. If a security confirmation from Windows Defender appears, please allow it.

mkdir ${env:USERPROFILE}\AppData\Roaming\MinIO
& ${env:USERPROFILE}\Downloads\minio server ${env:USERPROFILE}\AppData\Roaming\MinIO --console-address ":60277"

If the following is displayed, the server startup was successful.

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\minio server ${env:USERPROFILE}\AppData\Roaming\MinIO --console-address ":60277"
API: http://192.168.2.110:9000  http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin

Console: http://192.168.2.110:60277 http://127.0.0.1:60277
RootUser: minioadmin
RootPass: minioadmin

Command-line: https://docs.min.io/docs/minio-client-quickstart-guide
   $ mc.exe alias set myminio http://192.168.2.110:9000 minioadmin minioadmin

Documentation: https://docs.min.io
WARNING: Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and     'MINIO_ROOT_PASSWORD' environment variables

Open the MinIO console in your browser

Open http://localhost:60277 in your browser.

login

In the Username field, enter the RootUser displayed when the server started, which is minioadmin.

In the Password field, enter the RootPass displayed when the server started, which is minioadmin.

Once logged in, the dashboard will be displayed.

dashboard

Select Logs from the Tools menu to view the logs.

logs

Install the MinIO client mc.exe

Enter https://dl.min.io/client/mc/release/windows-amd64/mc.exe into your browser's address bar and press Enter to download mc.exe. Note that this address is the one listed in the Windows instructions on the official MinIO site: https://docs.min.io/docs/minio-client-quickstart-guide.html. For security, please ensure that the URL domain is .min.io when downloading.

Enter the following in PowerShell:

& ${env:USERPROFILE}\Downloads\mc

If the help is displayed as follows, the download was successful.

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc
mc.exe: Configuration written to `C:\Users\____\mc\config.json`. Please update your access credentials.
mc.exe: Successfully created `C:\Users\____\mc\share`.
mc.exe: Initialized share uploads `C:\Users\____\mc\share\uploads.json` file.
mc.exe: Initialized share downloads `C:\Users\____\mc\share\downloads.json` file.
NAME:
  mc - MinIO Client for cloud storage and filesystems.

USAGE:
  mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]

COMMANDS:
  alias      set, remove and list aliases in configuration file
  ls         list buckets and objects
  mb         make a bucket
  rb         remove a bucket
  cp         copy objects
  mirror     synchronize object(s) to a remote site
  cat        display object contents
  head       display first 'n' lines of an object
  pipe       stream STDIN to an object
  share      generate URL for temporary access to an object
  find       search for objects
  sql        run sql queries on objects
  stat       show object metadata
  mv         move objects
  tree       list buckets and objects in a tree format
  du         summarize disk usage recursively
  retention  set retention for object(s)
  legalhold  manage legal hold for object(s)
  diff       list differences in object name, size, and date between two buckets
  rm         remove object(s)
  version    manage bucket versioning
  ilm        manage bucket lifecycle
  encrypt    manage bucket encryption config
  event      manage object notifications
  watch      listen for object notification events
  undo       undo PUT/DELETE operations
  anonymous  manage anonymous access to buckets and objects
  tag        manage tags for bucket and object(s)
  replicate  configure server side bucket replication
  admin      manage MinIO servers
  update     update mc to latest release

GLOBAL FLAGS:
  --autocompletion              install auto-completion for your shell
  --config-dir value, -C value  path to configuration folder (default: "C:\\Users\\____\\mc")
  --quiet, -q                   disable progress bar display
  --no-color                    disable color theme
  --json                        enable JSON lines formatted output
  --debug                       enable debug output
  --insecure                    disable SSL certificate verification
  --help, -h                    show help
  --version, -v                 print the version

TIP:
  Use 'mc --autocompletion' to enable shell autocompletion

VERSION:
  RELEASE.2022-01-07T06-01-38Z

Create a new alias

An alias is a MinIO variable associated with information for logging into a specific MinIO server. It corresponds to the name of the MinIO service. You specify the alias when targeting a MinIO service with mc commands.

Enter the following in PowerShell. Here, we are setting an alias with the name minioalias.

& ${env:USERPROFILE}\Downloads\mc alias set  minioalias  http://localhost:9000  minioadmin  minioadmin

The meanings of the parameters are as follows:

mc alias set  __MinIO_Alias__  __MinIO_EndPoint__  __MinIO_AccessKey__  __MinIO_SecretKey__

Display connection information

Verify the location and status of the connection target.

Enter the following in PowerShell. The minioalias part is the alias you want to display information for.

& ${env:USERPROFILE}\Downloads\mc  admin info minioalias

For example, it will be displayed as follows:

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  admin info minioalias
●  localhost:9000
   Uptime: 38 minutes
   Version: 2022-01-08T03:11:54Z
   Network: 1/1 OK

Create and list buckets

To create a new bucket, enter the following in PowerShell.

& ${env:USERPROFILE}\Downloads\mc  mb minioalias/bucket1

To list buckets, enter the following in PowerShell.

& ${env:USERPROFILE}\Downloads\mc  ls minioalias

For example, it will be displayed as follows:

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  mb minioalias/bucket1
Bucket created successfully `minioalias/bucket1`.
PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  ls minioalias
[2022-01-09 22:43:56 JST]     0B bucket1/

Upload a file

Enter the following in PowerShell.

echo a > _a.txt  #// Prepare a file to upload
& ${env:USERPROFILE}\Downloads\mc  cp _a.txt  minioalias/bucket1
rm _a.txt  #// Delete the local file after uploading
& ${env:USERPROFILE}\Downloads\mc  ls minioalias/bucket1

For example, it will be displayed as follows:

PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  mb minioalias/bucket1
Bucket created successfully `minioalias/bucket1`.
PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  ls minioalias
[2022-01-09 22:43:56 JST]     0B bucket1/
PS C:\Users\____> echo a > _a.txt  #// Prepare a file to upload
PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  cp _a.txt  minioalias/bucket1
_a.txt:               8 B / 8 B [==========================================================================] 843 B/s 0s
PS C:\Users\____> rm _a.txt  #// Delete the local file after uploading
PS C:\Users\____> & ${env:USERPROFILE}\Downloads\mc  ls minioalias/bucket1
[2022-01-09 22:46:52 JST]     8B _a.txt

In the MinIO console, it will look like this:

buckets

By clicking the Browse button (top right), you can display a list of objects (files) inside the bucket.

objects

Command Documentation

The official command documentation is located below. You can find a list under "7. Commands" at the following link.

https://docs.min.io/docs/minio-client-complete-guide.html

Exit and Uninstall

Stop the MinIO service

Press Ctrl + C in the shell where minio.exe is running.

Uninstall MinIO and mc

Enter the following in PowerShell.

rm  ${env:USERPROFILE}\Downloads\minio.exe
rm  ${env:USERPROFILE}\Downloads\mc.exe

Delete folders used by minio.exe:

Enter the following in PowerShell.

rm -r -fo ${env:USERPROFILE}\mc
rm -r -fo ${env:USERPROFILE}\AppData\Roaming\MinIO

Discussion