...
To do so, the Java platform allows developer to attach a debugger to a running JVM.
...
Passing the remote debugging JVM options
The JVM you wish to attach the debugger to has to be started with a certain set of parameters for the remote debugging capability to be enabled.In particular, you should edit the startup script you use (either bin/yarn-session.sh for YARN or bin/flink-daemon.sh for the standalone scheduler) adding the following parameters to the java command:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
The command specifies to open the the 5005 port port (make sure your firewall poses no problem) and to suspend the process until a debugger is attached to the process. If you wish to allow remote debugging without having to attach a debugger before startup, simply set suspend=n.
Passing the JVM options via env.java.opts
In order to pass the remote debugging options to the JVM you can use Flink's env.java.opts configuration parameter. Simply set in the flink-conf.yaml the following line before starting your Flink cluster.
env.java.opts: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
Passing the JVM options as a dynamic property
When starting Flink in YARN mode via the bin/yarn-session.sh script you can also provide the JVM options via a dynamic property. Simply add the following option to your yarn-session.sh command.
bin/yarn-session.sh -Denv.java.opts="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
Editing the start-up scripts
Alternatively, you can edit the startup scripts bin/yarn-session.sh (for YARN) or bin/flink-daemon.sh (for standalone cluster) to include the JVM options.
Attach a remote debugger with IntelliJ IDEA
...
Attach a remote debugger with Eclipse
Similarly to IntelliJ, it is possible to debug a running Flink instance on a remote machine from Eclipse
...
.
These are the required steps:
- Go to the menu 'Run' -> 'Debug configurations...'
- Create a new 'Remote Java Application'
- In the 'Connect' tab choose:
- the project to debug
- Connection type 'Standard (Socket Attach)'
- Connection properties, host (i.e. target hostname or IP address) and port (same port specified before, i.e. 5005)
- (Optional) If you have installed Scala IDE you could see the error 'Multiple launchers available'. Just click on 'Select one' and choose the proper debugger (e.g. Eclipse JDT Launcher)