当前位置:网站首页>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 !
边栏推荐
- Oracle memory management
- 刚毕业的欧洲大学生,就能拿到美国互联网大厂 Offer?
- Understanding of CPU buffer line
- Slf4j log facade
- Luogup3694 Bangbang chorus standing in line
- Finite State Machine FSM
- Box layout of Kivy tutorial BoxLayout arranges sub items in vertical or horizontal boxes (tutorial includes source code)
- MySQL installation, uninstallation, initial password setting and general commands of Linux
- Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
- 【历史上的今天】7 月 3 日:人体工程学标准法案;消费电子领域先驱诞生;育碧发布 Uplay
猜你喜欢
Box layout of Kivy tutorial BoxLayout arranges sub items in vertical or horizontal boxes (tutorial includes source code)
regular expression
Mysql database basic operation - regular expression
这本数学书AI圈都在转,资深ML研究员历时7年之作,免费电子版可看
正则表达式
Sword finger offer 14- ii Cut rope II
物联网毕设 --(STM32f407连接云平台检测数据)
106. How to improve the readability of SAP ui5 application routing URL
Road construction issues
剑指 Offer 12. 矩阵中的路径
随机推荐
Setting up remote links to MySQL on Linux
SQL learning notes (I)
显卡缺货终于到头了:4000多块可得3070Ti,比原价便宜2000块拿下3090Ti
MySQL constraints
MyCms 自媒体商城 v3.4.1 发布,使用手册更新
Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory
IDEA 全文搜索快捷键Ctr+Shift+F失效问题
DQL basic query
This math book, which has been written by senior ml researchers for 7 years, is available in free electronic version
Flink SQL knows why (16): dlink, a powerful tool for developing enterprises with Flink SQL
Sword finger offer 12 Path in matrix
The reasons why there are so many programming languages in programming internal skills
2022-02-14 analysis of the startup and request processing process of the incluxdb cluster Coordinator
剑指 Offer 17. 打印从1到最大的n位数
The difference between stratifiedkfold (classification) and kfold (regression)
阿南的疑惑
JSP and filter
February 14, 2022, incluxdb survey - mind map
编程内功之编程语言众多的原因
Servlet