报错信息:
ERROR SparkContext: Error initializing SparkContext.
Cannot assign requested address: bind: Service 'sparkDriver' failed after 16 retries (starting from 7078)! Consider explicitly setting the appropriate port for the service 'sparkDriver' (for example spark.ui.port for SparkUI) to an available port or increasing spark.port.maxRetries.
原因分析:
java.net.BindException: Cannot assign requested address: bind:是由于IP地址变化导致的;
java.net.BindException: Address already in use: JVM_Bind:是由于端口被别的进程占用导致的,或者别的进程不使用后还没有释放;
解决办法:
在代码中需要手工添加一个比如本地环境设置
添加以下代码.set("spark.driver.host","localhost")
conf = SparkConf().setMaster("local[*]").setAppName("测试").set("spark.driver.host","localhost")