通过php使用hadoop流执行map reduce

ffx8fchx  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(407)

我有以下脚本:

<?php
$a =isset($_POST['text'])?$_POST['text']:'not yet';
$comm='/usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-*streaming*.jar -mapper "/usr/bin/python /var/www/DataMining/AnalysisByYear/AnalysisByYear_mapper.py '.$a.'" -reducer "/usr/bin/python /var/www/DataMining/AnalysisByYear/AnalysisByYear_reducer.py" -input /user/hduser/dataset/final_eval.txt -output /user/hduser/dataset-outputyear';
$mys=exec($comm);
$comm1='/usr/local/hadoop/bin/hadoop dfs -copyToLocal /user/hduser/dataset-outputyear/part-00000 /var/www/year.txt';
$mys1=exec($comm1);
$file = '/var/www/year.txt';
$contents = file($file); 
$string = implode($contents);
echo $string;
?>

我试图通过php通过shell执行$comm和$comm1命令。但是我没有得到任何结果。请帮忙

0tdrvxhp

0tdrvxhp1#

首先检查apache日志中是否有错误,然后使用hadoop用户运行脚本。

相关问题