我在AWS中创建了一个3节点(1个主节点,2个工作节点) loadModels = function () {
// loop through all files in models directory ignoring hidden files and this file
fs.readdirSync(config.modelsDirMongo)
.filter(function (file) {
return (file.indexOf('.') !== 0) && (file !== 'index.js')
})
// import model files and save model names
.forEach(function (file) {
winston.info('Loading mongoose model file ' + file);
require(path.join(config.modelsDirMongo, file));
});
};
群集。我可以从主服务器向集群提交作业,但是我无法远程工作。
Apache Spark
我可以从主人那里看到:
/* SimpleApp.scala */
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
object SimpleApp {
def main(args: Array[String]) {
val logFile = "/usr/local/spark/README.md" // Should be some file on your system
val conf = new SparkConf().setAppName("Simple Application").setMaster("spark://ec2-54-245-111-320.compute-1.amazonaws.com:7077")
val sc = new SparkContext(conf)
val logData = sc.textFile(logFile, 2).cache()
val numAs = logData.filter(line => line.contains("a")).count()
val numBs = logData.filter(line => line.contains("b")).count()
println(s"Lines with a: $numAs, Lines with b: $numBs")
sc.stop()
}
}
所以当我从本地计算机执行Spark Master at spark://ip-171-13-22-125.ec2.internal:7077
URL: spark://ip-171-13-22-125.ec2.internal:7077
REST URL: spark://ip-171-13-22-125.ec2.internal:6066 (cluster mode)
时,它无法连接到SimpleApp.scala
:
Spark Master
但是,我知道如果我将主设备设置为2017-02-04 19:59:44,074 INFO [appclient-register-master-threadpool-0] client.StandaloneAppClient$ClientEndpoint (Logging.scala:54) [] - Connecting to master spark://ec2-54-245-111-320.compute-1.amazonaws.com:7077...
2017-02-04 19:59:44,166 WARN [appclient-register-master-threadpool-0] client.StandaloneAppClient$ClientEndpoint (Logging.scala:87) [] - Failed to connect to spark://ec2-54-245-111-320.compute-1.amazonaws.com:7077
org.apache.spark.SparkException: Exception thrown in awaitResult
at org.apache.spark.rpc.RpcTimeout$$anonfun$1.applyOrElse(RpcTimeout.scala:77) ~[spark-core_2.10-2.0.2.jar:2.0.2]
at org.apache.spark.rpc.RpcTimeout$$anonfun$1.applyOrElse(RpcTimeout.scala:75) ~[spark-core_2.10-2.0.2.jar:2.0.2]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33) ~[scala-library-2.10.0.jar:?]
at org.apache.spark.rpc.RpcTimeout$$anonfun$addMessageIfTimeout$1.applyOrElse(RpcTimeout.scala:59) ~[spark-core_2.10-2.0.2.jar:2.0.2]
会有效,因为它会在本地运行。但是,我想让我的客户端连接到这个远程主服务器。我怎么能做到这一点? Apache配置看起来像文件。我甚至可以telnet到公共DNS和端口,我还为每个local
实例配置了/etc/hosts
公共DNS和主机名。
我希望能够向这位远程主人提交工作,我缺少什么?
答案 0 :(得分:7)
对于绑定主机主机名/ IP,请转到spark安装conf目录(spark-2.0.2-bin-hadoop2.7 / conf)并使用以下命令创建spark-env.sh文件。
cp spark-env.sh.template spark-env.sh
在vi编辑器中打开spark-env.sh文件,并添加以下行与主人的主机名/ IP。
SPARK_MASTER_HOST=ec2-54-245-111-320.compute-1.amazonaws.com
使用stop-all.sh和start-all.sh停止并启动Spark。现在您可以使用它来使用
连接远程主控val spark = SparkSession.builder()
.appName("SparkSample")
.master("spark://ec2-54-245-111-320.compute-1.amazonaws.com:7077")
.getOrCreate()
有关设置环境变量的更多信息,请查看http://spark.apache.org/docs/latest/spark-standalone.html#cluster-launch-scripts
答案 1 :(得分:0)
我在重新启动在远程集群上启动本地代码时遇到了另一个问题: 作业正在提交,资源分配正确,但是我的本地计算机上的驱动程序进程声称群集未被接受
WARN TaskSchedulerImpl:初始作业没有接受任何资源; 检查您的集群用户界面,以确保工作人员已注册并拥有 足够的资源
在远程计算机的日志上,我注意到它正在从本地网络接受带有驱动程序URL的作业
ExecutorRunner:54-启动命令: “ /opt/jdk1.8.0_131/bin/java”“ -cp” “ /opt/spark-2.3.3-bin-hadoop2.7/conf/:/opt/spark-2.3.3-bin-hadoop2.7/jars/*” “ -Xmx16384M”“ -Dspark.driver.port = 59399” “ org.apache.spark.executor.CoarseGrainedExecutorBackend” “ --driver-url”“ spark://CoarseGrainedScheduler@192.168.88.227:59399” “ --executor-id”“ 0”“ --hostname”“ 172.31.50.134”“ --cores”“ 4” “ --app-id”“ app-20190318121936-0000”“ --worker-url” “ spark://Worker@172.31.50.134:45999”
所以我的问题是使用错误的主机名解析驱动程序进程