Install mongodb 4.4 to arm64 amazon Linux 2

Recently I've tried to install mongodb to the arm64 amazon linux.
Because AWS Graviton 2 instances are cheaper than the other architecture instances.

Here is how you install mongodb community to the arm64 amazon linux.

The problem

According to the official document, MongoDB Community Edition on Amazon Linux supports the arm64 architecture but there aren't any instruction how you install it 😭

I modified a bit of /etc/yum.repos.d/mongodb-org-4.4.repo from their document and see if it works, but it doesn't work...

[mongodb-org-4.4]
name=MongoDB Repository
- baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/
+ baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/arm64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

The solution

You first need to have installed mongodb-database-tools as the mongodb-org package depends on it.
Then you'll be able to install mongodb-org package.
Here is the way how you do that.

Add mongodb-database-tools yum repo

Create a /etc/yum.repos.d/mongodb-database-tools-4.4.repo file.

[mongodb-database-tools-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/arm64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

Add mongodb-org yum repo

Create a /etc/yum.repos.d/mongodb-org-4.4.repo file.

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/aarch64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

Install both packages

You just need to run yum install command:

sudo yum install -y mongodb-database-tools mongodb-org

Then you'll have installed mongodb on your server.

81