scala – 指定hbase-site.xml以spark-submit
发布时间:2020-12-16 18:37:00 所属栏目:安全 来源:网络整理
导读:我有一个spark作业(用 Scala编写),它从另一台服务器上找到的HBase表中检索数据.为了做到这一点,我首先创建如下的HBaseContext: val hBaseContext:HBaseContext = new HBaseContext(sparkContext,HBaseConfiguration.create()) 当我运行spark作业时,我使用s
我有一个spark作业(用
Scala编写),它从另一台服务器上找到的HBase表中检索数据.为了做到这一点,我首先创建如下的HBaseContext:
val hBaseContext:HBaseContext = new HBaseContext(sparkContext,HBaseConfiguration.create()) 当我运行spark作业时,我使用spark-submit并指定所需的参数.像这样的东西: spark-submit --master=local[*] --executor-memory 4g --executor-cores 2 --num-executors 2 --jars $(for x in `ls -1 ~/spark_libs/*.jar`; do readlink -f $x; done | paste -s | sed -e 's/t/,/g') --class com.sparksJob.MyMainClass myJarFile.jar "$@" 问题是这连接到localhost上的zookeeper,但是我希望它连接到另一台服务器上的zookeeper(HBase所在的服务器). 硬编码此信息有效: val configuration: Configuration = new Configuration() configuration.set("hbase.zookeeper.quorum","10.190.144.8") configuration.set("hbase.zookeeper.property.clientPort","2181") val hBaseContext:HBaseContext = new HBaseContext(sparkContext,HBaseConfiguration.create(configuration)) 但是我希望它可以配置. 如何指定spark-submit要使用的hbase-site.xml文件的路径? 解决方法
您可以将hbase-site.xml作为–files选项的参数传递.你的例子将成为:
spark-submit --master yarn-cluster --files /etc/hbase/conf/hbase-site.xml --executor-memory 4g --executor-cores 2 --num-executors 2 --jars $(for x in `ls -1 ~/spark_libs/*.jar`; do readlink -f $x; done | paste -s | sed -e 's/t/,/g') --class com.sparksJob.MyMainClass myJarFile.jar "$@" 注意master设置为yarn-cluster.任何其他选项都会使hbase-site.xml被忽略. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |