How Do You Troubleshoot HBase Commands That Hang?

Problem scenarios
One of the following apply to you.

Problem #1
You run an HBase command but it hangs indefinitely, and there is no error. What could be the problem?

Problem #2
You run an HBase command but you see this:
"ERROR: KeeperErrorCode = ConnectionLoss for /hbase/master"

Solution
Has Zookeeper been started?

You may need to go to the Zookeeper server and run these commands:
cd /bin/zookeeper-"$version"/bin
sudo bash zkServer.sh start-foreground

How Do You Get the Kibana Web UI to Work?

Problem scenario
You want to try out he Kibana web UI. You are using Linux. How do you get Kibana to work?

Solution
Prerequisites

Install the ElasticStack. If you need assistance, see "How Do You Install the Elastic Stack on Any Type of Linux?"

Procedures

1. Install nginx. If you need assistance, see these postings:
How Do You Install Nginx on a Debian/Ubuntu Server?
How Do You Install Nginx on a CentOS/RHEL/Fedora Server?

2. Find kibana.yml and modify it (e.g., sudo vi /opt/kibana/config/kibana.yml). Uncomment out these two lines (which may not be near each other) if they are commented out:

server.port: 5601
server.host: "localhost"

3. Modify the default.conf file (e.g., /etc/nginx/conf.d/default.conf on a Red Hat derivative of Linux or /etc/nginx/sites-available/default on a Debian distribution of Linux). Replace the "location / { }" lines with these lines:
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

4. Run these commands:

sudo systemctl stop kibana
sudo systemctl enable kibana
sudo systemctl start kibana
sudo systemctl stop nginx
sudo systemctl start nginx

5. Open a web browser. Go to the external IP address of the server. (If you need help determining this, from the back-end run curl icanhazip.com if your Nginx server has internet access.)

How Do You Connect to an Aurora MySQL Database from a Linux Server with a MySQL Command?

Problem scenario
You are using an Aurora or RDS MySQL database. You have a Linux server that you want to run MySQL commands from (rather than install a SQL front-end). What should you do?

Solution

1. Install a MySQL client. If you need assistance with this, see this posting.

2. Make sure the Security Group governing the Aurora or RDS region allows for incoming connections from one of the following:
a) if you are using an EC-2 server in the same region, the internal IP address of the server ip addr show | grep inet
b) the external IP address of the server (e.g., visible in the result of a curl icanhazip.com command)

3. Test it by using this (with no special designation of a database beyond the endpoint and no port number):

mysql -hnameofauroraendpoing-us-west-2b.abcd1234.us-west-2.rds.amazonaws.com -ujdoe -pgoodpassword

# (Replace "nameofauroraendpoing-us-west-2b.abcd1234.us-west-2.rds.amazonaws.com" with the endpoint.
#  You can find it in the AWS web console or via an AWS CLI command.
#  If you have the AWS CLI configured run this commmand: aws rds describe-db-instances | grep Address
#  If you need assistance installing and configuring the AWS CLI, see the postings linked at the bottom.* 
#  Replace "jdoe" with the Aurora database master username.
#  Replace "goodpassword" with the Aurora database master password.

*One posting is How Do You Install and Configure the AWS CLI on a Linux Server (without the pip Command)?"
Another article is How Do You Install the AWS CLI on an Ubuntu Server?

How Do You Change The “From” Address in an Email Sent via the Mail Command on Linux?

Problem scenario
You want Linux to send out an email with a alias email address in the "From" field. You are using the mail command on a Linux server. You want to customize the "from" address in the emails that you send. What do you do to choose your own "from" email address (e.g., jdoe@myowndomain.com) in the email that is sent out?

Solution

Prerequisites
You need to have mailx installed. If you are using a Red Had derivative, use this command: sudo yum -y install mailx

Procedures
Use this:

echo "payLoad of Message" | mail -s "placeSubjectHere" -r email@from.com destiny@destination.com

-replace "payload of Message" with the message you want to send
-replace "placeSubjectHere" with the subject of your email
-replace "email@from.com" with the email address that you want the email to appear to be from
-replace "destiny@destination.com" with the destination email address

How Do You Write a Python Program to Show the Status of the Servers in AWS?

Problem scenario
You want to list the statuses of each EC-2 instance in AWS using Python. How do you do this for a given region in AWS (e.g., us-west-1)?

Solution
Prerequisites
This assumes you have installed Boto3. If you do not know how, see this posting "How do you install Boto 3 on a RHEL server in AWS?"

Procedures
Use this program:

# Usage instructions 
# 1. replace "aaa111" with the aws_access_key_id of your account
# 2. replace "bbb222" with the aws_secret_access_key of your account
# If you are not sure how to find these credentials do the following:
#  To find the AWS Access Key ID and AWS Secret Access Key, in the AWS console, click on your name in the upper right hand corner. 
# Then click on "My Security Credentials."  Click "Create New Access Key"  Click "Show Access Key." 
#  3.  Replace us-west-1 with the region that you want to list Ec-2 instances for.
#  To run it, call it test3.py and run it with a command like this: "python test3.py"

import boto3

ec2 = boto3.resource('ec2', aws_access_key_id='aaa111', aws_secret_access_key='bbb222', region_name='us-west-1')

for status in ec2.meta.client.describe_instance_status()['InstanceStatuses']:
    print(status)

As a reference, you may go here to learn more about Boto's features.

How Do You Troubleshoot This Problem “[ERROR KubeletVersion]: couldn’t get kubelet version: executable file not found in $PATH”?

Problem scenario
You run this command: sudo kubeadm init

You get this problem: "[ERROR KubeletVersion]: couldn't get kubelet version: executable file not found in $PATH"

What should you do?

Solution
Install kubelet. See this posting you need assistance. (If it is a Red Hat distribution of Linux, you can try How Do You Install kubectl, kubeadm, and kubelet on a CentOS/RHEL/Fedora Server?.)

If it was already installed, use this command to find it: sudo find / -name kubelet

Then either move the file to /usr/bin/ or run a command like this:
sudo ln -s /path/to/kublet /usr/bin/ # replace "path/to" with the path to the file found above.

Now try your kubeadm command again.

How Do You Use a YAML File or a YAML Manifest in Kubernetes?

Problem scenario
Kubernetes can use YAML files for configuration. The book Kubernetes in Action by Luksa refers to these files as manifests (pages 148), YAML manifests (page 155) or "pod manifests" (page 451). The Kubernetes website refers to this YAML file as "the PodSpec" here. Pod templates are defined inside these .yaml files (as a subset of the file itself). How do you use these YAML files?

Solution
1. To create one, know that there are maps and lists. Lists have merely arguments. Maps are key-value pairs. Quotes around the keys and values are optional. There should be no "tab" keys when formatting them. To learn more about the formatting, you can see this external posting.

2. You can make changes to services that already exist with these .yaml files. You would run a command like this: kubectl apply -f filename.yaml

The resource specified in the .yaml file named "filename.yaml" will be updated accordingly.

How Do You Troubleshoot an Error like This in Groovy “groovy.lang.MissingMethodException”?

Problem scenario
You run a Groovy program like this: groovy foobar.groovy

You see this message:

Caught: groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (foobar$_run_closure5$_closure6) values: [foobar$_run_closure5$_closure6@6150c3ec]
Possible solutions: wait(), any(), wait(long), and(java.lang.Boolean), each(groovy.lang.Closure), any(groovy.lang.Closure)
groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (foobar$_run_closure5$_closure6) values: [foobar$_run_closure5$_closure6@6150c3ec]
Possible solutions: wait(), any(), wait(long), and(java.lang.Boolean), each(groovy.lang.Closure), any(groovy.lang.Closure)
at foobar$_run_closure5.doCall(foobar.groovy:56)

What should you do?

Solution
Are you returning a variable with a closure? Look at the relevant return statement itself. Returns should be like this:

return foobar

Return statements should not be like this:
return ${foobar}

When You Have Two Branches in a Git Repo, How Can You Reconcile the Differences When You Merge Them?

Problem scenario
When you have created a branch of a Git repo, and there have been changes made to the master branch and this second branch you created, what are your options?

Possible Solution #1. You can merge the two branches (e.g., with a pull request). One branch will prevail if there are any conflicts. You can select which branch to prevail with GitLab, Atlassian Bitbucket, or regular Git.

Possible Solution #2. You can use git rebase. This will apply your second branch to the current state of the upstream master branch. git rebase makes the master branch as the main base. If no changes happened to the master branch since the second branch was created, using git rebase in this scenario would have the same effect as merging the second branch with the master branch with the option to have the conflicts be resolved with the second branch's changes prevailing. In all instances, the branch you are working in will have its changes preserved after a git rebase.