在Spark Shell中编写WordCount程序的步骤如下:1. 首先启动HDFS。2. 将文件上传至HDFS路径 hdfs://hdp-01:9000/wordcount/input/a.txt。3. 在Spark Shell中使用Scala编写Spark程序:scala> sc.textFile(\"hdfs://hdp-01:9000/wordcount/input/\").flatMap(.split(\" \")).map((,1)).reduceByKey( + ).sortBy(_._2,false).collect。注意:Spark是懒加载的,需要调用action方法才会正式运行。