You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
3.9 KiB
167 lines
3.9 KiB
4 years ago
|
= Swarm Minio HowTo!
|
||
|
Apostolos rootApostolos@swarmlab.io
|
||
|
:description: IoT Εισαγωγή στο Cloud
|
||
|
:keywords: Cloud, swarm
|
||
|
:data-uri:
|
||
|
:toc: right
|
||
|
:toc-title: Πίνακας περιεχομένων
|
||
|
:toclevels: 4
|
||
|
:source-highlighter: coderay
|
||
|
:icons: font
|
||
|
:sectnums:
|
||
|
|
||
|
|
||
|
|
||
|
{empty} +
|
||
|
|
||
|
== configure Minio
|
||
|
|
||
|
=== Connect to Server
|
||
|
|
||
|
.create policy
|
||
|
[source,yaml]
|
||
|
----
|
||
|
mc config host add --insecure [SESSION] https://ip:9443 key secret --api s3v4
|
||
|
e.g.
|
||
|
mc config host add --insecure mysession https://83.212.119.119:9443 mykey mysecret --api s3v4
|
||
|
----
|
||
|
|
||
|
=== Create policy
|
||
|
|
||
|
.create Default policy file: test.json
|
||
|
[source,yaml]
|
||
|
----
|
||
|
{
|
||
|
"Version": "2012-10-17",
|
||
|
"Statement": [
|
||
|
{
|
||
|
"Effect": "Allow",
|
||
|
"Principal": {
|
||
|
"AWS": [
|
||
|
""
|
||
|
]
|
||
|
},
|
||
|
"Action": [
|
||
|
"s3:GetBucketLocation", // <1>
|
||
|
"s3:HeadBucket", // <1>
|
||
|
"s3:ListBucket", // <1>
|
||
|
"s3:ListBucketMultipartUploads" // <1>
|
||
|
],
|
||
|
"Resource": [
|
||
|
"arn:aws:s3:::test" // <2>
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"Effect": "Allow",
|
||
|
"Principal": {
|
||
|
"AWS": "*"
|
||
|
},
|
||
|
"Action": [
|
||
|
"s3:DeleteObject", // <3>
|
||
|
"s3:GetObject", // <3>
|
||
|
"s3:ListMultipartUploadParts", // <3>
|
||
|
"s3:PutObject" // <3>
|
||
|
],
|
||
|
"Resource": [
|
||
|
"arn:aws:s3:::test/*" // <4>
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
----
|
||
|
<1> Bucket properties https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html[more info^]
|
||
|
<2> Bucket source
|
||
|
<3> Object properties https://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html#using-with-s3-actions-related-to-objects[more info^]
|
||
|
<3> Object source
|
||
|
|
||
|
|
||
|
=== Apply policy
|
||
|
|
||
|
.create policy
|
||
|
[source,yaml]
|
||
|
----
|
||
|
#!/bin/bash
|
||
|
|
||
|
mc mb --insecure mymsession/test // <1>
|
||
|
|
||
|
mc admin policy add --insecure mymisession test ./test.json // <2>
|
||
|
|
||
|
mc admin user add --insecure mymsession usertest bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd // <3>
|
||
|
|
||
|
mc admin policy set --insecure mymsession test user=usertest // <4>
|
||
|
----
|
||
|
<1> create bucket
|
||
|
<2> Apply policy
|
||
|
<3> create user
|
||
|
<4> Apply policy User2bucket
|
||
|
|
||
|
|
||
|
=== Sync local2Server
|
||
|
|
||
|
.sync local2server
|
||
|
[source,yaml]
|
||
|
----
|
||
|
export MINIO_MIRROR_PARAMETERS="--delete"
|
||
|
export MINIO_SERVER_URL="ip:9443" // <1>
|
||
|
export MINIO_PROT=https
|
||
|
export MINIO_SERVER_DOCUMENTROOT="/home/user/syncdir" // <2>
|
||
|
export MINIO_WEB_BUCKET=test1
|
||
|
export MINIO_WEB_PASS="bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd"
|
||
|
export AWS_CONFIG_FILE="$HOME/.aws/config"
|
||
|
export AWS_ACCESS_KEY_ID=$MINIO_WEB_BUCKET
|
||
|
export AWS_SECRET_ACCESS_KEY=$MINIO_WEB_PASS
|
||
|
|
||
|
aws --endpoint-url $MINIO_PROT://$MINIO_SERVER_URL s3 sync MINIO_SERVER_DOCUMENTROOT s3://$MINIO_WEB_BUCKET $MINIO_MIRROR_PARAMETERS
|
||
|
----
|
||
|
<1> Minio Server ip
|
||
|
<2> Directory sync
|
||
|
|
||
|
|
||
|
|
||
|
=== Sync Server2Local
|
||
|
|
||
|
.sync server2local
|
||
|
[source,yaml]
|
||
|
----
|
||
|
export MINIO_MIRROR_PARAMETERS="--delete"
|
||
|
export MINIO_SERVER_URL="ip:9443" // <1>
|
||
|
export MINIO_PROT=https
|
||
|
export MINIO_SERVER_DOCUMENTROOT="/var/www/html" // <2>
|
||
|
export MINIO_WEB_BUCKET=test
|
||
|
export MINIO_WEB_PASS="bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd"
|
||
|
export AWS_CONFIG_FILE="$HOME/.aws/config"
|
||
|
export AWS_ACCESS_KEY_ID=$MINIO_WEB_BUCKET
|
||
|
export AWS_SECRET_ACCESS_KEY=$MINIO_WEB_PASS
|
||
|
|
||
|
aws --endpoint-url $MINIO_PROT://$MINIO_SERVER_URL s3 sync s3://$MINIO_WEB_BUCKET $MINIO_SERVER_DOCUMENTROOT $MINIO_MIRROR_PARAMETERS
|
||
|
----
|
||
|
<1> Minio Server ip
|
||
|
<2> Directory sync
|
||
|
|
||
|
|
||
|
=== Docker-compose env
|
||
|
|
||
|
.sync docker-compose env
|
||
|
[source,yaml]
|
||
|
----
|
||
|
environment: //<1>
|
||
|
- MINIO_MIRROR_PARAMETERS= --delete
|
||
|
- MINIO_SERVER_URL=ip:9443
|
||
|
- MINIO_PROT=https
|
||
|
- MINIO_SERVER_DOCUMENTROOT=/var/www/html
|
||
|
- MINIO_WEB_BUCKET=test
|
||
|
- MINIO_WEB_PASS=bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd
|
||
|
- AWS_CONFIG_FILE=/home/user/.aws/config
|
||
|
----
|
||
|
<1> add env to docker-comose
|
||
|
|
||
|
|
||
|
=== Automating sync with cron
|
||
|
|
||
|
.crond file
|
||
|
[source,yaml]
|
||
|
----
|
||
|
*/15 * * * * root /PATH/local2server >> /var/log/usercron.log 2>&1 / <1>
|
||
|
----
|
||
|
<1> Every 15 minutes
|