data_new_table.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. set -x
  3. source /root/anaconda3/bin/activate py37
  4. export SPARK_HOME=/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8
  5. export PATH=$SPARK_HOME/bin:$PATH
  6. export HADOOP_CONF_DIR=/etc/taihao-apps/hadoop-conf
  7. export JAVA_HOME=/usr/lib/jvm/java-1.8.0
  8. # nohup sh handle_rov.sh > "$(date +%Y%m%d_%H%M%S)_handle_rov.log" 2>&1 &
  9. # 原始数据table name
  10. table='alg_recsys_sample_all_v2'
  11. # 处理分区配置 推荐数据间隔一天生产,所以5日0点使用3日0-23点数据生产new模型数据
  12. begin_early_2_Str=20240728
  13. end_early_2_Str=20240728
  14. beginHhStr=00
  15. endHhStr=23
  16. max_hour=05
  17. max_minute=00
  18. # 各节点产出hdfs文件绝对路径
  19. # 源数据文件
  20. originDataPath=/dw/recommend/model/41_recsys_sample_data_new_table/
  21. # 特征分桶
  22. bucketDataPath=/dw/recommend/model/43_recsys_train_data_new_table/
  23. # hadoop
  24. HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
  25. # 0 判断上游表是否生产完成,最长等待到max_hour点
  26. # shellcheck disable=SC2154
  27. # echo "$(date +%Y-%m-%d_%H-%M-%S)----------step0------------开始校验是否生产完数据,分区信息:beginStr:${begin_early_2_Str}${beginHhStr},endStr:${end_early_2_Str}${endHhStr}"
  28. # while true; do
  29. # python_return_code=$(python /root/joe/recommend-emr-dataprocess/qiaojialiang/checkHiveDataUtil.py --table ${table} --beginStr ${begin_early_2_Str}${beginHhStr} --endStr ${end_early_2_Str}${endHhStr})
  30. # echo "python 返回值:${python_return_code}"
  31. # if [ $python_return_code -eq 0 ]; then
  32. # echo "Python程序返回0,校验存在数据,退出循环。"
  33. # break
  34. # fi
  35. # echo "Python程序返回非0值,不存在数据,等待五分钟后再次调用。"
  36. # sleep 300
  37. # current_hour=$(date +%H)
  38. # current_minute=$(date +%M)
  39. # # shellcheck disable=SC2039
  40. # if (( current_hour > max_hour || (current_hour == max_hour && current_minute >= max_minute) )); then
  41. # echo "最长等待时间已到,失败:${current_hour}-${current_minute}"
  42. # exit 1
  43. # fi
  44. # done
  45. # 1 生产原始数据
  46. echo "$(date +%Y-%m-%d_%H-%M-%S)----------step1------------开始根据${table}生产原始数据"
  47. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  48. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  49. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  50. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  51. tablePart:64 repartition:32 \
  52. beginStr:${begin_early_2_Str}00 endStr:${end_early_2_Str}09 \
  53. savePath:${originDataPath} \
  54. table:${table} &
  55. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  56. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  57. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  58. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  59. tablePart:64 repartition:32 \
  60. beginStr:${begin_early_2_Str}10 endStr:${end_early_2_Str}15 \
  61. savePath:${originDataPath} \
  62. table:${table} &
  63. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  64. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  65. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  66. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  67. tablePart:64 repartition:32 \
  68. beginStr:${begin_early_2_Str}16 endStr:${end_early_2_Str}23 \
  69. savePath:${originDataPath} \
  70. table:${table} &
  71. wait
  72. if [ $? -ne 0 ]; then
  73. echo "Spark原始样本生产任务执行失败"
  74. exit 1
  75. else
  76. echo "spark原始样本生产执行成功"
  77. fi
  78. # 2 特征分桶
  79. echo "$(date +%Y-%m-%d_%H-%M-%S)----------step2------------根据特征分桶生产重打分特征数据"
  80. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  81. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_43_bucketData_20240709 \
  82. --master yarn --driver-memory 2G --executor-memory 4G --executor-cores 1 --num-executors 16 \
  83. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  84. readPath:${originDataPath} \
  85. savePath:${bucketDataPath} \
  86. beginStr:${begin_early_2_Str} endStr:${end_early_2_Str} repartition:500 \
  87. filterNames:XXXXXXXXX \
  88. fileName:20240609_bucket_314.txt \
  89. whatLabel:is_return whatApps:0,4,21,17
  90. if [ $? -ne 0 ]; then
  91. echo "Spark特征分桶处理任务执行失败"
  92. exit 1
  93. else
  94. echo "spark特征分桶处理执行成功"
  95. fi
  96. echo "$(date +%Y-%m-%d_%H-%M-%S)----------step5------------spark特征分桶处理执行成功:${begin_early_2_Str}"