spark上的一些常用命令(一)


1. 加速跑

spark-sql --name uername --num-executors 21 --driver-memory 8G --executor-memory 8G

2. 上傳數據

  • 建表
create table xxx_yyy ( userid varchar(200))
  • 上傳數據
load data local inpath '/home/spark/xxx.txt' into xxx_yyy
##inpath后面跟路徑名,into后面跟表名

3. 導出數據

hive -e "select * from temp.user_temp;" > /home/spark/temp/daochu.txt
##通過hive的導出,代碼盡量從中間表出,短代碼沒問題,但是越長越會出現問題。

4. 建表語句

create table table_name 
(
    column1 double  comment '字段注釋1',
    column2 double  comment '字段注釋2'
)partitioned by (data_date string)
row format delimited
fields terminated by '\t'
stored as textfile
;
---創建新表

insert overwrite table table_name partition(data_date)
drop table if exists table_name;
create table if not exists table_name as .....
---更好的建表方式

 5. MAC上的數據加密打包工作

##STEP 1
首先開啟終端機(Terminal),使用 cd 指令切換到要壓縮的檔案所在目錄,如果放在桌面上就是:
cd Desktop
##STEP 2
##使用 zip 指令配合 -e 參數制作加密的壓縮檔:
zip -e daobao.zip daobaowenjian.txt
##其中 daobaowenjian.txt 就是要加密壓縮的檔案,而 daobao.zip 就是輸出的壓縮檔檔名。



##在壓縮前,要先輸入密碼:
##如果要壓縮整個資料夾,就把上面的 filetoprotect.txt 替換成資料夾,再加上 -r即可,例如:
zip -er ~20180115.zip ~/20180115/
zip -er 20180115.zip  20180115

 6. VIM的常用快捷鍵


7. UDF的使用

add jar /home/script_job/jar/hive-udf-1.0.jar;
create temporary function month_end as 'com.xxx.hive_udf.EndDayOfMonth';

8. MAC上用終端快速鏈接跳板機訪問spark

vi ~/.bash_profile
alias work="ssh user_name@172.0.0.0"
##保存后可在終端直接輸入work進行訪問

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM