21_make_data_new_table.sh 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/sh
  2. set -x
  3. export SPARK_HOME=/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8
  4. export PATH=$SPARK_HOME/bin:$PATH
  5. export HADOOP_CONF_DIR=/etc/taihao-apps/hadoop-conf
  6. export JAVA_HOME=/usr/lib/jvm/java-1.8.0
  7. source /root/anaconda3/bin/activate py37
  8. # 原始数据table name
  9. table='alg_recsys_sample_all_v2'
  10. # 处理分区配置 推荐数据间隔一天生产,所以5日0点使用3日0-23点数据生产new模型数据
  11. begin_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
  12. end_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
  13. beginHhStr=00
  14. endHhStr=23
  15. max_hour=05
  16. max_minute=00
  17. # 各节点产出hdfs文件绝对路径
  18. # 源数据文件
  19. originDataPath=/dw/recommend/model/41_recsys_sample_data_new_table/
  20. # 特征分桶
  21. bucketDataPath=/dw/recommend/model/43_recsys_train_data_new_table/
  22. # hadoop
  23. HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
  24. # 1 生产原始数据
  25. echo "$(date +%Y-%m-%d_%H-%M-%S)----------step1------------开始根据${table}生产原始数据"
  26. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  27. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  28. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  29. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  30. tablePart:64 repartition:32 \
  31. beginStr:${begin_early_2_Str}00 endStr:${end_early_2_Str}09 \
  32. savePath:${originDataPath} \
  33. table:${table} &
  34. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  35. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  36. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  37. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  38. tablePart:64 repartition:32 \
  39. beginStr:${begin_early_2_Str}10 endStr:${end_early_2_Str}15 \
  40. savePath:${originDataPath} \
  41. table:${table} &
  42. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  43. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
  44. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  45. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  46. tablePart:64 repartition:32 \
  47. beginStr:${begin_early_2_Str}16 endStr:${end_early_2_Str}23 \
  48. savePath:${originDataPath} \
  49. table:${table} &
  50. wait
  51. if [ $? -ne 0 ]; then
  52. echo "Spark原始样本生产任务执行失败"
  53. exit 1
  54. else
  55. echo "spark原始样本生产执行成功"
  56. fi
  57. # 特征采样分桶
  58. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  59. --class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_43_bucketData_fu_sample_20240709 \
  60. --master yarn --driver-memory 2G --executor-memory 4G --executor-cores 1 --num-executors 16 \
  61. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  62. readPath:/dw/recommend/model/41_recsys_sample_data_new_table \
  63. savePath:/dw/recommend/model/43_recsys_train_data_new_table_274_sample_01 \
  64. beginStr:${begin_early_2_Str} endStr:${end_early_2_Str} repartition:500 \
  65. filterNames:ROS fuSampleRate:0.1 \
  66. fileName:20240609_bucket_314.txt \
  67. whatLabel:is_return whatApps:0,3,4,21,17
  68. if [ $? -ne 0 ]; then
  69. echo "Spark特征分桶任务执行失败"
  70. exit 1
  71. else
  72. echo "spark特征分桶任务执行成功"
  73. fi
  74. # 定时任务配置
  75. # 0 11 * * * cd /root/zhaohp/recommend-emr-dataprocess && /bin/sh ./recommend/21_make_data_new_table.sh > logs/recommend/21_make_data_new_table/$(date +\%Y\%m\%d\%H\%M).log 2>&1