-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun_stats_hadoop.sh
executable file
·77 lines (59 loc) · 2.46 KB
/
run_stats_hadoop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
CRAWL="$1"
if [ -z "$CRAWL" ]; then
echo "Usage: $0 <CRAWL-YEAR-WEEK>"
echo " Argument indicating year and week of crawl (e.g., 2016-40) to be processed required"
exit 1
fi
OUTPUT_COUNT=ccstats/$CRAWL/count/
OUTPUT_STATS=ccstats/$CRAWL/stats/
hadoop fs -mkdir -p ccstats/$CRAWL/
# check that output paths do not exist (jobs will fail otherwise)
if hadoop fs -ls $OUTPUT_COUNT; then
echo "Output path $OUTPUT_COUNT already exists: delete path before running the count job"
exit 1
fi
if hadoop fs -ls $OUTPUT_STATS; then
echo "Output path $OUTPUT_STATS already exists: delete path before running the stats job"
exit 1
fi
set -e
set -x
set -o pipefail
INPUT="s3a://commoncrawl/cc-index/collections/CC-MAIN-$CRAWL/indexes/cdx-*.gz"
HADOOP_USER=${HADOOP_USER:-$USER}
python3 crawlstats.py --job=count \
--no-exact-counts \
-r hadoop \
--jobconf "mapreduce.map.memory.mb=720" \
--jobconf "mapreduce.map.java.opts=-Xmx512m" \
--jobconf "mapreduce.reduce.memory.mb=640" \
--jobconf "mapreduce.reduce.java.opts=-Xmx512m" \
--jobconf "mapreduce.output.fileoutputformat.compress=true" \
--output-dir hdfs:///user/$HADOOP_USER/$OUTPUT_COUNT \
--no-output \
--cleanup NONE \
"$INPUT" \
2>&1 | tee cc-stats.$CRAWL.count.log
#for i in `seq 0 9`; do
# hadoop distcp ccstats/$CRAWL/count/part-0000$i.bz2 s3a://commoncrawl/crawl-analysis/CC-MAIN-$CRAWL/count/part-0000$i.bz2
#done
hadoop fs -rm ccstats/$CRAWL/count/_SUCCESS
hadoop distcp -direct ccstats/$CRAWL/count s3a://commoncrawl/crawl-analysis/CC-MAIN-$CRAWL/count
python3 crawlstats.py --job=stats \
--max-top-hosts-domains=500 \
--min-urls-top-host-domain=100 \
--min-lang-comb-freq=50 \
-r hadoop \
--jobconf "mapreduce.map.memory.mb=1200" \
--jobconf "mapreduce.map.java.opts=-Xmx1024m" \
--jobconf "mapreduce.reduce.memory.mb=1200" \
--jobconf "mapreduce.reduce.java.opts=-Xmx1024m" \
--jobconf "mapreduce.output.fileoutputformat.compress=true" \
--no-output \
--cleanup NONE \
--output-dir hdfs:///user/$HADOOP_USER/$OUTPUT_STATS \
hdfs:///user/$HADOOP_USER/$OUTPUT_COUNT \
2>&1 | tee cc-stats.$CRAWL.stats.log
hadoop fs -mkdir -p s3a://commoncrawl/crawl-analysis/CC-MAIN-$CRAWL/stats/
hadoop fs -cp -d -f ccstats/$CRAWL/stats/part-00000.gz s3a://commoncrawl/crawl-analysis/CC-MAIN-$CRAWL/stats/part-00000.gz