目录
- bucket的命名规则
- 一、创建权限
- 1、参数含义
- 2、示例,实现读写test, 读test2目录但无下载权限
- 3、自己新建的权限
- 二、创建用户并关联权限
- 三、用新用户登录
- 四、mc命令
- 1、mc安装
- 用docker容器运行
- 直接安装在操作系统
- 2、mc配置
- `mc配置文件`
- `查看mc配置mc alias list`
- `查看mc配置mc config host ls`
- `设置新的minio服务器地址`
- 3、mc命令用法
- 创建bucket
bucket的命名规则
●存储桶名称的长度必须介于3 (最小)到63 (最大)个字符之间。
●存储桶名称只能由小写字母、数字、点(.) 和连字符(-) 组成。
●存储桶名称不得包含两个相邻的句点,或与连字符相邻的句点。
●存储桶名称的格式不得为IP地址(例如192.168.5.4)。
●存储桶名称不得以前缀 xn 开头–.
●存储桶名称不得以后缀 -s3alias 结尾。此后缀保留用于接入点别名。
●存储桶名称在分区中必须是唯一的。
一、创建权限
1、参数含义
{
"Version": "2012-10-17", #这个日期就这样吧,虽然比较老
"Statement": [
{
"Effect": "Allow",
"Action": [ // 权限列表
"s3:ListAllMyBuckets", // 查看所有的桶权限
"s3:ListBucket", // 查看桶内对象权限
"s3:GetBucketLocation", // 定位bucket权限
"s3:GetObject", // 下载权限
"s3:PutObject", // 上传权限
"s3:DeleteObject" // 删除权限
],
"Resource": [
"arn:aws:s3:::onebucket/*" // arn:aws:s3不用动,后面用*表示所有桶,用onebucket/*表示只针对这个桶
]
}
]}
2、示例,实现读写test, 读test2目录但无下载权限
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::test/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::test2/*"
]
}
]
}
3、自己新建的权限
二、创建用户并关联权限
三、用新用户登录
四、mc命令
1、mc安装
用docker容器运行
docker run -it --entrypoint=/bin/sh minio/mc
直接安装在操作系统
[root@dev32 ~]# wget https://dl.minio.org.cn/client/mc/release/linux-amd64/mc --no-check-certificate
[root@dev32 ~]# chmod +x mc
[root@dev32 ~]# mv mc /usr/bin/
2、mc配置
mc配置文件
[root@test2 ~]# cat /root/.mc/config.json
{
"version": "10",
"aliases": {
"gcs": {
"url": "https://storage.googleapis.com",
"accessKey": "YOUR-ACCESS-KEY-HERE",
"secretKey": "YOUR-SECRET-KEY-HERE",
"api": "S3v2",
"path": "dns"
},
"local": {
"url": "http://192.168.180.47:7000",
"accessKey": "minio",
"secretKey": "minio123",
"api": "S3v4",
"path": "auto"
},
"minio1": {
"url": "http://192.168.180.45:39000",
"accessKey": "admin",
"secretKey": "Qwe@1245",
"api": "s3v4",
"path": "auto"
},
"minio2": {
"url": "http://192.168.180.37:39080",
"accessKey": "admin",
"secretKey": "Qwe@1245",
"api": "s3v4",
"path": "auto"
},
"play": {
"url": "https://play.min.io",
"accessKey": "Q3AM3UQ867SPQQA43P2F",
"secretKey": "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
"api": "S3v4",
"path": "auto"
},
"s3": {
"url": "https://s3.amazonaws.com",
"accessKey": "YOUR-ACCESS-KEY-HERE",
"secretKey": "YOUR-SECRET-KEY-HERE",
"api": "S3v4",
"path": "dns"
}
}
}
查看mc配置mc alias list
[root@test2 ~]# mc alias ls
gcs
URL : https://storage.googleapis.com
AccessKey : YOUR-ACCESS-KEY-HERE
SecretKey : YOUR-SECRET-KEY-HERE
API : S3v2
Path : dns
local
URL : http://192.168.180.47:7000
AccessKey : minio
SecretKey : minio123
API : S3v4
Path : auto
minio1
URL : http://192.168.180.45:39000
AccessKey : admin
SecretKey : Qwe@1245
API : s3v4
Path : auto
minio2
URL : http://192.168.180.37:39080
AccessKey : admin
SecretKey : Qwe@1245
API : s3v4
Path : auto
play
URL : https://play.min.io
AccessKey : Q3AM3UQ867SPQQA43P2F
SecretKey : zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
API : S3v4
Path : auto
s3
URL : https://s3.amazonaws.com
AccessKey : YOUR-ACCESS-KEY-HERE
SecretKey : YOUR-SECRET-KEY-HERE
API : S3v4
Path : dns
查看mc配置mc config host ls
[root@test2 ~]# mc config host ls
gcs
URL : https://storage.googleapis.com
AccessKey : YOUR-ACCESS-KEY-HERE
SecretKey : YOUR-SECRET-KEY-HERE
API : S3v2
Path : dns
local
URL : http://192.168.180.47:7000
AccessKey : minio
SecretKey : minio123
API : S3v4
Path : auto
minio1
URL : http://192.168.180.45:39000
AccessKey : admin
SecretKey : Qwe@1245
API : s3v4
Path : auto
minio2
URL : http://192.168.180.37:39080
AccessKey : admin
SecretKey : Qwe@1245
API : s3v4
Path : auto
play
URL : https://play.min.io
AccessKey : Q3AM3UQ867SPQQA43P2F
SecretKey : zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
API : S3v4
Path : auto
s3
URL : https://s3.amazonaws.com
AccessKey : YOUR-ACCESS-KEY-HERE
SecretKey : YOUR-SECRET-KEY-HERE
API : S3v4
Path : dns
[root@test2 ~]#
设置新的minio服务器地址
#添加新的minio服务地址
[root@dev32 ~]# mc alias set 名称 服务地址 用户名 密码
[root@dev32 ~]# mc alias set minio1 http://192.168.180.45:39000 admin Qwe@1245
[root@dev32 ~]# mc alias set minio2 http://192.168.180.37:39000 admin Qwe@1245
3、mc命令用法
创建bucket
[root@test2 ~]# mc mb minio2/bucketbymc
Bucket created successfully `minio2/bucketbymc`.
[root@test2 ~]#
确认下是否创建成功
[root@test2 ~]# mc ls minio2
[2024-08-22 15:32:20 CST] 0B bucket1/
[2024-08-22 15:32:56 CST] 0B bucket2/
[2024-08-27 17:10:30 CST] 0B bucketbymc/
[root@test2 ~]#