我正在尝试使用自定义 python 运行 python 脚本并部署--deploy-mode cluster
在 Enterprise 4.2 集群上。
[biadmin@bi4c-xxxxx-mastermanager ~]$ hive
hive> CREATE TABLE pokes (foo INT, bar STRING);
OK
Time taken: 2.147 seconds
hive> LOAD DATA LOCAL INPATH '/usr/iop/4.2.0.0/hive/doc/examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;
Loading data to table default.pokes
Table default.pokes stats: [numFiles=1, numRows=0, totalSize=5812, rawDataSize=0]
OK
Time taken: 0.49 seconds
hive>
然后我创建一个简单的 pyspark 脚本:
[biadmin@bi4c-xxxxxx-mastermanager ~]$ cat test_pokes.py
from pyspark import SparkContext
from pyspark.sql import HiveContext
sc = SparkContext()
hc = HiveContext(sc)
pokesRdd = hc.sql('select * from pokes')
print( pokesRdd.collect() )
然后我尝试像这样运行脚本:
export PYSPARK_PYTHON=/home/biadmin/anaconda2/bin/python2.7
export PYSPARK_DRIVER_PYTHON=/home/biadmin/anaconda2/bin/python2.7
spark-submit --master yarn \
--deploy-mode cluster \
--jars /usr/iop/4.2.0.0/hive/lib/datanucleus-api-jdo-3.2.6.jar,/usr/iop/4.2.0.0/hive/lib/datanucleus-core-3.2.10.jar,/usr/iop/4.2.0.0/hive/lib/datanucleus-rdbms-3.2.9.jar \
--files /usr/iop/current/spark-client/conf/hive-site.xml \
test_pokes.py
这在纱线集群上运行,但不使用该PYSPARK_PYTHON
变量。
但是,如果我使用--deploy-mode client
,PYSPARK_PYTHON
就可以了。
更新
我尝试在 SparkContext 初始化之前添加它:
os.environ["PYSPARK_PYTHON"] = '/home/biadmin/anaconda2/bin/python2.7'
os.environ["PYSPARK_DRIVER_PYTHON"] = '/home/biadmin/anaconda2/bin/python2.7'
另外,尝试设置--conf spark.yarn.appMasterEnv.PYSPARK_PYTHON=/home/biadmin/anaconda2/bin/python2.7
Container: container_e09_1477084339086_0508_02_000001 on bi4c-xxxxxx-data-1.bi.services.bluemix.net_45454
==========================================================================================================
LogType:stderr
...
java.io.IOException: Cannot run program "/home/biadmin/anaconda2/bin/python2.7": error=2, No such file or directory
然而,
[biadmin@bi4c-xxxxxx-mastermanager ~]$ ssh bi4c-xxxxxx-data-1.bi.services.bluemix.net
[biadmin@bi4c-xxxxxx-data-2 ~]$ ls /home/biadmin/anaconda2/bin/python2.7
/home/biadmin/anaconda2/bin/python2.7