How Do You Cancel the Uninstallation of a Jenkins Plugin?

Problem scenario
You started the uninstallation of a plugin in Jenkins via the web UI.  The plugin now says "Uninstallation pending" in the web UI.  You changed your mind (or you accidentally initiated the process to remove the plugin by clicking the "Uninstall" button) about removing the plugin.  What do you do to keep the plugin continuously installed in Jenkins?

Solution
Background
When you initiate the uninstallation of a plugin, behind-the-scenes you delete a .hpi or .jpi file from the plugins directory of Jenkins.  The directory of other files associated with that plugin, which reside in the plugins directory on the server, will be deleted upon next restart of the Jenkins service.  Those files still exist, but the .hpi or .jpi file gets deleted immediately.

Prerequisites
This solution requires access to the back-end of the Jenkins server and a copy of .jpi (or .hpi) file for the plugin.  You could download one from here (and rename the .hpi file to .jpi, but we expect the files to start being called .jpi soon).  If you are not sure if you had an .hpi or .jpi file, look at what is in the .../jenkins/plugins/ directory.  If you have mostly other .jpi files, we recommend assuming you need a .jpi file.  In our experience a .hpi file can be renamed to be a .jpi file and work fine.

Procedures
1.  This step involves getting the .jpi (or .hpi) file of the plugin you want to keep installed.  Here are two commands to get a gradle.jpi file from a different source.

curl -L https://updates.jenkins.io/download/plugins/gradle/1.28/gradle.hpi > /tmp/gradle.jpi
sudo mv /tmp/gradle.jpi /var/lib/jenkins/plugins/gradle.jpi

Ideally the .jpi will be the same version as the old version.  If it is the exact same version, the uninstallation will not happen (in accord with your intentions).

Restore from backups or copy a .jpi file to /var/lib/jenkins/plugins/ (or whatever directory is your .../jenkins/plugins/ directory) from a back up or a different machine with the same archiecture and version of Jenkins.

2.  Move the respective plugin subdirectory to be assume a new name.  For example, if you are uninstalling the Gradle plugin, do something like this:

cd /var/lib/jenkins/plugins/
sudo mv gradle gradlenew

3.  Now move the directory back to its original name.  If you were doing this for Gradle, do something like this:

sudo mv gradlenew gradle

Next time Jenkins is restarted, the plugin will not be uninstalled.  The plugin will remain installed on Jenkins, and the removal process will be cancelled.  Until Jenkins is restarted remember that you must ignore the "Uninstallation pending" comment in the "Installed" plugins section of the Jenkins web UI.

How Do You Use Amazon Aurora to Try It Out?

Problem scenario
You know that Amazon Aurora is compatible with either PostgreSQL or MySQL.  While RDS supports these database types as well as Oracle and SQL Server, RDS does not offer all of the advantages that Aurora offers.

You have read about the benefits of Aurora a database PaaS or DBaaS.   You want to deploy Amazon Aurora because it has numerous features for high availability, performance, and scalability.  What do you do?

Solution
1.  Log into AWS.  

2.  Go here in the web browser: https://console.aws.amazon.com/rds

3.  Click the button to "Get Started".

4.  For the "Engine options", choose "Amazon Aurora".

5.  At the bottom, choose the "Edition" (e.g., MySQL or PostgreSQL).

6.  Click "Next".

7.  For "Specify DB details", choose and enter settings you think are appropriate.  It should be self-explanatory.  Remember the username and password entered here.

8.  Click "Next".

9.a.  For "Configure advanced settings" most of the options will be self-explanatory based on your preference.

9.b.  In the "Public accessibility" section, choose "Yes".

9.c.  For "Network & Security" there is a section for "Availability zone" options.  If you do not see the zone you want, go to the upper right hand corner of the AWS console.  Between your name and the "Support" option, do you see the region you expect?  You may need to change this region and start over creating your Aurora instance if you need a specific Availability Zone.

9.d.  Click "Launch DB Instance".

10.  Click "View DB Instances" in the lower right hand corner.

11.  Connect to your database via a SQL front end (e.g., such as HeidiSQL).  Go to "Endpoint" and find the FQDN.  Go to "DB Name" and find the name.  Use these in your SQL front end application.  Use the username and password entered in step #7 above.  Once connected, try it out.  You may want to run a command such as this: SELECT current_database();
Or you may want to run a command like this: create table contint(column1 int)

12.  If you want to delete your Aurora instance go to "Instance actions" in the upper right hand corner, and go to "Delete".  You are now done.

You may want to view this link to learn more about the costs and benefits of Aurora.

How Do You Get hdfs or Yarn to Start When You Get an Error Such As “Permission denied (publickey,gssapi-keyex,gssapi-with-mic)”?

Problem scenario
You try to use start-dfs.sh or start-yarn.sh.  You received this message:  Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

What do you do?

Solution
You need to be able to ssh into the node without any Hadoop components.  To help you troubleshoot, consider the following items on the server that is causing the problem (e.g., the DataNode server, but it could be the NameNode server itself):

1.  Does the authorized_keys file in /home/hduser/authorized_keys have permissions rw-------? If not you may need to use this command: sudo chmod 600 authorized_keys

2.  Does the authorized_keys file in /home/hduser/authorized_keys, on the problematic server, have the content of /home/hduser/id_rsa.pub, on the NameNode server?  That is the content of the /home/hduser/id_rsa.pub on the NameNode server needs to be appended to the /home/hduser/authorized_keys file (or exist somewhere among potentially other strings from .pub files) on the NameNode server.

3.  On the server that has the problem, is the /home/hduser owned by hduser and associated with the group Hadoop?

There would be a problem if you were in /home/ and ran "ls -lh" and saw this:

drwxr-xr-x 3 root     root  4.0K Jan  3 06:11 hduser

To remedy the problem, you would need to be a sudoer user.  Then you would run this:

sudo chown -R hduser:hadoop /home/hduser

4.  See this posting to set up SSH keys between two Linux servers.

How Do You Add a Linux User to the sudoers Users?

Problem scenario
You want a given Linux user to be added to the sudoers group.  You want the user to be able to use the "sudo " command before running other commands.  How do you give the sudo privilege to a given user?

Solution
If you are using Debian or Ubuntu Linux, do this (but replace "cooluser" with the username of your choice):
sudo adduser cooluser sudo

If you are using CentOS/RHEL/Fedora, do this (but replace "cooluser" with the username of your choice):

Modify the /etc/sudoers file.
Find this stanza:
root    ALL=(ALL)    ALL

Add a stanza above it like this:

cooluser ALL=(ALL)    ALL

How Do You Troubleshoot the Vagrant Error “default: Waiting for SSH to become available.”?

Problem scenario
You run "vagrant up" and you see things stop at this stage:  "==> default: Waiting for SSH to become available..."

What should you do?

Possible Solutions
1.  Run the command again with " --debug" at the end.  This provides verbose output.  

2.  You may want to review your Vagrantfile settings.  This page helps with such a review (i.e., if you do not know what to look for).

3.  Verify that the Security Group your AWS instance is trying to connect to allows for inbound connections from the external IP address of your server.  Even if your server is an AWS EC2 instance, the Security Group must allow for inbound connections for "vagrant up" to work.  To modify the security group, find the EC-2 server's external IP address.  Run this command  curl ipinfo.io  It will show you the external IP address if it has access to the internet.

How Do You Run a Groovy Program on a Red Hat Derivative Linux Server?

Problem scenario
You want to use a Java Virtual Machine language on a CentOS/RHEL/Fedora server.  You want to test out the language too.  What should you do?

Prerequisites
Install Groovy; this command should work (assuming your server is configured to work with a yum repository with groovy):  sudo yum -y install groovy
# If your yum repositories do not have Groovy, see this posting.

Procedures
1.  Create a file called hello.groovy with the following five lines:

class Example {
   static void main(String[] args) {
      println('Hello World');
   }
}

2.  Run it like this:  groovy hello.groovy

How Do You Test a Remote Oracle Database Connection (with Credentials You Were Given) from a Linux Command Prompt?

Problem scenario
You have no desktop GUI and a limited ability to install new applications other than the Java compiler.  You are not be allowed to install a SQL command line client such as sqlconnect or a utility such as tnsping.  What should you do to test the credentials, server name and port number to ensure they work to allow access to an Oracle database?

Solution
The overview is to use a Java program with the code provided below.

Prerequisite
You need to be able to compile Java programs.  The "javac" command must be recognized.  To do this install a Java compiler.  If you do have this and do not know how, see this posting.

Procedures
1.  Find the jre/lib/ext directory path on your server.  (e.g., sudo find / -name ext -type d | grep lib). 

2.  Place an ojdbc14.jar file (e.g., downloaded from Oracle.com or some trustworthy website) in that directory above. Here is one place to get it.

3.  From any directory create a program such as this called OracleCon.java:

    import java.sql.*;  //first line of file
    class OracleCon{  
    public static void main(String args[]){  
    try{  
    //step1 load the driver class  
    Class.forName("oracle.jdbc.driver.OracleDriver");  

    //step2 create  the connection object  
    Connection con=DriverManager.getConnection(  
    "jdbc:oracle:thin:@contintserver:1521:xe","jdoe","strongPassword");  

    //step3 create the statement object  
    Statement stmt=con.createStatement();  

    //step4 execute query  
    ResultSet rs=stmt.executeQuery("select * from all_users");  
    while(rs.next())  
    System.out.println(rs.getString(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  

    //step5 close the connection object  
    con.close();  

    }catch(Exception e){ System.out.println(e);}  

    }  
    }  // last line of file

(This code was largely taken from https://www.javatpoint.com/example-to-connect-to-the-oracle-database.)

In the above code, you need to make some modifications:

  • Replace "jdoe" with the Oracle SQL user, and replace "strongPassword" with jdoe's password. 
  • Replace "contintserver" with the servername of the remote Oracle server.
  • Replace "xe" with the SID.  You may need to ask the DBA for this SID as it can be crucial. 
  • Under the comment "//step4 execute query" there is a SELECT statement in quotes. You can change this SQL command, but it often works as a test.

4.  To compile it, use javac OracleCon.java

5.  To run the compiled byte code, run java OracleCon without quotes.  The output of running this Java program should give you an indication of whether or not the credentials work to connect to the database.

As a closing tip, we have seen a source (an article, http://glennpaulley.ca/conestoga/2015/06/configuring-sonarqube-with-oracle-12c/, published in June of 2015) indicated that the two forward slashes "//" are a necessary constructor for a JDBC connection string.  We know in 2018 that this is not necessary in all instances.

How Do You Troubleshoot “java.lang.AbstractMethodError: Method oracle/jdbc/driver/OraclePrepreadStatementWrapper.setBinaryStream (IL java/io/InputStream;)V is abstract”?

Problem scenario
You get an error such as this on a Linux server:

"Caused by: java.lang.AbstractMethodError: Method oracle/jdbc/driver/OraclePrepreadStatementWrapper.setBinaryStream (IL java/io/InputStream;)V is abstract at oracle.jdbc.driver.OraclePreparedStatementWrapper.setBinaryStream (OraclePreparedStatementWrapper.java)"

What should you do?

Possible Solution #1
If you are doing Java coding, have you imported the packages needed for the line of Java code that is throwing this error?

Possible Solution #2
If you are using JBoss, an Atlassian tool, SonarQube, or some web application written in Java, try to reinstall Java on that web application server.  If you need help with this, see this posting after Java has been removed.

Possible Solution #3
Was the database upgraded recently?  If there is a database involved, you may need a newer .jar file for a driver to connect to the database.

How Do You Install kubectl on Any Type of Linux?

Problem scenario
You want a quick, generic way to install kubectl on any type of Linux.  What should you do?

Solution
Run these commands:

cd /tmp

curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl

sudo mv kubectl /usr/local/bin/

Test it by running this command: kubectl version

(If you would prefer to use apt commands, because you are using a Debian/Ubuntu distribution of Linux, to install kubectl, see this posting.)

How Do You Troubleshoot This Salt Minion Message “SaltReqTimeoutError”?

Problem scenario
You run "sudo salt-minion -l debug" on a Salt Minion.  You see this message:  "[INFO    ] SaltReqTimeoutError: after 60 seconds. (Try 4 of 7)"

What should you do?

Solution
Go to the Salt Master server.  Run this command:  sudo systemctl start salt-master