当前位置:网站首页>Spark practice 1: build spark operation environment in single node local mode
Spark practice 1: build spark operation environment in single node local mode
2022-07-03 13:22:00 【Brother Xing plays with the clouds】
Preface :
Spark For its own use scala Written , Running on the JVM above .
JAVA edition :java 6 /higher edition.
1 download Spark
http://spark.apache.org/downloads.html
You can choose the version you need , My choice here is :
http://d3kbcqa49mib13.cloudfront.net/spark-1.1.0-bin-hadoop1.tgz
If you are a good farmer who works hard , You can download the source code yourself :http://github.com/apache/spark.
Be careful : I'm running here Linux In the environment . You can install it on the virtual machine without conditions !
2 decompression & Entry directory
tar -zvxf spark-1.1.0-bin-Hadoop1.tgz
cd spark-1.1.0-bin-hadoop1/
3 start-up shell
./bin/spark-shell
You will see a lot of things printed , Finally, it shows
4 A profound
Execute the following statements successively
val lines = sc.textFile("README.md")
lines.count()
lines.first()
val pythonLines = lines.filter(line => line.contains("Python"))
scala> lines.first() res0: String = ## Interactive Python Shel
--- explain , What is? sc
sc It is generated by default SparkContext object .
such as
scala> sc res13: org.apache.spark.SparkContext = [email protected]
Here is only local operation , Let's know in advance Distributed A diagram of the calculation :
5 Independent program
Finally, I will conclude this section with an example
In order to make it run smoothly , Just follow the steps below :
-------------- The directory structure is as follows :
/usr/local/spark-1.1.0-bin-hadoop1/test$ find . . ./src ./src/main ./src/main/scala ./src/main/scala/example.scala ./simple.sbt
then simple.sbt Is as follows :
name := "Simple Project" version := "1.0" scalaVersion := "2.10.4" libraryDependencies += "org.apache.spark" %% "spark-core" % "1.1.0"example.scala Is as follows :
import org.apache.spark.SparkConf import org.apache.spark.SparkContext import org.apache.spark.SparkContext._
object example { def main(args: Array[String]) { val conf = new SparkConf().setMaster("local").setAppName("My App") val sc = new SparkContext("local", "My App") sc.stop() //System.exit(0) //sys.exit() println("this system exit ok!!!") } }
Red local: One colony Of URL, Here is local, tell spark How to connect a colony ,local It means running in a single thread on the local machine without connecting to a cluster .
Orange My App: The name of a project ,
And then execute :sbt package
Execute after success
./bin/spark-submit --class "example" ./target/scala-2.10/simple-project_2.10-1.0.jar
give the result as follows :
It shows that the implementation is indeed successful !
end !
边栏推荐
- Typeerror resolved: argument 'parser' has incorrect type (expected lxml.etree.\u baseparser, got type)
- The 35 required questions in MySQL interview are illustrated, which is too easy to understand
- Elk note 24 -- replace logstash consumption log with gohangout
- Swiftui development experience: the five most powerful principles that a programmer needs to master
- stm32和电机开发(从mcu到架构设计)
- Anan's doubts
- sitesCMS v3.0.2发布,升级JFinal等依赖
- [Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [sqlserver2012 comprehensive exercise]
- Will Huawei be the next one to fall
- Introduction to the implementation principle of rxjs observable filter operator
猜你喜欢

Flink SQL knows why (13): is it difficult to join streams? (next)

elk笔记24--用gohangout替代logstash消费日志

Flink SQL knows why (17): Zeppelin, a sharp tool for developing Flink SQL

Sword finger offer 14- ii Cut rope II

106. 如何提高 SAP UI5 应用路由 url 的可读性

Image component in ETS development mode of openharmony application development

My creation anniversary: the fifth anniversary

Sword finger offer 12 Path in matrix

今日睡眠质量记录77分

MySQL installation, uninstallation, initial password setting and general commands of Linux
随机推荐
Tencent cloud tdsql database delivery and operation and maintenance Junior Engineer - some questions of Tencent cloud cloudlite certification (TCA) examination
When the R language output rmarkdown is in other formats (such as PDF), an error is reported, latex failed to compile stocks Tex. solution
【历史上的今天】7 月 3 日:人体工程学标准法案;消费电子领域先驱诞生;育碧发布 Uplay
JSP and filter
Setting up Oracle datagurd environment
stm32和电机开发(从mcu到架构设计)
[Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [Chapter V exercises]
Elk note 24 -- replace logstash consumption log with gohangout
luoguP3694邦邦的大合唱站队
Convolution emotion analysis task4
Internet of things completion -- (stm32f407 connects to cloud platform detection data)
elk笔记24--用gohangout替代logstash消费日志
Smbms project
The difference between session and cookie
Sword finger offer 12 Path in matrix
The difference between stratifiedkfold (classification) and kfold (regression)
Box layout of Kivy tutorial BoxLayout arranges sub items in vertical or horizontal boxes (tutorial includes source code)
[sort] bucket sort
2022-01-27 redis cluster technology research
18W word Flink SQL God Road manual, born in the sky