How Do You Install MongoDB on RHEL 8.x?

Problem scenario
You want to install MongoDB on a RHEL server. What do you do?

Solution
1. Create this file: /etc/yum.repos.d/mongodb-org-4.4.repo

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

  1. Run these commands:

sudo yum -y update
sudo yum -y install mongodb-org

  1. Test the installation by running this: mongod -version

If you are using Debian or Ubuntu,

 » Read more..

How Does a Python Docstring Work?

Problem scenario
You know that Python has a feature for documentation strings that can print out when your program runs. How does it work as comments and as something that is displayed at the time the code is executed?

Solution
To best illustrate how one works, create a file called test.py with this code and run it:

def cool_function(n):
”’This is an example of a docstring.  » Read more..

How Do You Troubleshoot the Error “An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The provided nodeRole is invalid.”?

Problem scenario
From the AWS CLI you try to create a node group. But you get this error: “An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The provided nodeRole is invalid.”

Solution
The above can happen when you use a role’s name but not the ARN string (such as arn:aws:iam::123456:role/foobar). Use the ARN string of the role instead of what you were using.

 » Read more..

How Do You Use Boto3 to Create EC-2 Instances?

Problem scenario
You want to create EC-2 instances using an SDK (a program that automatically generates AWS resources). How do you do this?

Solution
Prerequisites

You have Boto3 installed. If you need assistance, see this posting if you have CentOS/RHEL/Fedora or this posting for Debian/Ubuntu.

Procedures
Run this program to create a RHEL server (but you can replace the “ami-0a54aef4ef3b5f881” with the image ID of your choice):

# Replace AKIAabcdefghijk with your AWS access key ID
# Replace 1a2b3c4d5e6f7g8h9/i0j0k9l8m7n6o5p4q3r2s1tuvwxyz with your AWS Secret Access key
# Replace us-west-1 with the region of your choice
# Replace ami-0a54aef4ef3b5f881 with the image ID of your choice.  » Read more..