快速搭建 docker minio 环境

先上minio 官网地址
https://docs.min.io/

docker 一键搭建
docker run -p 9000:9000 -p 50000:50000 --name minio1
-e “MINIO_ACCESS_KEY=admin” \
-e “MINIO_SECRET_KEY=12345678”
-v /mnt/data:/data \ 挂载数据地址
-v /mnt/config:/root/.minio \ 配置文件地址
minio/minio server /data --console-address “:50000” 指定minio服务

如果需要使用https协议
配置https
在${HOME}.minio/certs文件夹下
1、生成私钥
openssl genrsa -out private.key 2048
2、生成自签名证书
创建一个以openssl.conf以下内容命名的文件。设置IP.1和/或DNS.1指向正确的 IP/DNS 地址:
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no

[req_distinguished_name]
C = US
ST = VA
L = Somewhere
O = MyOrg
OU = MyOU
CN = MyServerName

[v3_req]
subjectAltName = @alt_names

[alt_names]
IP.1 = 127.0.0.1 这里需要匹配docker内ip
DNS.1 = localhost
然后指定文件运行
openssl req -new -x509 -nodes -days 730 -key private.key -out public.crt -config openssl.conf

重启minio服务即可支持https

如果想换回http,删掉或重命名private.key密钥文件即可

给出 nodejs 测试 用例 具体 内容 参考官网
var Minio = require(“minio”);
// Instantiate the minio client with the endpoint
// and access keys as shown below.
var minioClient = new Minio.Client({
endPoint: “192.168.1.84”, //这里不能带http或者https
port: 9000,
useSSL: true, //不需要https
accessKey: “admin”, //账号密码同web登陆时一致
secretKey: “12345678”,
});
// File that needs to be uploaded.
var file = “D:\test.zip”;
// Make a bucket called europetrip.
minioClient.makeBucket(“europetrip”, “us-east-1”, function (err) {
if (err) return console.log(err);
console.log(‘Bucket created successfully in “us-east-1”.’);
var metaData = {
“Content-Type”: “application/octet-stream”,
“X-Amz-Meta-Testing”: 1234,
example: 5678,
};
// Using fPutObject API upload your file to the bucket europetrip.
minioClient.fPutObject(
“europetrip”,
“test.zip”,
file,
metaData,
function (err, etag) {
if (err) return console.log(err);
console.log(“File uploaded successfully.”);
}
);
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值