Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect with JMX remotely to Spark worker on Dataproc

I can connect to the driver just fine by adding the following:

spark.driver.extraJavaOptions=-Dcom.sun.management.jmxremote \
                              -Dcom.sun.management.jmxremote.port=9178 \
                              -Dcom.sun.management.jmxremote.authenticate=false \
                              -Dcom.sun.management.jmxremote.ssl=false

But doing ...

spark.executor.extraJavaOptions=-Dcom.sun.management.jmxremote \
                                -Dcom.sun.management.jmxremote.port=9178 \
                                -Dcom.sun.management.jmxremote.authenticate=false \
                                -Dcom.sun.management.jmxremote.ssl=false

... only yield a bunch of errors on the driver ...

Container id: container_1501548048292_0024_01_000003
Exit code: 1
Stack trace: ExitCodeException exitCode=1: 
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:972)
    at org.apache.hadoop.util.Shell.run(Shell.java:869)
    at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:1170)
    at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:236)
    at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:305)
    at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:84)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)


Container exited with a non-zero exit code 1

... and finally crashes the job.

There are no errors on the workers, it simply exits with:

[org.apache.spark.util.ShutdownHookManager] - Shutdown hook called

Spark v2.2.0, and the cluster is a simple 1m-2w-configuration, and my jobs run without issues without the executor parameters.

like image 646
habitats Avatar asked Aug 01 '17 10:08

habitats


People also ask

How do I enable JMX agent?

A common way to enable local JMX access on these JVMs is to include the -Dcom. sun. management. jmxremote option on the command line when you start the JVM.

How do I open a JMX port?

To open the JMX port on the remote JVM, you must enter the port number to use for the JMX RMI connection. Be sure to specify an unused port number. From a command line, go to the bin directory in the <JRE_HOME> directory that contains the Java Runtime Environment (JRE) implementation, for example jre/bin.

What is the use of JMX port?

The JMX technology can be used for out-of-the-box management of the Java VM. The Java Virtual Machine (Java VM) is highly instrumented using the JMX technology. You can start a JMX agent to access the built-in Java VM instrumentation, and thereby monitor and manage a Java VM remotely.

How do I submit a spark job?

You can submit a Spark batch application by using cluster mode (default) or client mode either inside the cluster or from an external client: Cluster mode (default): Submitting Spark batch application and having the driver run on a host in your driver resource group. The spark-submit syntax is --deploy-mode cluster.


2 Answers

As Rick Mortiz pointed out, the issue was conflicting ports for the executor jmx.

Setting:

-Dcom.sun.management.jmxremote.port=0

yields a random port, and removed the errors from Spark. To figure out which port it ends up using do:

netstat -alp | grep LISTEN.*<executor-pid>/java

which lists the currently open ports for that process.

like image 109
habitats Avatar answered Oct 20 '22 08:10

habitats


Passing following configuration with spark-submit worked for me --conf "spark.executor.extraJavaOptions=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9178 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

like image 1
Akshay thakur Avatar answered Oct 20 '22 08:10

Akshay thakur