当前位置:网站首页>Install spark + run Scala related projects with commands + crontab scheduled execution
Install spark + run Scala related projects with commands + crontab scheduled execution
2022-06-25 18:07:00 【Fishing Map】
One 、 preparation :
1. Software needed :java install jre1.8 spark-2.2.0.tar.gz( It has been configured )
2. What is needed to run the project :maven The project hit jar package --prodmge-mapreduce-0.0.1-SNAPSHOT.jar, Required for operation of the project lib,bjtds.sql
Two 、 install spark And configuration spark The variable of : Mainly for reference https://blog.csdn.net/weixin_46995451/article/details/108709068
Pay attention to spark The version should be consistent with the version used in the project , Otherwise it will go wrong .
Modify environment variables :vim /etc/profile( There is no need to modify in the project , Ignore this step for now )
After adding ,source /etc/profile
After running, only the current window can be used directly in any position spark The order of , It will not work until it is restarted .
3、 ... and 、 Use the command to run the project
1. stay spark-2.2.0/bin Execute under directory No profile
./spark-submit --driver-class-path /home/sy/spark/mysql-connector-java-5.1.6-bin.jar --jars $(files=(/home/sy/single-node/3.docker-service-image-build/lib/*.jar); IFS=,; echo "${files[*]}") --class com.bjtds.ProdmgeDataStastics --master local /home/sy/single-node/3.docker-service-image-build/test.jar
2. After configuring environment variables , Direct use spark-submit command
spark-submit --driver-class-path /home/sy/spark/mysql-connector-java-5.1.6-bin.jar --jars $(files=(/home/sy/single-node/3.docker-service-image-build/lib/*.jar); IFS=,; echo "${files[*]}") --class com.bjtds.ProdmgeDataStastics --master local /home/sy/single-node/3.docker-service-image-build/test.jar
Four 、 Write commands and configurations to shell Script
vim data.sh
Add the following to the script
#!/bin/bash
set mysql-host-mapreduce=192.168.1.242:3306
set mysql-database-bjtds=bjtds
set mysql-username=root
set mysql-passwd=bjtds2019
cd /home/sy/spark/spark-2.2.0/bin && ./spark-submit --driver-class-path /home/sy/spark/mysql-connector-java-5.1.6-bin.jar --jars $(files=(/home/sy/single-node/3.docker-service-image-build/lib/*.jar); IFS=,; echo "${files[*]}") --class com.bjtds.ProdmgeDataStastics --master local /home/sy/single-node/3.docker-service-image-build/test.jar
chmod +x data.sh
5、 ... and 、 Use shell Scripts automatically add scheduled tasks to crontab
vim execCrontab.sh
Add content :
#!/bin/sh
crontab -l > conf && echo "* * * * * /bin/bash /home/sy/spark/test.sh>>/home/sy/spark/prodmgeDataStastics.log 2>&1 " >> conf && crontab conf && rm -f conf
chmod +x execCrontab.sh // Set the permissions
./execCrontab.sh // Execute the script
After the execution , see
crontab -e // Edit view crontab, The original command does not delete , Append to the back .
6、 ... and 、 Summary of problems that have occurred
1.ip Wrong address , Project configuration ip Follow the running ip atypism , There was this mistake .
Finally, the reason is found to be configured in the project code mysql-host, In the system mysql Already configured ip, terms of settlement : Changed the project code mysql-host by mysql-host-xxx.
2. There is no... In the command mysql The driver reports an error spark-submit --jars $(files=(/home/sy/single-node/3.docker-service-image-build/lib/*.jar); IFS=,; echo "${files[*]}") --class com.bjtds.ProdmgeDataStastics --files /home/sy/spark/prodmgeDataStastics.xml --master local /home/sy/single-node/3.docker-service-image-build/test.jar
After adding the driver spark-submit --driver-class-path /home/sy/spark/mysql-connector-java-5.1.6-bin.jar --jars $(files=(/home/sy/single-node/3.docker-service-image-build/lib/*.jar); IFS=,; echo "${files[*]}") --class com.bjtds.ProdmgeDataStastics --files /home/sy/spark/prodmgeDataStastics.xml --master local /home/sy/single-node/3.docker-service-image-build/test.jar Run correctly .
3、crontab Timing execution
crontab -e Enter editing status , Add the last line
service cron restart To restart .
But I found that I couldn't find spark-submit command ,spark The environment variable has been configured , Still in crontab perform shell Could not find problem while scripting , So find out why
Change to the following command , Can operate correctly .
First clear the log file
Log files are also output normally
边栏推荐
- 【工作小技巧】刚入职的软件测试工程师怎么快速上手新岗位
- Which of the top ten securities companies has the lowest commission? Is it safe to open an account
- 智能体白皮书 - 共建智能体,共创全场景智慧 | 云享书库NO.21推荐
- Vscode automatically generates ifndef define ENDIF of header file
- Sentinel哨兵机制
- Accumulation of some common knowledge points
- Deep understanding of ELF files
- SDN system method | 9 Access network
- Agent white paper - jointly build agents and create the wisdom of the whole scene | cloud library No.21 recommendation
- Use diskgenius to expand the capacity of system disk C
猜你喜欢
SDN system method | 9 Access network
Article 7: there is no code prompt in clion,,,
Introduction to the container of() function
Centos7 installing redis 7.0.2
Solve nvprof error err_ NVGPUCTRPERM - The user does not have permission to profile on the target device.
ACY100油烟浓度在线监控仪针对饮食业厨房油烟排放
Matlab中图形对象属性gca使用
QT中QString包含“\u0000“的处理方式
A simple and easy-to-use graph visualization tool developed recently
ASP. Net supermarket convenience store online shopping mall source code, for the surrounding distribution system
随机推荐
[machine learning] case study of college entrance examination prediction based on multiple time series
The performance of the server's four channel memory is improved. How about the performance of the four channel memory
New characteristics of cultural consumption in the era of digital economy
Video production material website arrangement
IET出席2022世界科技社团发展与治理论坛 为构建国际科技共同体献言献策
篇5:VS2017搭建QT5.9.9开发环境
【工作小技巧】刚入职的软件测试工程师怎么快速上手新岗位
RuntimeError: Trying to backward through the graph a second time (or directly access saved variable
Use of jupyter
mysql mysql-8.0.19-winx64 安装与navicat连接
十大龙头券商 办理开户安全吗
Three traversal methods of binary tree (recursive + non recursive) complete code
Android物联网应用程序开发(智慧园区)—— 图片预览界面
Qt使用SQLITE数据库
1、对范数的理解
SDN system method | 9 Access network
TLV decoding
HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
CONDA modifying a mirror source
Sentinel sentinel mechanism