How to Install MinIO in Distributed Mode on AWS EC2

How to Install MinIO in Distributed Mode on AWS EC2

AWS has a majority of the more than one million public cloud deployments of MinIO. This is one of the reasons that we built a managed application in AWS Marketplace, which can be deployed with only a handful of clicks.

Running MinIO as a managed app not only provides streamlined deployment, it also  offloads operations through automations and transparent integrations with additional AWS components. It’s a quick, easy way to get started developing applications backed by MinIO.    

As developers, we also know that developers like the flexibility to do things your own way. In true MinIO spirit, we want you to be able to customize to your heart’s content, so we’re making sure that you have everything you need to make that happen.

If you’d like to learn how to quickly and easily deploy MinIO on AWS to your specifications, read on.

This is a guide on how to deploy MinIO on AWS EC2. In this guide we set up a 16 TiB Instance using EBS volumes.

  1. Create 4 AWS Instances at https://aws.amazon.com/console/
  2. Start by logging into your account: “Sign In to the Console”
  3. Provide your Account ID, IAM user name, and password
  4. Click “Sign in”
  5. Once you are logged in go to the “EC2” link
  6. And Launch instances by clicking “Launch instances”

7.  Choose the Amazon Machine Image also known as AMI. In this case we are going to be using Amazon Linux AMI from the top with x86 architecture.

8.  Then, select the Instance Type you want to test or use. Keep in mind that  they can get very  expensive as you increase HW capacity. You can use the AWS Calculator to estimate the price you will pay based on the time it will be used. For this example, we are going to use the c6i.metal Instance Type.

9.  Then click in “Next: Configure Instance Details” so that you can select the number of machines you want to use for MinIO. Then select 4 of them.


10.  Once you’ve selected 4, click on “Next: Add Storage” and add 4 extra volumes to run MinIO in distributed mode. There are a few things to keep in mind. First of all, notice that because we are using EBS type storage, then it really does not matter which device letter you configure as long as it is mapped consecutively later on. The size is up to you and depends on your needs. Look for the best price-performance ratio and set your configuration. Please remember to delete or remove the disks once an instance is terminated so as not to incur extra cost.

Once this is done, and you are satisfied with it, you can add tags. This depends on your organization and how you plan to use AWS in general.  At the very least, it is useful to have some tags to make it easier for  you  to find and terminate instances:

function get_running_instances_by_tag() {
# To get all running instance by tag
aws ec2 describe-instances \
--filters Name=tag-key,Values=$1 Name=instance-state-name,Values=running \
--query 'Reservations[*].Instances[*].InstanceId' \
--output text
}

function terminate_instances() {
# To terminate all instances by id
echo "terminating instance id: ${instance_id}"
aws ec2 terminate-instances --instance-ids $@
}

11.  Next, let’s configure the Security group. This is important for you to connect via SSH and allow access to MinIO for management  via port 9000 on TCP.

12.  Now you can review and launch the instances, and as a final step, add the key pair so that you can ssh to your host easily using a .pem file.

13.  Wait for the instances to be in the running state so that you can connect and configure each host to install MinIO.

14.  While you are waiting, you can use AWS CLI for to automate checking state:

printHeader 2 "Check the status of the instances to be running state"
counter=$NUMBER_OF_MACHINES
while [ $counter -gt 0 ]
do
counter=$NUMBER_OF_MACHINES
for instance_id in "${INSTANCES[@]}"
do
state=$(aws ec2 describe-instance-status \
--instance-ids $instance_id \
| jq ".InstanceStatuses[0].InstanceState.Name")
echo "instance: ${instance_id}, state: ${state}"
if [ "$state" = '"running"' ]; then
counter=$(( $counter - 1 ))
fi
done
sleep 5
done

15.  Once your instances are running, you can now proceed to connect via SSH to each host. The first thing we are going to do is change the /etc/hosts file to allow  secure communication between the machines:

ssh -i "celis.pem" ec2-user@ec2-3-239-64-1.compute-1.amazonaws.com
ssh -i "celis.pem" ec2-user@ec2-3-235-86-144.compute-1.amazonaws.com
ssh -i "celis.pem" ec2-user@ec2-3-236-38-32.compute-1.amazonaws.com
ssh -i "celis.pem" ec2-user@ec2-35-170-62-128.compute-1.amazonaws.com

16.  And add this portion to the /etc/hosts files of each instance:

172.31.77.115 host1
172.31.79.85  host2
172.31.74.75  host3
172.31.65.97  host4

Please note that we are using the private IP address of our  instances. You will need to use the IP address of your instances instead.

17.  Next, let’s create the directories where we will map our devices. Again, you must do this for each AWS instance:

mkdir /mnt/data1
mkdir /mnt/data2
mkdir /mnt/data3
mkdir /mnt/data4

mount /dev/sdb1 /mnt/data1
mount /dev/sdc1 /mnt/data2
mount /dev/sdd1 /mnt/data3
mount /dev/sde1 /mnt/data4

18.  We’re in the home stretch now. Download, install and run minio on each node:

wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=password
./minio server http://host{1...4}/mnt/data{1...4}

19.  Install MinIO Client (mc) to manage the cluster. Download the application, set it as executable and configure credentials. For a quick set up and verification, we’re running mc on the same instance as MinIO server. You may follow our example or install mc on another instance, or wherever you wish and then remotely access your MinIO instances.

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=password

20.  Set an alias to make it easier for you to log in and manage MinIO via mc.

[root@ip-172-31-77-115 ec2-user]# ./mc alias set myminio http://localhost:9000 minioadmin minioadmin
mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.Added `myminio` successfully.

21.  Finally, let’s measure the speed of MinIO with our new feature, SpeedTest. This will run a short, automated series of tests to quickly verify that your deployment is performing as it should.

[root@ip-172-31-77-115 ec2-user]# ./mc admin speedtest myminio

  THROUGHPUT IOPS     
PUT 2.4 GiB/s 38 objs/s
GET 4.6 GiB/s 73 objs/s

Speedtest: MinIO 2022-02-01T18:00:14Z, 4 servers, 16 drives, 64 MiB objects, 72 threads
[root@ip-172-31-77-115 ec2-user]


Deploy MinIO on AWS EC2 Today

Thanks for reading this tutorial. You now have MinIO installed and have verified performance. Now you can use MinIO Console, mc or the API to create buckets and further configure your deployment. If you have any questions, ping us on hello@min.io or join the Slack community.