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.
 
 
 
 
 
 
minio/docs/setup-replication-between-t...

3.8 KiB

How to use mc mirror to setup replication between two sites running Minio. Gitter

minio_MIRROR

In this document we will illustrate how to set up replication between two Minio servers, minio1 and minio2 running on 192.168.1.11 and 192.168.1.12 respectively. We will mirror the data directory on minio1 to the bucket on minio2.

1. Prerequisites

  • Download Minio server from here
  • Download & Install mc from here
  • Familiarity with mc mirror

2. Install and Configure Minio Server

Setup minio1

$ ./minio server minio1-data/

Endpoint:  http://127.0.0.1:9000  http://192.168.1.11:9000
AccessKey: MURIVYBYNPTYE7O8I779 
SecretKey: lVbZmz4CvGkBl7JKw5icuL7RCcSvpBJTkAJTFQwz
Region:    us-east-1

mc alias

Alias is a short name to your cloud storage service for Minio client. End-point, access and secret keys are supplied by your cloud storage provider. API signature is an optional argument. By default, it is set to S3v4.

$ ./mc config host add minio1 http://192.168.1.11:9000 MURIVYBYNPTYE7O8I779 lVbZmz4CvGkBl7JKw5icuL7RCcSvpBJTkAJTFQwz

Create buckets and add objects

We have created few buckets using mc mb and added objects to it using mc cp Minio client commands.

$ ./mc mb minio1/mybucket
$ ./mc cp myfile.txt minio1/bucket1
$ ./mc ls minio1
[2016-07-31 10:26:55 PDT]     0B bucket1/
[2016-07-31 09:36:17 PDT]     0B bucket2/
[2016-07-31 09:38:08 PDT]     0B bucket3/

Setup minio2

$ ./minio server minio2-data/

Endpoint:  http://127.0.0.1:9000  http://192.168.1.12:9000
AccessKey: YRDRWWQLEWS9OBJ31GZ2
SecretKey: y2sSWzx5ytwvkELcxOuSaQ8n3doNqoIilRpb5Kjj
Region:    us-east-1
$ ./mc config host add minio2 http://192.168.1.12:9000 YRDRWWQLEWS9OBJ31GZ2 y2sSWzx5ytwvkELcxOuSaQ8n3doNqoIilRpb5Kjj

Create bucket

We are creating destination bucket mbucket on minio2 and adding minio2 alias. The bucket mbucket will be used to mirror data directory of minio1.

$ ./mc mb minio1/mbucket
$ ./mc config host add minio2 http://192.168.1.12:9000 YRDRWWQLEWS9OBJ31GZ2 y2sSWzx5ytwvkELcxOuSaQ8n3doNqoIilRpb5Kjj

4. Setup crontab

Cron is a Unix/Linux system utility by which you can schedule a task process for particular duration, we have tested this setup on Ubuntu Linux.

Script

Add crontab configuration on minio1 providing path of data directory, minio1-data.

--force option with mc mirror overwrites the destination contents, this would keep your contents in sync.


#!/bin/bash
datadir="/home/minio/minio1-data/"
minio2="minio2/mbucket"
MC_PATH="/home/minio/mc"
$MC_PATH --quiet  mirror --force $minio1 $minio2

Set executable permissions on the script before adding a cron entry.


$ chmod 755 /home/minio/minio.sh

Set a new cron entry to run minio.sh script once every 30mins.


$ crontab -e
*/30 * * * * /home/minio/minio.sh 

Note: We are going to introduce continuous replication feature in mc mirror which will enable the sites to be in sync without having the need to setup cron job.

Explore Further