cd /opt/soft
tar -zxvf spark-2.3.0-bin-hadoop2.7.tgz
mv spark-2.3.0-bin-hadoop2.7/ spark
vi /etc/profile
export SPARK_HOME=/opt/soft/spark
export PATH=$SPARK_HOME/bin:$SPARK_HOME/sbin:$PATH
source /etc/profile
cd opt/soft/spark/conf
cp spark-env.sh.template spark-env.sh
vi spark-env.sh
export JAVA_HOME=/opt/soft/jdk
export HADOOP_HOME=/opt/soft/hadoop
export HADOOP_CONF_DIR=/opt/soft/hadoop/etc/hadoop
export SPARK_MASTER_HOST=master
export SPARK_MASTER_PORT=7077
export SPARK_LOCAL_IP=master
scp -r /opt/soft/spark root@slave01:/opt/soft
scp -r /opt/soft/spark root@slave02:/opt/soft
cd /opt/soft/spark/sbin
./start-all.sh
cd /
cd opt/soft/spark/conf
vi spark-env.sh
export JAVA_HOME=/opt/soft/jdk
export SPARK_MASTER_HOST=master
export SPARK_MASTER_PORT=7077
export SPARK_WORKER_CORES=1
export SPARK_WORKER_MEMORY=1g
export SPARK_CONF_DIR=/opt/soft/spark/conf
cp slaves.template slaves
vi slaves
slave01
slave02
cd /
cd opt/soft/spark/sbin
start-all.sh
import scala.collection.mutable.ListBuffer
object ll
{
// 1循环
def main(args: Array[String]): Unit = {
for (i <- 1 to 10){
println(i)
}
// 2.方法
def sum(a: Int,b:Int): Int = a+b
val result=sum(5,3)
println(result)
//3.函数
val square=(x: Int)=> x * x
val squared=square(5)
println(squared)
//4.数组
val array=Array(1,2,3,4,5)
array.foreach(println)
//5.元组
val tuple=("hello",42)
println(tuple._1)
println(tuple._2)
//6.列表
val list = List("apple","banana","cherry")
val upperCaseList = list.map(_.toUpperCase)
println(upperCaseList)
//7.集合
val set = Set(1,2,3,4,5,6)
val evenMumbers = set.filter(_% 2 == 0)
println(evenMumbers)
//8.映射
val map=Map("one" -> 1, "two" -> 2, "three" ->3)
val value =map.get("two")
value.foreach(println)
//9.可变与不可变集合
import scala.collection.mutable.ListBuffer
val immutableList = List(1,2,3)
val mutableListBuffer = new ListBuffer[Int]
mutableListBuffer += 1
mutableListBuffer += 2
mutableListBuffer += 3
println(immutableList)
println(mutableListBuffer)
}
}