hdfs dfs -copyFromLocal file hdfs://path/to/dir/file
hdfs dfs -copyToLocal hdfs://path/to/dir/file file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime as dt | |
| import operator as op | |
| def date_iterator(from_date, days, reverse=False): | |
| func = op.sub if reverse else op.add | |
| return (func(from_date, dt.timedelta(days=d)) for d in range(days)) | |
| def date_range(from_date, to_date, inclusive=True): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # This script will check that both NameNodes are alive in HDFS HA | |
| # configuration and will force failover to the preferred NameNode. | |
| # | |
| # Author: Stas Alekseev <me@salekseev.com> | |
| # | |
| ACTIVE_NAMENODE=nn1 | |
| STANDBY_NAMENODE=nn2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # export HADOOP_OPTS=-Xmx28G | |
| export HADOOP_CLIENT_OPTS="-Xmx2048m" | |
| hadoop distcp -p "hdfs://plat/data/level1/clicks/datehour=2016-12-*" "gs://data-events/data/level1/clicks/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # DELETE A TABLE IN THE HIVE METASTORE | |
| # BE CAREFUL! BACKUP THE DB BEFORE PROCEEDING! | |
| set @table_name = ''; | |
| SELECT @tbl_id := TBl_ID FROM TBLS WHERE TBL_NAME = @table_name; | |
| -- Delete partition key vals | |
| DELETE pvk | |
| FROM PARTITION_KEY_VALS pvk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| example1 = 1118363648 | |
| def numeric_to_ip(ip): | |
| parts = [] | |
| while ip: | |
| parts.append(ip & 255) | |
| ip = ip >> 8 | |
| return '.'.join([str(p) for p in reversed(parts)]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import time | |
| logger = logging.getLogger(__name__) | |
| class NoSuchActivityError(Exception): | |
| pass | |
- Install hadoop to get the required jars (
brew install hadoop) - Create a spark-env.sh (
cp /usr/local/Cellar/apache-spark/1.6.1/libexec/conf/spark-env.sh.template /usr/local/Cellar/apache-spark/1.6.1/libexec/conf/spark-env.sh) - Set HADOOP_CONF_DIR in spark-env.sh (
export HADOOP_CONF_DIR=/usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/) - Add the required jars to the
SPARK_CLASSPATHinspark-env.sh