本文旨在测试minio集群部署的情况下,上传和下载文件的速度。
1.环境部署
机器 | IP配置 | 配置 |
---|
minio服务器 | 192.168.35.111 | linux系统,内存4G,cpu核数2个,硬盘1000G | minio服务器 | 192.168.35.112 | linux系统,内存4G,cpu核数2个,硬盘1000G | minio服务器 | 192.168.35.113 | linux系统,内存4G,cpu核数2个,硬盘1000G | minio服务器 | 192.168.35.114 | linux系统,内存4G,cpu核数2个,硬盘1000G | 客户端 | 192.168.32.184 | windows系统, |
2.下载minio
wget https://dl.min.io/server/minio/release/darwin-amd64/minio
chmod +x minio
3.启动minio
./minio server -address ":9051" --console-address ":9050" --config-dir ./config http://192.168.35.111/
home/lyz/data http://192.168.35.112/home/lyz/data http://192.168.35.113/home/lyz/data http://192.168.35.114/home/lyz/data
4.上传测试脚本
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func main() {
ctx := context.Background()
endpoint := "192.168.35.111:9051"
accessKeyID := "minioadmin"
secretAccessKey := "minioadmin"
useSSL := false
// Initialize minio client object.
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
Secure: useSSL,
})
if err != nil {
log.Fatalln(err)
}
// Make a new bucket called mymusic.
bucketName := "mymusic"
location := "us-east-1"
err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
if err != nil {
// Check to see if we already own this bucket (which happens if you run this twice)
exists, errBucketExists := minioClient.BucketExists(ctx, bucketName)
if errBucketExists == nil && exists {
log.Printf("We already own %s\n", bucketName)
} else {
log.Fatalln(err)
}
} else {
log.Printf("Successfully created %s\n", bucketName)
}
// Upload the zip file
objectName := "/extern.rar"
filePath := "E:/Model/extern.rar"
contentType := "application/rar"
t1 := time.Now()
info, err := minioClient.FPutObject(ctx, bucketName, objectName, filePath, minio.PutObjectOptions{ContentType: contentType})
if err != nil {
log.Fatalln(err)
}
t2 := time.Now()
fmt.Println("diff : " + t2.Sub(t1).String())
log.Printf("Successfully uploaded %s of size %d\n", objectName, info.Size)
}
5.上传测试结果
文件名 | 文件大小 | 平均上传耗时 | 平均上传速度 |
---|
WindTerm.1.0.zip | 14.4M | ?621ms | 23.1884M/s | BimAngle_Engine_ RVT_v2022.01.13.zip ? | 163M | 6.5056045s | 25.124M/s | data1-e.rar | 931M | 20.8479114s | 44.657M/s | extern.rar | 2.03G | 1m14.6236129s | 27.856M/s | autodesk revit 2021.zip ? ? | 10.7G | ??5m40.7467879s | 32.155M/s |
6.下载测试脚本
package main
import (
"context"
"fmt"
"io"
"log"
"os"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func main() {
ctx := context.Background()
endpoint := "192.168.35.111:9051"
accessKeyID := "minioadmin"
secretAccessKey := "minioadmin"
useSSL := false
// Initialize minio client object.
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
Secure: useSSL,
})
if err != nil {
log.Fatalln(err)
}
bucketName := "mymusic"
// download the zip file
objectName := "extern.rar"
t1 := time.Now()
object, err := minioClient.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{})
if err != nil {
fmt.Println(err)
return
}
localFile, err := os.Create("D:/testminio/" + objectName)
if err != nil {
fmt.Println(err)
return
}
if _, err = io.Copy(localFile, object); err != nil {
fmt.Println(err)
return
}
t2 := time.Now()
fmt.Println("diff : " + t2.Sub(t1).String())
log.Printf("Successfully download %s of size %d\n", objectName, 0)
}
7.下载测试结果
文件名 | 文件大小 | 平均下载耗时 | 平均下载速度 |
---|
WindTerm.1.0.zip | 14.4M | 212.7193ms | 67.695M/s | BimAngle_Engine_RVT_v2022.01.13.zip | 163M | 1.8019099s | 90.455M/s | data1-e.rar | 931M | 9.3173644s | 99.921M/s | extern.rar | 2.03G | 21.9392096s | 94.750M/s | autodesk revit 2021.zip | 10.7G | 2m5.2534976s | 87.477M/s |
|