How Do You Set up a Send-Only (Postfix) Email Server on a Linux RHEL AWS Instance?

Problem scenario
You have a monitoring tool on a RedHat Enterprise Linux server that needs to send out emails upon certain events happening. You want to install and configure an email server. You need to send outbound emails, but you do not need to receive inbound emails. How do you configure RHEL to be able to send out regular emails over the internet?

Prerequisite
This assumes that Postfix has been installed. For Debian/Ubuntu Linux, postfix is often installed by default. If it is not, run this command:
sudo apt -y install postfix # accept the various options by mostly accepting the defaults and using your best judgement

Solution
1. Ensure that the AWS Security Group allows for outbound connectivity over port 25.
2. Log into the RHEL server.
3. Run this command: hostname -f
4. Find the internal IP address. It is usually in the FQDN of an AWS server. You could run this command (and ignore the /20 at the end of its output):

ip addr show | grep eth0 | grep inet | awk '{print $2}'

You'll need this later.

5. Edit the /etc/postfix/main.cf file (e.g., with sudo vi /etc/postfix/main.cf). It should have lines like these at the very end (but replace contint.com with FQDN of the server and replace 10.10.10.10 with the internal IP address as found in steps 3 and 4 above).

inet_interfaces = localhost, 10.10.10.10
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, $mydomain
myhostname = contint.com

6. Now that the last lines of the main.cf file have been updated and the file is saved, restart the postfix server. Run this command:

sudo service postfix restart

7. If you have a DNS server so the FQDN resolves, skip this step. Otherwise update the /etc/hosts file to have an entry like this (where FQDN is the one found in step 3 and where 10.10.10.10 is the internal IP address as found in step 4):

10.10.10.10 FQDN

8. Optional step. Test it. Type in the following but replace contint.com below with your mail server's FQDN and press enter after each line:

sudo yum -y install telnet
telnet contint.com 25
helo contint.com
mail from: webmaster@contint.com
rcpt to: goodperson@gyahoomail.com
DATA
This is just a test.
.
quit

Another Possible Solution
Another way to do this is with Python; to learn how to use Python and not install anything else, see this external posting.

What Are The Kubernetes Concepts “pod label,” “label selector,” and “pod selector”?

Question
What is the difference between these three two-word terms "pod label," "label selector," and "pod selector"?

Answer
This answer provides details on what these are and provides some information on how they are different.

pod label: It is an inherent attribute of the pod. It can be changed via a command like this: kubectl label pod new-podlabel version=5.5 These statements were based on Assistanz.com. These may match with what is usually referred to as a "label selector" in a ReplicationController.

label selector: These are often categories, non-unique and common across multiple pods, that are arbitrarily designed by a human engineer and are not indicative of an underlying pod's attributes. They are one of three parts of a ReplicationController.

One way to think of it is that it is the pod label (an attribute of a pod) from the reference point of a server running the "kubectl" command. The "kubectl" command can filter pods based on their selectable "label selector" values that match the respective filter value. Also note that the ReplicaController's scope is composed of pods that are designated by their label selectors (page 92 of Kubernetes in Action by Luksa). An optimal use of this is to constrain certain pods to run on certain nodes. Kubernetes provides the benefit of hardware redundancy (colocation in two or more hosts). While jobs can run on servers without having GPU acceleration or solid state drives, servers with these features are optimal for certain task-scheduling. High-quality servers can be leveraged frequently whereas commodity servers can be dormant as backups based on label selectors and well-designed kubectl command invocation (page 73 of Kubernetes in Action by Luksa). To learn more, see this posting.

In most, and perhaps all, contexts, we do not think there is a difference between pod label and label selector.

If you run the kubectl describe svc kubia command, you will see an attribute for "Labels" and a separate attribute for "Selector".

pod selector: This is a reference to something that picks (or selects) a pod. It can be defined in a pod template or in what is less recommended -- a ReplicationController .yaml (page 93 of Kubernetes in Action by Luksa). If you run the "kubectl describe svc kubia" command, you will see an attribute for "Labels" and a separate attribute for "Selector". Pod selectors are needed for Kubernetes to automatically create a service's "Endpoints resource" (page 132 of Kubernetes in Action by Luksa).

A "Service" exposes a pod to a socket (inside front cover of Kubernetes in Action). To change a Service's pod selector, run this command: "kubectl set selector" (page 253 of Kubernetes in Action by Luksa).

Here is an example of pod selectors to give some context. The official Kubernetes website has this excerpt of key value pairs:

"matchExpressions:
- {key: tier, operator: In, values: [cache]}
- {key: environment, operator: NotIn, values: [dev]}"

The external link clarifies that "matchExpressions is a list of pod selector requirements. "

How Do You Get the mysql Command to Work from an Ubuntu Linux Command Line?

Problem scenario
The mysql command does not work from Ubuntu. You try to run a "mysql" command but you get "command not found." What do you do to install a mysql CLI utility?

Solution
Run one of the following:

sudo apt -y install mysql-client-core-5.7
sudo apt -y install mariadb-client-core-10.1

These commands may help you too:

apt-cache search mysql-client
apt-cache search mariadb-client
sudo apt -y install mycli
sudo mysql -u root

What Do You Do when Cassandra Stalls on “Initializing IndexInfo”?

Problem scenario
When you start Cassandra you see a message such as this:

INFO [main] 2018-02-03 08:45:55,257 ColumnFamilyStore.java:389 - Initializing system.IndexInfo

What should you do?

Possible Solution #1
Try rebooting the server. This could help the problem.

Possible Solution #2
This next one is merely a workaround. It is not a best practice.

Edit the ColumnFamilyStore.java file. To find it use this:
sudo find / -name ColumnFamilyStore.java

Comment out line 389. It should look like this after you comment it out:
//logger.info("Initializing {}.{}", keyspace.getName(), name);

Start Cassandra again. But know that you modified the source code without a though quality assurance process. This could have serious ramifications in the future.

Possible Solution #3
Wait 60 minutes. If you are patient enough, it is possible that the problem will go away on its own.

Possible Solution #4
Verify you have sufficient hardware for your version of Cassandra. Reinstall Cassandra; if you need assistance, click on the link for your distribution of Linux:

How Do You Use Terraform to Create a Server in GCP?

Problem scenario
You want to use infrastructure as a code with Terraform and GCP. How do you use a .tf file to create a virtual machine in Google Cloud Platform?

Solution
Prerequisite

This assumes you have installed Terraform. If you need assistance with this, see this posting.

Procedures

1. Obtain the account.json file for your GCP account. Log into GCP, and then go here: https://console.cloud.google.com/apis/credentials/serviceaccountkey
For the "Service Account" drop down menu, choose "Computer Engine default service account." Then for "Key Type" click on the option for "JSON". Click "Create".

2. On the Linux server with Terraform, save the file as account.json in the file you will create a .tf file.

3. Mentally identify the project ID of an existing project. If you want to find the ID of your project, from the GCP web UI, go to "My First Project" or something similar at the top middle part of the screen. Click on it. The pop up should show the project IDs according to their names.

4. Create in this directory a file called test.tf with these lines (but replace projectID-asfoundinstep3above with your project ID):

provider "google" {
  credentials = "${file("account.json")}"
  project     = "projectID-asfoundinstep3above"
  region      = "us-east1"
  zone        = "us-east1-b"
}

resource "google_compute_instance" "coolname" {
  name          = "verycoolserver"
  machine_type  = "n1-standard-1"
  zone          =  "us-east1-b"
  tags          = ["ssh","http"]
  boot_disk {
    initialize_params {
      image     =  "centos-7-v20180129"
    }
  }

network_interface {
    subnetwork = "default"
    access_config {
    }
  }
}

5. Run these commands:

terraform init
terraform apply

6. Respond with "yes" to the prompt. Your server should be created.

How Do You Troubleshoot Error Messages in a Bash Script?

Problem scenario
You run a shell or bash script but you receive an error message such as one of the following:

$'\r': command not found
line:55 syntax error: unexpected end of file

Solution
Did you download the file from the internet directly to the Unix system? The root cause could be that there are invisible characters in the file.

If you can copy the content of the text into the Linux machine and have it run as a script, the invisible characters are to blame. The integration between Windows and Linux can have hitches.

To eliminate these extra characters which interfere with the Bash script's execution, run the following (but substitute "script.sh" with the name of your script):

perl -p -i -e "s/\r//g" script.sh

How Do You Delete VM Instances from GCP That Pertain to GKE?

Problem Scenario
You have some GKE standard clusters that you want deleted. You try to delete them, but they do not go away. What should you do?

Solution
Root cause: Kubernetes clusters are self-healing. They are acting as they were designed. Once the instance group is deleted, you will be able to delete the instances via the web UI or via Google's Cloud Shell.

Procedures
See this link How Do You Delete VM Instances from GCP That Pertain to GKE?

Why Would a MongoDB Container Work on an Ubuntu Host but Not a SUSE Host?

Problem scenario
You have two Linux servers in AWS, and each one has the same flavor (i.e., same amount of RAM and same number of processors). One is Ubuntu and another is SUSE. These commands will create working containers in Ubuntu:

docker run --name name1-mongo -d mongo
docker run --name name2-mongo -d mongo:2

This command will not create a working container in SUSE:

docker run --name name2-mongo -d mongo:2

The container that is created will never start. Its status is "Exited." What is wrong?

Solution
SUSE and Ubuntu may have the same amount of processing power and RAM available. However if you have only one processor, the containers may not perform correctly. Try resizing the SUSE VM so you have more than one processor. If your server is in AWS, see this link for directions on how to resize it. If your server is in GCP, see this posting on how to resize it.