|  | @@ -0,0 +1,132 @@
 | 
											
												
													
														|  | 
 |  | +#!/bin/sh
 | 
											
												
													
														|  | 
 |  | +set -x
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +source /root/anaconda3/bin/activate py37
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +export SPARK_HOME=/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8
 | 
											
												
													
														|  | 
 |  | +export PATH=$SPARK_HOME/bin:$PATH
 | 
											
												
													
														|  | 
 |  | +export HADOOP_CONF_DIR=/etc/taihao-apps/hadoop-conf
 | 
											
												
													
														|  | 
 |  | +export JAVA_HOME=/usr/lib/jvm/java-1.8.0
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +#  nohup sh handle_rov.sh > "$(date +%Y%m%d_%H%M%S)_handle_rov.log" 2>&1 &
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +# 原始数据table name
 | 
											
												
													
														|  | 
 |  | +table='alg_recsys_sample_all'
 | 
											
												
													
														|  | 
 |  | +today="$(date +%Y%m%d)"
 | 
											
												
													
														|  | 
 |  | +today_early_3="$(date -d '3 days ago' +%Y%m%d)"
 | 
											
												
													
														|  | 
 |  | +#table='alg_recsys_sample_all_test'
 | 
											
												
													
														|  | 
 |  | +# 处理分区配置 推荐数据间隔一天生产,所以5日0点使用3日0-23点数据生产new模型数据
 | 
											
												
													
														|  | 
 |  | +begin_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
 | 
											
												
													
														|  | 
 |  | +end_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
 | 
											
												
													
														|  | 
 |  | +beginHhStr=00
 | 
											
												
													
														|  | 
 |  | +endHhStr=23
 | 
											
												
													
														|  | 
 |  | +max_hour=05
 | 
											
												
													
														|  | 
 |  | +max_minute=00
 | 
											
												
													
														|  | 
 |  | +# 各节点产出hdfs文件绝对路径
 | 
											
												
													
														|  | 
 |  | +# 源数据文件
 | 
											
												
													
														|  | 
 |  | +originDataPath=/dw/recommend/model/41_recsys_sample_data/
 | 
											
												
													
														|  | 
 |  | +# 特征值
 | 
											
												
													
														|  | 
 |  | +valueDataPath=/dw/recommend/model/14_feature_data/
 | 
											
												
													
														|  | 
 |  | +# 特征分桶
 | 
											
												
													
														|  | 
 |  | +bucketDataPath=/dw/recommend/model/43_recsys_train_data/
 | 
											
												
													
														|  | 
 |  | +# 模型数据路径
 | 
											
												
													
														|  | 
 |  | +MODEL_PATH=/root/joe/recommend-emr-dataprocess/model
 | 
											
												
													
														|  | 
 |  | +# 预测路径
 | 
											
												
													
														|  | 
 |  | +PREDICT_PATH=/root/joe/recommend-emr-dataprocess/predict
 | 
											
												
													
														|  | 
 |  | +# 历史线上正在使用的模型数据路径
 | 
											
												
													
														|  | 
 |  | +LAST_MODEL_HOME=/root/joe/model_online
 | 
											
												
													
														|  | 
 |  | +# 模型数据文件前缀
 | 
											
												
													
														|  | 
 |  | +model_name=model_nba8
 | 
											
												
													
														|  | 
 |  | +# fm模型
 | 
											
												
													
														|  | 
 |  | +FM_HOME=/root/sunmingze/alphaFM/bin
 | 
											
												
													
														|  | 
 |  | +# hadoop
 | 
											
												
													
														|  | 
 |  | +HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
 | 
											
												
													
														|  | 
 |  | +OSS_PATH=oss://art-recommend.oss-cn-hangzhou.aliyuncs.com/zhangbo/
 | 
											
												
													
														|  | 
 |  | +#OSS_PATH=oss://art-recommend.oss-cn-hangzhou.aliyuncs.com/qiaojialiang/
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +# 1 生产原始数据
 | 
											
												
													
														|  | 
 |  | +echo "$(date +%Y-%m-%d_%H-%M-%S)----------step1------------开始根据${table}生产原始数据"
 | 
											
												
													
														|  | 
 |  | +#/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
 | 
											
												
													
														|  | 
 |  | +#--class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
 | 
											
												
													
														|  | 
 |  | +#--master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
 | 
											
												
													
														|  | 
 |  | +#../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
 | 
											
												
													
														|  | 
 |  | +#tablePart:64 repartition:32 \
 | 
											
												
													
														|  | 
 |  | +#beginStr:${begin_early_2_Str}${beginHhStr} endStr:${end_early_2_Str}${endHhStr} \
 | 
											
												
													
														|  | 
 |  | +#savePath:${originDataPath} \
 | 
											
												
													
														|  | 
 |  | +#table:${table}
 | 
											
												
													
														|  | 
 |  | +#if [ $? -ne 0 ]; then
 | 
											
												
													
														|  | 
 |  | +#   echo "Spark原始样本生产任务执行失败"
 | 
											
												
													
														|  | 
 |  | +#   /root/anaconda3/bin/python monitor_util.py --level error --msg "荐模型数据更新 \n【任务名称】:step1根据${table}生产原始数据\n【是否成功】:error\n【信息】:Spark原始样本生产任务执行失败"
 | 
											
												
													
														|  | 
 |  | +#   exit 1
 | 
											
												
													
														|  | 
 |  | +#else
 | 
											
												
													
														|  | 
 |  | +#   echo "spark原始样本生产执行成功"
 | 
											
												
													
														|  | 
 |  | +#fi
 | 
											
												
													
														|  | 
 |  | +/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
 | 
											
												
													
														|  | 
 |  | +--class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
 | 
											
												
													
														|  | 
 |  | +--master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
 | 
											
												
													
														|  | 
 |  | +../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
 | 
											
												
													
														|  | 
 |  | +tablePart:64 repartition:32 \
 | 
											
												
													
														|  | 
 |  | +beginStr:2024072700 endStr:2024072709 \
 | 
											
												
													
														|  | 
 |  | +savePath:${originDataPath} \
 | 
											
												
													
														|  | 
 |  | +table:${table} &
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
 | 
											
												
													
														|  | 
 |  | +--class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
 | 
											
												
													
														|  | 
 |  | +--master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
 | 
											
												
													
														|  | 
 |  | +../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
 | 
											
												
													
														|  | 
 |  | +tablePart:64 repartition:32 \
 | 
											
												
													
														|  | 
 |  | +beginStr:2024072710 endStr:2024072715 \
 | 
											
												
													
														|  | 
 |  | +savePath:${originDataPath} \
 | 
											
												
													
														|  | 
 |  | +table:${table} &
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
 | 
											
												
													
														|  | 
 |  | +--class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_41_originData_20240709 \
 | 
											
												
													
														|  | 
 |  | +--master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
 | 
											
												
													
														|  | 
 |  | +../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
 | 
											
												
													
														|  | 
 |  | +tablePart:64 repartition:32 \
 | 
											
												
													
														|  | 
 |  | +beginStr:2024072716 endStr:2024072723 \
 | 
											
												
													
														|  | 
 |  | +savePath:${originDataPath} \
 | 
											
												
													
														|  | 
 |  | +table:${table} &
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +wait
 | 
											
												
													
														|  | 
 |  | +if [ $? -ne 0 ]; then
 | 
											
												
													
														|  | 
 |  | +   echo "Spark原始样本生产任务执行失败"
 | 
											
												
													
														|  | 
 |  | +   /root/anaconda3/bin/python monitor_util.py --level error --msg "荐模型数据更新 \n【任务名称】:step1根据${table}生产原始数据\n【是否成功】:error\n【信息】:Spark原始样本生产任务执行失败"
 | 
											
												
													
														|  | 
 |  | +   exit 1
 | 
											
												
													
														|  | 
 |  | +else
 | 
											
												
													
														|  | 
 |  | +   echo "spark原始样本生产执行成功"
 | 
											
												
													
														|  | 
 |  | +fi
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +# 2 特征分桶
 | 
											
												
													
														|  | 
 |  | +echo "$(date +%Y-%m-%d_%H-%M-%S)----------step2------------根据特征分桶生产重打分特征数据"
 | 
											
												
													
														|  | 
 |  | +/opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
 | 
											
												
													
														|  | 
 |  | +--class com.aliyun.odps.spark.examples.makedata_recsys.makedata_recsys_43_bucketData_20240709 \
 | 
											
												
													
														|  | 
 |  | +--master yarn --driver-memory 2G --executor-memory 4G --executor-cores 1 --num-executors 16 \
 | 
											
												
													
														|  | 
 |  | +../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
 | 
											
												
													
														|  | 
 |  | +readPath:${originDataPath} \
 | 
											
												
													
														|  | 
 |  | +savePath:${bucketDataPath} \
 | 
											
												
													
														|  | 
 |  | +beginStr:20240727 endStr:20240727 repartition:500 \
 | 
											
												
													
														|  | 
 |  | +filterNames:XXXXXXXXX \
 | 
											
												
													
														|  | 
 |  | +fileName:20240609_bucket_314.txt \
 | 
											
												
													
														|  | 
 |  | +whatLabel:is_return whatApps:0,4,21,17
 | 
											
												
													
														|  | 
 |  | +if [ $? -ne 0 ]; then
 | 
											
												
													
														|  | 
 |  | +   echo "Spark特征分桶处理任务执行失败"
 | 
											
												
													
														|  | 
 |  | +   /root/anaconda3/bin/python monitor_util.py --level error --msg "荐模型数据更新 \n【任务名称】:step3训练数据产出\n【是否成功】:error\n【信息】:Spark特征分桶处理任务执行失败"
 | 
											
												
													
														|  | 
 |  | +   exit 1
 | 
											
												
													
														|  | 
 |  | +else
 | 
											
												
													
														|  | 
 |  | +   echo "spark特征分桶处理执行成功"
 | 
											
												
													
														|  | 
 |  | +fi
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +echo "$(date +%Y-%m-%d_%H-%M-%S)----------step4------------开始模型训练,增量训练:${MODEL_PATH}/${model_name}_${today_early_3}.txt"
 | 
											
												
													
														|  | 
 |  | +#$HADOOP fs -text ${bucketDataPath}/${begin_early_2_Str}/* | ${FM_HOME}/fm_train -m ${MODEL_PATH}/${model_name}_${begin_early_2_Str}.txt -dim 1,1,8 -im ${LAST_MODEL_HOME}/model_online.txt -core 8
 | 
											
												
													
														|  | 
 |  | +$HADOOP fs -text ${bucketDataPath}/20240727/* | ${FM_HOME}/fm_train -m ${MODEL_PATH}/${model_name}_20240727.txt -dim 1,1,8 -im /root/joe/model_online/model_online.txt -core 8
 | 
											
												
													
														|  | 
 |  | +if [ $? -ne 0 ]; then
 | 
											
												
													
														|  | 
 |  | +   echo "模型训练失败"
 | 
											
												
													
														|  | 
 |  | +   /root/anaconda3/bin/python monitor_util.py --level error --msg "荐模型数据更新 \n【任务名称】:step5模型训练\n【是否成功】:error\n【信息】:${bucketDataPath}/20240727训练失败"
 | 
											
												
													
														|  | 
 |  | +fi
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +echo "$(date +%Y-%m-%d_%H-%M-%S)----------step5------------模型训练完成:${MODEL_PATH}/${model_name}_20240727.txt"
 | 
											
												
													
														|  | 
 |  | +
 |