Updated on 2022-12-08 GMT+08:00

An Error Occurs When Spark Connects to Redis

Issue

An error occurs when the Spark component of the MRS 3.x security cluster is used to access Redis.

Symptom

When Spark of the MRS 3.0 security cluster is used to access Redis, the following error message is displayed.

Cause Analysis

The jars directory of Spark contains a jredisclient-xxx.jar package provided by the MRS cluster. This package is loaded when a Spark task connects to Redis, thereby causing this error. You can manually remove this package to rectify the fault.

Procedure

  1. Delete JAR packages from the Spark client.

    cd $SPARK_HOME/jars

    mv jredisclient-*.jar /tmp

  2. Delete JAR packages from the Spark server.

    Log in to the nodes (generally two) where SparkResource2x is located.

    mkdir /tmp/SparkResource2x

    cd /opt/Bigdata/FusionInsight_Current/1_*_SparkResource2x/install/spark/jars/

    mv jredisclient-*.jar /tmp/SparkResource2x

  3. Delete the jredisclient file from the HDFS.

    1. Check configuration item spark.yarn.archive in the $SPARK_HOME/conf/spark-defaults.conf file to obtain the address of the spark-archive-2x.zip package.

      cat $SPARK_HOME/conf/spark-defaults.conf | grep "spark.yarn.archive"

    2. Download the spark-archive-2x.zip package. (This section uses MRS 3.0.5 as an example. Modify the command based on the actual cluster version.)

      cd /opt

      mkdir sparkTmp

      cd sparkTmp

      hdfs dfs -get hdfs://hacluster/user/spark2x/jars/8.0.2.1/spark-archive-2x.zip

    3. Decompress spark-archive-2x.zip and remove the package file.

      unzip spark-archive-2x.zip

      rm -f spark-archive-2x.zip

    4. Remove the jredisclient package.

      rm -f jredisclient-*.jar

    5. Compress the spark-archive-2x.zip package again.

      zip spark-archive-2x.zip ./*

    6. Back up the original package from the HDFS to tmp and upload the newly compressed package to the HDFS.

      hdfs dfs -mv hdfs://hacluster/user/spark2x/jars/8.0.2.1/spark-archive-2x.zip /tmp

      hdfs dfs -put spark-archive-2x.zip hdfs://hacluster/user/spark2x/jars/8.0.2.1/spark-archive-2x.zip

    7. Restart the JDBCServer service to prevent JDBCServer exceptions. The jredisclient file has been deleted from the spark-archive-2x.zip package.
    8. Delete temporary files.

      rm -rf /opt/sparkTmp