当在AI训练或部署工程中有些数据需要放到服务器进行存档,并且在测试的时候使用;
MinIO官方网站入口
# deb 安装
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20221008201100.0.0_amd64.deb -O minio.deb
sudo dpkg -i minio.deb
# binary 安装- 这个主要下载minio 可执行工具,然后手动终端执行; 注意执行起来后会是卡顿状态,所以最好用tmux或者screen使其一直保持住(类似后台一直执行状态)
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
# setup minio server
export MINIO_ACCESS_KEY=admin //创建账号
export MINIO_SECRET_KEY=12345678 //创建密码,至少8个
### 后端执行,默认访问端口:9000, 默认控制端口:9001, /my/data: 是drive,也是你用于存储数据的root文件夹。
nohup ./minio server --address :9000 --console-address :9001 /my/data > /home/minio/data/minio.log &
# get client file
curl https://dl.min.io/client/mc/release/linux-amd64/mc \
--create-dirs \
-o $HOME/minio-binaries/mc
chmod +x $HOME/minio-binaries/mc
export PATH=$PATH:$HOME/minio-binaries/
mc --help
# usage
# 查看命令行使用章节, 主要通过mc cmd 来操作文件的增删改查等操作。
注意在使用mc 操作之前,最好用alias进行命名远程服务器;如:
mc alias set cloudstorage http://yourdeployIP:9000 admin 12345678; 也就是用cloudstorage 代替后面的一串字符;后续通过mc对cloudstorage操作就可以了。
直接执行./mc可以看help信息,获得参数
# 用cloudstorage 代替http://localhost:9000 admin 12345678
./mc alias set mydata http://10.112.0.83:9000 admin 12345678
# download data
### download file into localhost
./mc cp mydata/data/mytest.bin ./
### directory
./mc cp -r mydata/data
# upload data
./mc cp ./data/file mydata/data/ # file
./mc cp -r ./data mydata/data/ # directory
# list directory
./mc ls mydata
# tree directory
./mc ls mydata
# delete data (注意不要误删)
./mc rb -r mydata/data/
./mc rb mydata/data/file
# mkdir
./mc mb mydata/new_folder
# mirror 好用的功能。
# 如果data中已经有objects,这个功能只会覆盖(下载)哪些更新了的文件; 所以避免每次都要重新cp 大量数据。
./mc mirror --overwrite myminio/data ./data
NAME:
mc - MinIO Client for object storage and filesystems.
USAGE:
mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
COMMANDS:
alias manage server credentials in configuration file
ls list buckets and objects
mb make a bucket
rb remove a bucket
cp copy objects
mv move objects
rm remove object(s)
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
find search for objects
sql run sql queries on objects
stat show object metadata
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)
support support related commands
license license related commands
share generate URL for temporary access to an object
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)
diff list differences in object name, size, and date between two buckets
replicate configure server side bucket replication
admin manage MinIO servers
update update mc to latest release
ready checks if the cluster is ready or not
ping perform liveness check
od measure single stream upload and download
policy-based-access-control官方链接
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [ "s3:" , ... ],
"Resource" : "arn:aws:s3:::*",
"Condition" : { ... }
},
{
"Effect" : "Deny",
"Action" : [ "s3:" , ... ],
"Resource" : "arn:aws:s3:::*",
"Condition" : { ... }
}
]
}
"Action": [
# "s3:*", # 可以所有操作
"s3:CreateBucket", # 允许在这个bucket中创建bucket
"s3:DeleteBucket",# 允许在这个bucket中删除bucket
... # 查阅官方链接
]
#!/bin/bash
function get_data() {
cd mydir
./mc alias set mydata http://localhost:9000 mydata 12345678
if [ ! -d tmp ]; then
mkdir tmp
echo "Get data Files-------------"
./mc cp -r mydata/data tmp
else
if [ ! -d tmp/data ]; then
INFO "Get data Files-------------"
./mc cp -r mydata/data tmp/data
else
INFO "Update data Files-------------"
./mc mirror --overwrite mydata/data tmp/data
fi
fi
cd -
}
对象存储服务(Object Storage Service,OSS)是一种海量、安全、低成本、高可靠的云存储服务,适合存放任意类型的文件。容量和处理能力弹性扩展,多种存储类型供选择,全面优化存储成本。 ↩︎