How Do You Set the S3 Policy to Archive after 60 Days?

Problem scenario
You want items in an S3 bucket to be archived automatically after they are 60 days old. What do you do?

Solution
1. Log into the AWS console.
2. Click on your S3 bucket.
3. Click on the "Management" tab on the right.
4. Click on "Add lifecycle rule"
5. Give the rule a name. Click "Next."
6. Check the box for "Current version" or "Previous versions." Then below the "For current version of objects" click "+ Add transition"
7. Choose the transition policy you want (e.g., "Transition to Amazon Glacier after").
8. For the "Days after object creation" type 60. Click Next.
9. For configure expiration, just click "Next."
10. On the Review page, click "Save."

How Do You Delete an Aurora Database when You Get an Error about It Not Being Started?

Problem scenario
You are trying to delete an Aurora database but you get this error: "This database is not started." What do you do?

Possible Solution #1 (with the web console)
1. Log into the web console.
2. Go to "Amazon RDS".
3. Go to "Databases"
4. Click on the Aurora cluster of the database you want to delete or its parent.
5. Go to Actions -> Start
6. If it is grayed out, it may be stopping. It can take several minutes to fully stop.
7. Then go to Actions -> Delete. Respond to the next prompt.

Possible Solution #2 (with the AWS CLI)
From the AWS CLI, run these two commands (but replace "foobar" with the database name that you want to delete):

aws rds start-db-instance --db-instance-identifier foobar
# You may have to wait 10 minutes or more for the database to start
aws rds delete-db-instance --db-instance-identifier foobar

How Do You Find the Default Directory for Tomcat when It Acts as a Web Server?

Problem scenario
Your Tomcat server is has been configured to serve as a web server. You have access to the back-end Linux server. But you do not know what directory corresponds with the URL of the host. How do you find what the default directory is for files that are presented on the web?

Solution
From the back-end, run this: sudo find / -name index.html | grep tomcat

Look for a WEB-INF or webapps directory. See if there are subdirectories after one of these directories until the index.html file (e.g., /var/lib/tomcat9/webapps/foo/index.html ).

How Do You Troubleshoot an Error Such as “UnboundLocalError: local variable ‘foobar’ referenced before assignment”?

Problem scenario
You run a Python program. You receive this message: "UnboundLocalError: local variable 'foobar' referenced before assignment"

What should you do?

Solution
Initialize the variable (e.g., foobar = 0). If you do so inside a function wherein foobar is called, that may work. If you want it to be available globally throughout your program, you will initialize it outside of a function. To gain access to the variable inside a function, use this syntax: global foobar

You may also want to use the nonlocal keyword; to read about it, click here.

How Do You Troubleshoot Golang Using Hexademical Values?

Problem scenario
Your Golang program has variables with values that look like this:

{0xc4200457e8 [97 49]}

You think the that underlying variables should have regular alphabetic string values. What should you do?

Solution
Use the .string() function.

When you use strings.Builder for a variable, the value will be a hexadecimal value. To retrieve the string value that you intend, you must append ".string()" to the variable.

Here is a snippet of code (without the import section that you would need) appending integers to the letter "a":

var prevar strings.Builder

for i := 0; i < 10; i++ {
  j := strconv.Itoa(i)
  if i == 0 {prevar.WriteString("a")
  } else {
  prevar.WriteString(j)
  fmt.Println(prevar.String())
  }
}

What Are Some Free SQL Front-end Applications to Install on a Windows Desktop?

Problem scenario
You want a free trial or a completely open source (always free) graphical user interface application to install on your Windows desktop or laptop. What options do you have for a free front-end?

Answer
These GUIs are free or free to start out with an initial trial:

https://www.aquafold.com/aquadatastudio/trialregform
https://www.heidisql.com/
https://dbeaver.io/
https://www.devart.com/dbforge/postgresql/studio/
https://www.pgadmin.org/
https://omnidb.org/
Team SQL (formerly at https://teamsql.io/)
https://download.cnet.com/DbVisualizer/3000-10254_4-10202406.html
https://fishcodelib.com/database.htm

How Do You Know if Hadoop is Installed (and the version if it is installed) on Linux SUSE?

Problem scenario
You are administering Linux SUSE machines. You want to see if Hadoop is installed on them. The command hadoop version does not work.

Solution
Run this command:

sudo find / -name hadoop -type f

From the results above, you can probably find the file and path of the executable. It will likely not be in /var/ or /tmp/. Run this command (where /path/to/ is the directory of Hadoop as found above):

/path/to/hadoop version

Alternate solution
Run this command:
whereis hadoop
You will likely find a directory named "bin" in the directory that results from the command above. Inside this subdirectory named bin should be a "hadoop" executable if Hadoop has been installed. Run this command (where /path/to/ is the directory of Hadoop as found in /bin/ above):

/path/to/hadoop version

How Do You Troubleshoot the GitLab Installation Error “dpkg: error processing package gitlab-ee…post-installation script returned error exit status 1”?

Problem scenario
You are trying to install GitLab, but you get this error:

"dpkg: error processing package gitlab-ee (--configure):
subprocess installed post-installation script returned error exit status 1"

What do you do?

Possible solution #1
Is Jenkins running on the server? Is a service running on port 8080? Can you stop any process running on port 8080 and try again?

Possible solution #2
Reboot the server. Try again.

Possible solution #3
Do you have enough memory? Using the top or free -mh show you how much free memory you have. You may want to see this posting to create swap space if have ample hard disk space but cannot increase the amount of RAM . It can work on servers in the cloud (such as RackSpace, AWS, or Google Cloud Platform). If you are using AWS, you can easily upgrade the server's flavor. See this posting if you are using an EC-2 instance. If you resize the instance in GCP (click here if you need assistance with this), the external IP address will change. You may need to configure /etc/gitlab/gitlab.rb to have a new external_url.

How Do You Troubleshoot “Errno::ENOMEM: Cannot allocate memory -” or Some Other “out of memory” Error in Linux?

Problem scenario
You go to /var/log/ for the program or application that is not working properly. You look for the word "error." You see HeapDumpOnOutofMemoryError or "OnOutOfMemoryError=kill -9" messages.

Or you get this error on the terminal that says "Errno::ENOMEM: Cannot allocate memory." How might you troubleshoot out of memory errors on Linux?

Solution

Possible solution #1
Add more memory, but be aware that this costs money. For a physical server you may need to purchase RAM. Resize your VM if you are using a VM. For resizing GCP virtual machines, see this posting. For upgrading AWS instances (aka servers), see this posting.

Possible solution #2
Add more swap space (aka virtual memory). See this posting if you do not know how. This solution involves losing available hard drive space. This solution will not increase the performance as much as possible solution #1.

Possible solution #3
You can use the top or free -mh commands to monitor memory usage. You could reproduce the problem while monitoring either of the above commands. This can help prove that you need more memory for the operations. You can then make the case, confidently, to your systems administrator or boss that you need a server with greater memory.

Possible solution #4
Has code been modified recently? Maybe there is a memory leak. This problem could be caused by memory leaks in an application. You may need to ask the programmer if the code could have been written with a flaw or if a systems administrator patched an OS that is not compatible with the current application. Some environmental variables can introduce problems.

What Are The Different Statuses of Individual Docker Containers?

Question
In Docker what are possible status values of containers?

Answer
Possible statuses include the following:

created, restarting, running, removing, paused, up, exited, or dead

Sources: 1) https://docs.docker.com/engine/reference/commandline/ps/ (for every one except "up")
2) https://www.thegeekdiary.com/how-to-list-start-stop-delete-docker-containers/ (for "up")

The docker create command when used with a Docker image ID will produce a new container in the "Created" state.