Skip to content

Blog

Spark Cluster Configuration

Following the Hadoop configurations.

In $SPARK_HOME/conf:

  • Configure spark-env.sh

cp spark-env.sh.template spark-env.sh and add following:

Text Only
PYSPARK_DRIVER_PYTHON=python3
export HADOOP_CONF_DIR=/usr/local/hadoop/etc/hadoop
export SPARK_MASTER_HOST=$Master IP
export SPARK_WORKER_PORT=20001

Invoke Script Functions and Methods via JavaScript Engine

List supported script engines

Java
ScriptEngineManager manager = new ScriptEngineManager();
for(ScriptEngineFactory factory : manager.getEngineFactories()){
    System.out.printf("Name: %s%n" +
                    "\tVersion: %s%n" +
                    "\tLanguage name: %s%n" +
                    "\tLanguage version: %s%n" +
                    "\tExtensions: %s%n" +
                    "\tMime types: %s%n" +
                    "\tNames: %s%n",
            factory.getEngineName(),
            factory.getEngineVersion(),
            factory.getLanguageName(),
            factory.getLanguageVersion(),
            factory.getExtensions(),
            factory.getMimeTypes(),
            factory.getNames());
}

Linux Sed Command

Basic Usage

  • replace a string in a file

    sed -i "s/<string to be replaced>/<string will be replaced to>/g" $file

    You also can escape special character with a backslash