How Do You Get All of Your Live Nodes to Appear in The “hdfs dfsadmin -report” Results?

Problem scenario
You use the "hdfs dfsadmin -report" command on your Hadoop NameNode server.  You see that there is a small amount of "DFS Remaining."  You expect many more GB. You also see one datanode not listed under the "Live datanodes" section. All of your live datanodes are not appearing in hdfs,

Your /usr/local/hadoop/etc/hadoop/slaves file has the DNS name of a server you expect to be a datanode.  You see no reference to this data node "hdfs dfsadmin -report" output.

When you run start-dfs.sh from the NameNode server you see that the DataNode service starts up on a slave server in a multi-node Hadoop cluster.  Likewise when you run stop-dfs.sh you see the DataNode service disappear from the back-end of the slave server itself.  The NameNode (or Master Hadoop server) controls the datanode service perfectly on a specific slave server.

But when you run "sudo /usr/local/hadoop/bin/hdfs dfsadmin -report" (or hdfs dfsadmin -report) you see only one live datanode and it is NOT the one described above.  You have at least two data nodes.  What can be done to get this other node to appear in the report?  You want this additional datanode to be live.  You know the start-dfs.sh and stop-dfs.sh scripts control the server well.  But you do not know why the dfsadmin report will monitor this server.

What can you do to add another datanode and have it participate in the hdfs cluster or otherwise get the report to accurately show which data nodes you have running?

Solution
Prerequisite
This assumes you have a multi-node deployment of Hadoop.  If you do not know how to deploy this, see these directions.

Root cause
An intermediate firewall is blocking certain ports but not other ports between the datanode in question and the namenode.  If every port was blocked, the DataNode service would not start and stop from the MasterNode operations (e.g., running the start-dfs.sh and stop-dfs.sh scripts).  Some ports would have to be open.  The problem of not having the datanode listed as "live" when you run "hdfs dfsadmin -report" on the namenode with corresponding functionality is attributable to ports 54310 and 50010 being blocked.

Procedure of Solution
From the datanode server, ensure that outbound ports 54310 and 50010 are unblocked to the name node server (aka master server).

To the namenode server, ensure that inbound ports 54310 and 50010 are unblocked from the datanode server (aka master server).

You may need to run stop-dfs.sh and start-dfs.sh again once the ports are opened. Commands like these may help you "sudo bash /usr/local/hadoop/sbin/stop-dfs.sh && sudo bash /usr/local/hadoop/sbin/start-dfs.sh".

Miscellaneous
The nmap utility is useful for checking out this problem closely.

If you have the NameNode running in Azure, you would need to manually add an inbound security rule in the relevant Network Security Group.  In our experience opening the security rule for any Source Port and any Destination Port makes the configuration much more simple.

How Do You Know If Yarn or Hadoop’s NameNode Services Are Running?

Problem scenario
How do you know if YARN or Hadoop's NameNode services are running or not?

Solution
Use the "sudo jps" command.  Some Linux users may not have sufficient permissions to install it.  

If the command is not found, go to the option below for your distribution of Linux:

If you are running a RedHat derivative (e.g., Fedora, CentOS etc.), run this:  sudo yum -y install java-1.8.0-openjdk-devel
# you may prefer to use java-1.7.0-openjdk-devel

If you are running Ubuntu or a Debian distribution, run this:  sudo apt-get -y install apt-get install openjdk-8-jre
# you may prefer to use openjdk-7-jre

To interpret the output of a "sudo jps" command, here is an example of jps output where the NameNode is running but Yarn is not:

7521 SecondaryNameNode
7189 NameNode
7335 DataNode
7695 Jps

Here is an example of Yarn running but not the name node:

9027 GetConf
8004 NodeManager
7863 ResourceManager
9079 Jps

How Do You Troubleshoot the Maven Build Failure of No “POM in this directory”?

Problem scenario
You need to use this following command on a CentOS/RedHat/Fedora Linux server in a /home/hadoop/ directory:

mvn package -Pdist,native -DskipTests -Dtar

The Maven build is failing.  When you run the command with the "-e" flag for verbosity you see this:

[INFO] BUILD FAILURE
...
[WARNING] The requested profile "dist" could not be activated because it does not exist.
[WARNING] The requested profile "native" could not be activated because it does not exist.
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/hadoop).

Please verify you invoked Maven from the correct directory. -> [Help 1]
...
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/home/hadoop). Please verify you invoked Maven from the correct directory.
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:84)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

What do you do to create a pom.xml file in the correct directory so you can run the original mvn command?

Solution
Run these commands:
cd /home/hadoop/

# In the commands below, replace "contint" with the name of your company or some other term you desire.
mvn archetype:generate -DgroupId=com.contint.app -DartifactId=contint -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

cp ./contint/pom.xml pom.xml

mvn package -Pdist,native -DskipTests -Dtar

How Do You Troubleshoot an hdfs Command with the Error “java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)…ConnectionRefused”?

Problem scenario
When trying to run an hdfs command you see this message:

"WARN ipc.Client: Failed to connect to server: localhost/127.0.0.1:54310: try once and fail.
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
        at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:531)
        at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:495)
        at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:681)
        at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:777)
        at org.apache.hadoop.ipc.Client$Connection.access$3500(Client.java:409)
        at org.apache.hadoop.ipc.Client.getConnection(Client.java:1542)
        at org.apache.hadoop.ipc.Client.call(Client.java:1373)
        at org.apache.hadoop.ipc.Client.call(Client.java:1337)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:227)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:116)
        at com.sun.proxy.$Proxy10.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:787)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:398)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:163)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:155)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:95)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:335)
        at com.sun.proxy.$Proxy11.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1700)
        at org.apache.hadoop.hdfs.DistributedFileSystem$27.doCall(DistributedFileSystem.java:1436)
        at org.apache.hadoop.hdfs.DistributedFileSystem$27.doCall(DistributedFileSystem.java:1433)
        at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
        at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1433)
        at org.apache.hadoop.fs.Globber.getFileStatus(Globber.java:64)
        at org.apache.hadoop.fs.Globber.doGlob(Globber.java:269)
        at org.apache.hadoop.fs.Globber.glob(Globber.java:148)
        at org.apache.hadoop.fs.FileSystem.globStatus(FileSystem.java:1685)
        at org.apache.hadoop.fs.shell.PathData.expandAsGlob(PathData.java:326)
        at org.apache.hadoop.fs.shell.Command.expandArgument(Command.java:235)
        at org.apache.hadoop.fs.shell.Command.expandArguments(Command.java:218)
        at org.apache.hadoop.fs.shell.FsCommand.processRawArguments(FsCommand.java:103)
        at org.apache.hadoop.fs.shell.Command.run(Command.java:165)
        at org.apache.hadoop.fs.FsShell.run(FsShell.java:315)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:90)
        at org.apache.hadoop.fs.FsShell.main(FsShell.java:378)
ls: Call From contint/10.10.10.10 to localhost:54310 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused"

What do you do?

Solution

See if the regular NameNode (not the SecondaryNameNode) is running.  Run this (as the hduser or something similar):  jps

You should see "NameNode" in the results.  If NameNode is not running, then you need to start it.

To start NameNode run this command:  bash /usr/local/hadoop/sbin/start-dfs.sh

If start-dfs.sh completes without errors but the problem remains, see one of these links: one, two, or three.

If start-dfs.sh is having issues and running a single-node cluster, can you SSH into the local host with root?  Can you SSH to the localhost with root subsequently?  If you cannot login with SSH using the root user twice consecutively, see if getting that to work will allow start-dfs.sh to work.

If you can do both of these without any hdfs commands, then the links above should be what you try next:

ssh root@localhost
ssh root@localhost 

How Do You Pass Parameters Using Boto?

Problem scenario
You want to run a Boto program. But there is an error about necessary parameters not being assigned.

You see a message like this:

botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStack operation: Parameters: [KeyName, DBPassword, DBUser] must have values

Where can you see an example of parameters being passed?

Solution
Updated on 3/15/21.
Here is a working program:

import boto3
cloudf = boto3.client('cloudformation', region_name='us-west-1', aws_access_key_id='AKIAabcdefgh12345', aws_secret_access_key='SOMETHING1234here/moretext')
json_stack=open('lampstack.json', 'r').read()
cloudf.create_stack(StackName='continualstack', TemplateBody=json_stack, Parameters = [ { 'ParameterKey': 'KeyName', 'ParameterValue': 'foobar'}, {'ParameterKey': 'DBPassword', 'ParameterValue': 'verycont'}, {'ParameterKey': 'DBUser', 'ParameterValue': 'contuser'}, {'ParameterKey': 'DBRootPassword', 'ParameterValue': 'contpassword'}] )

How Do You Copy a File into HDFS without the Error “No such file or directory”?

Problem scenario
You want to add a file to Hadoop. You are trying to run a basic Hadoop command to copy a file into HDFS.  You get this error:  copyFromLocal: `hdfs://localhost:54310/user/...': No such file or directory

How do you copy a file from your OS into HDFS?

Solution
Do one of the following:
Option 1.  Run this command to create a new directory (substitute "jdoe" with the name of your user):

hdfs dfs -mkdir -p /user/jdoe/contint
# Now repeat your copy command

Option 2.  Use a directory you know exists for the destination file without renaming the file itself (substitute "/path/to/" with the directory path to the source file and substitute "foo.bar" with the file name you want copied):

hdfs dfs -copyFromLocal /path/to/foo.bar hdfs://localhost:54310/user/root/

It does not work like the cp command in Linux where the file name can be changed to in the destination path with the -copyFromLocal flag.  The destination file name should not appear in the destination path argument.

How Do You Install kubectl, kubeadm, and kubelet on a CentOS/RHEL/Fedora Server?

Problem scenario
You have a Red Hat derivative distribution of Linux.  You want to use some core Kubernetes utilities.  How do you install kubectl, kubeadm, and kubelet on Linux?

Solution
1.  Create a file /etc/yum.repos.d/kubernetes.repo2.  Have this be the content:

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

2.  Run this: sudo yum -y install kubelet kubeadm kubectl

How Do You Troubleshoot a Fatal HDFS Error?

Problem scenario
You run an hdfs command and you get this:

[Fatal Error] core-site.xml:2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
17/09/25 04:21:00 FATAL conf.Configuration: error parsing conf core-site.xml
org.xml.sax.SAXParseException; systemId: file:/home/hadoop/hadoop/etc/hadoop/core-site.xml; lineNumber: 2; columnNumber: 6; The processing instruction target matching "[xX][mM][lL]" is not allowed.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
        at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2531)
        at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2519)
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2590)
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2543)
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2426)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1151)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1123)
        at org.apache.hadoop.conf.Configuration.setBoolean(Configuration.java:1459)
        at org.apache.hadoop.util.GenericOptionsParser.processGeneralOptions(GenericOptionsParser.java:322)
        at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:488)
        at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:170)
        at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:153)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:90)
        at org.apache.hadoop.fs.FsShell.main(FsShell.java:378)

What is the problem?

Solution
Find your core-site.xml file.  Make sure there are no blank lines at the top. Delete any blank lines.  The first line should be "<?xml..." and not blank.

For example the top two lines may look like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

How Do You Troubleshoot Nginx Not Being Removed from Ubuntu Linux Like It Should?

Problem scenario
You want to remove Nginx from an Ubuntu server.  You run this: sudo apt-get remove nginx

But you receive this error:
"
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 nginx-dbg : Depends: nginx (= 1.12.1-1~xenial)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
"

What do you do to remove Nginx?

Solution
Remove nginx-dbg first.  Run this command:  sudo apt-get remove nginx-dbg
Then remove nginx with a command like this:  sudo apt-get remove nginx

How Do You Eliminate Highlighting of Text in MS Word 2016?

Problem scenario
Some text in MS Word 2016 is highlighted with a color as part of its formatting.  No matter what you do (including highlighting it and clicking "No color") the text remains highlighted.   What should you do?

Solution
Highlight the text (with either the mouse or by holding shift and pressing an arrow key) then press Ctrl and the Spacebar (hold control and tap the spacebar).  This should eliminate formatting.