[health@kyc-dev bin]$ ./mc mc: Configuration written to `/home/health/.mc/config.json`. Please update your access credentials. mc: Successfully created `/home/health/.mc/share`. mc: Initialized share uploads `/home/health/.mc/share/uploads.json` file. mc: Initialized share downloads `/home/health/.mc/share/downloads.json` file. NAME: mc - MinIO Client for cloud storage and filesystems.
USAGE: mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
COMMANDS: aliasset, 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 objects 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 policy 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: "/home/health/.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
[health@kyc-dev bin]$ ./mc sql --help NAME: mc sql - run sql queries on objects
USAGE: mc sql [FLAGS] TARGET [TARGET...] FLAGS: --query value, -e value sql query expression (default: "select * from s3object") --recursive, -r sql query recursively --csv-input value csv input serialization option --json-input value json input serialization option --compression value input compression type --csv-output value csv output serialization option --csv-output-header value optional csv output header --json-output value json output serialization option --encrypt-key value encrypt/decrypt objects (using server-side encryption with customer provided keys) --config-dir value, -C value path to configuration folder (default: "/home/health/.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 ENVIRONMENT VARIABLES: MC_ENCRYPT_KEY: list of comma delimited prefix=secret values
SERIALIZATION OPTIONS: For query serialization options, refer to https://docs.min.io/docs/minio-client-complete-guide#sql
EXAMPLES: 1. Run a query on a set of objects recursively on AWS S3. $ mc sql --recursive --query "select * from S3Object" s3/personalbucket/my-large-csvs/
2. Run a query on an object on MinIO. $ mc sql --query "select count(s.power) from S3Object" myminio/iot-devices/power-ratio.csv
3. Run a query on an encrypted object with customer provided keys. $ mc sql --encrypt-key "myminio/iot-devices=32byteslongsecretkeymustbegiven1" \ --query "select count(s.power) from S3Object s" myminio/iot-devices/power-ratio-encrypted.csv
4. Run a query on an object on MinIO in gzip format using ; as field delimiter, newline as record delimiter and file header to be used $ mc sql --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \ --query "select count(s.power) from S3Object" myminio/iot-devices/power-ratio.csv.gz
5. Run a query on an object on MinIO in gzip format using ; as field delimiter, newline as record delimiter and file header to be used $ mc sql --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \ --json-output "rd=\n\n" --query "select * from S3Object" myminio/iot-devices/data.csv
6. Run same query as in 5., but specify csv output headers. If --csv-output-headers is specified as "", first row of csv is interpreted as header $ mc sql --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \ --csv-output "rd=\n" --csv-output-header "device_id,uptime,lat,lon" \ --query "select * from S3Object" myminio/iot-devices/data.csv [health@kyc-dev bin]$
[health@kyc-dev bin]$ mc admin NAME: mc admin - manage MinIO servers
USAGE: mc admin COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
COMMANDS: service restart and stop all MinIO servers update update all MinIO servers info display MinIO server information user manage users group manage groups policy manage policies defined in the MinIO server config manage MinIO server configuration heal [DEPRECATED] heal disks, buckets and objects on MinIO server profile generate profile data for debugging purposes top provide top like statistics for MinIO trace show http trace for MinIO server console show console logs for MinIO server prometheus manages prometheus config kms perform KMS management operations subnet Subnet related commands bucket manage buckets defined in the MinIO server FLAGS: --config-dir value, -C value path to configuration folder (default: "/home/health/.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 [health@kyc-dev bin]$
STS AssumeRole
1. 创建用户
1 2
[health@kyc-dev bin]$ mc admin user add local company-60001 company-60001-123456 Added user `company-60001` successfully.
[health@kyc-dev bin]$ mc admin policy add local company-60001 ./policy-company.json Added policy `company-60001` successfully. [health@kyc-dev bin]$ mc admin policy info local company-60001 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:DeleteObject", "s3:GetObject", "s3:PutObject" ], "Resource": [ "arn:aws:s3:::kyc/60001/*" ] } ] }
注:策略文件的 Version 固定设置为 2012-10-17。
为此账号授权 company-60001 的策略
1 2 3
[health@kyc-dev bin]$ mc admin policy setlocal company-60001 user=company-60001 Policy company-60001 is set on user `company-60001` [health@kyc-dev bin]$
通过 aws-cli 来获取 AssumeRole STS 授权
通过 aws configure 来添加配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[health@kyc-dev bin]$ aws configure --profile company-60001 AWS Access Key ID [None]: company-60001 AWS Secret Access Key [None]: company-60001-123456 Default region name [None]: us-east-1 Default output format [None]: json