We can preload the library in the MATLAB scripts through cluster properties without modifying the system environment variables. The two scripts require slightly different code, because they are built on different technologies. In both of these, $MATLAB_ROOT needs to be replaced with the full path to the MATLAB installation on the worker.
For "mapreduce", modify your code as below:
cluster = parallel.cluster.Hadoop(..)\n...\ncluster.HadoopProperties('mapred.child.env') = 'LD_PRELOAD=$MATLAB_ROOT/bin/glnxa64/glibc-2.17_shim.so'\n...\nmapreducer(cluster)
For the Spark-based script, modify the code as below:
cluster = parallel.cluster.Hadoop(..)\n...\ncluster.SparkProperties('spark.executorEnv.LD_PRELOAD') = '$MATLAB_ROOT/bin/glnxa64/glibc-2.17_shim.so'\n...\nmapreducer(cluster)
This error may continue to be present after running the "mapreduce" script. The issue is likely related to "mapred.child.env", which is the legacy name for this configuration and the part of the workaround intended to allow mapreduce to work. Changing this to use the following configuration properties resolves the issue:
preloadEnv = 'LD_PRELOAD=$MATLAB_ROOT/bin/glnxa64/glibc-2.17_shim.so';\ncluster.HadoopProperties('mapreduce.map.env') = preloadEnv;\ncluster.HadoopProperties('mapreduce.reduce.env') = preloadEnv; \ncluster.HadoopProperties('yarn.app.mapreduce.am.env') = preloadEnv;