hive load data script based on date partition

1. Hive loads data script according to date partition

#!/bin/bash
date_list='2018-03-20 2018-03-22';

for date in $date_list
do
     echo "start to hive partition"
     hive -e "ALTER TABLE hive_table_name ADD PARTITION(dt='$date');"
     echo "hive partition finished"
done

2. hive view table partition command

show partitions hive_table_name;

3. Judge the status of hadoop's nameNode in the remote command script, and select the nameNode whose status is active to use

if
  /hadoop/bin/hdfs dfs -ls hdfs://host1:8020/ | grep logs
  then
    echo "host1 status is active"  
  else
    echo "host2 status is active"
    namenodeHost="hdfs://host2:8020/"
fi


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325771808&siteId=291194637