macOS Spark 2.4.3 standalone 搭建笔记

based on

jdk 1.8

Mac os


1、解压


nancylulululu:local nancy$ tar -zxvf /Users/nancy/Downloads/spark-2.4.3-bin-hadoop2.7.tar -C /usr/local/opt/


2、重命名并修改配置文件


nancylulululu:conf nancy$ cp slaves.template slaves

nancylulululu:conf nancy$ cp spark-defaults.conf.template spark-defaults.conf

nancylulululu:conf nancy$ cp spark-env.sh.template spark-env.sh

nancylulululu:conf nancy$ vi slaves

localhost


nancylulululu:conf nancy$ vi spark-env.sh



SPARK_LOCAL_IP=127.0.0.1

SPARK_MASTER_HOST=127.0.0.1

SPARK_MASTER_PORT=7077

SPARK_WORKER_CORES=2

SPARK_WORKER_MEMORY=1G



3、启动spark


nancylulululu:spark-2.4.3 nancy$ sbin/start-all.sh

starting org.apache.spark.deploy.master.Master, logging to /usr/local/opt/spark-2.4.3/logs/spark-nancy-org.apache.spark.deploy.master.Master-1-nancylulululu.out

localhost: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/opt/spark-2.4.3/logs/spark-nancy-org.apache.spark.deploy.worker.Worker-1-nancylulululu.out


jps 查看一个 master 和一个 worker服务

nancylulululu:conf nancy$ jps

3908 CoarseGrainedExecutorBackend

3478 Master

4166 Jps

3896 SparkSubmit

3514 Worker



4、 Launching Applications with spark-submit

Once a user application is bundled, it can be launched using the  bin/spark-submit  script. This script takes care of setting up the classpath with Spark and its dependencies, and can support different cluster managers and deploy modes that Spark supports:

./bin/spark-submit \   --class <main-class> \   --master <master-url> \   --deploy-mode <deploy-mode> \   --conf <key>=<value> \   ... # other options   <application-jar> \   [application-arguments]

Some of the commonly used options are:

  • --class : The entry point for your application (e.g.  org.apache.spark.examples.SparkPi )
  • --master : The  master URL  for the cluster (e.g.  spark://23.195.26.187:7077 )
  • --deploy-mode : Whether to deploy your driver on the worker nodes ( cluster ) or locally as an external client ( client ) (default:  client † 
  • --conf : Arbitrary Spark configuration property in key=value format. For values that contain spaces wrap “key=value” in quotes (as shown).
  • application-jar : Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an  hdfs://  path or a  file://  path that is present on all nodes.
  • application-arguments : Arguments passed to the main method of your main class, if any

脚本:


./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master spark://localhost:7077 \
 /usr/local/opt/spark-2.4.3/examples/jars/spark-examples_2.11-2.4.3.jar \
100


结果

Pi is roughly 3.1413047141304715

19/05/14 14:23:06 INFO SparkUI: Stopped Spark web UI at http://localhost:4040


5、spark-shell 模式

nancylulululu:spark-2.4.3 nancy$ bin/spark-shell --master spark://localhost:7077








6、测试wordcount


测试文件

nancylulululu:opt nancy$ vi 3.txt


hello scala hello spark hello mysql hello java hello java hello scala



测试结果



scala> sc.textFile("/usr/local/opt/3.txt").flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).collect

res1: Array[(String, Int)] = Array((scala,2), (mysql,1), (hello,6), (java,2), (spark,1))


scala> 





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69908925/viewspace-2644303/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/69908925/viewspace-2644303/

为了在 macOS搭建 PHP 开发环境,你可以按照以下步骤进行操作: 1. 安装 Homebrew:Homebrew 是 macOS 上一个常用的包管理器。打开终端并输入以下命令安装 Homebrew: ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 2. 安装 PHP:使用 Homebrew 安装 PHP。在终端中输入以下命令: ``` brew install php ``` 3. 配置 PHP:默认情况下,Homebrew 会将 PHP 安装在 `/usr/local/etc/php` 目录下。你可以根据需要进行配置更改。 4. 安装一个 Web 服务器:你可以选择安装 Apache 或 Nginx 作为 Web 服务器。下面是安装 Apache 的步骤: - 安装 Apache: ``` brew install httpd ``` - 配置 Apache:编辑 `/usr/local/etc/httpd/httpd.conf` 文件进行必要的配置更改,如修改网站根目录等。 - 启动 Apache: ``` sudo apachectl start ``` - 在浏览器中输入 `http://localhost`,如果看到 "It works!" 的页面,则说明 Apache 已经成功安装并运行。 5. 安装数据库:如果你需要使用数据库,可以选择安装 MySQL 或 PostgreSQL。使用以下命令安装 MySQL: ``` brew install mysql ``` - 启动 MySQL: ``` brew services start mysql ``` - 设置 MySQL 根密码: ``` mysql_secure_installation ``` 6. 安装开发工具:你可以选择安装一个集成开发环境(IDE)或文本编辑器,如 Visual Studio Code、PhpStorm、Sublime Text 等。 这样,你的 macOS PHP 开发环境就搭建完成了。你可以在配置文件中进行进一步的定制和调整,以适应你的开发需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值