1. 不同集群直接hive迁移
由于集群里设置了dfs.permissions=true 的 因此hdfs上的文件访问须hdfs用户才可以操作 被迁移的集群是hadoop用户,因此先对现有的目录设在acl权限访问/hive
① 新集群操作
导数据之先把另一个集群的hadoop用户授予本集群的hdfs访问权限。
hdfs dfs -setfacl -R -muser:hadoop:rwx /hive
② 原有集群里面执行
hadoop@hdp01:~$ hadoopdistcp /hive/warehouse/proc.db/drug_info_result3.txthdfs://10.3.14.24:8020/hive/warehouse/proc.db/
③ 新集群操作给hdfs目录授权
hdfs dfs -chown -R hdfs /hive
hdfs@bigdata:/root$hdfs dfs -ls -R /hive
drwxrwxr-x+ - hdfs supergroup 0 2018-07-11 16:52 /hive/warehouse
drwxrwxr-x+ - hdfs supergroup 0 2018-07-11 16:52/hive/warehouse/process.db
hdfs@bigdata-148024:/root$ hive
创建表注意指到路径即可
DROP TABLE IF EXISTS product.dim_drug_info;
CREATE EXTERNAL TABLE IF NOT EXISTS product.dim_drug_info
(
id string,
item_name string,
standard_code string,
approval_date string
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE
LOCATION '/hive/warehouse/proc.db/dim_drug_info';
④ 加载数据到表里
hive> load datainpath '/hive/warehouse/proc.db/drug_info_result3.txt' intotable product.dim_drug_info;
Loading data to tableproducttest.dim_drug_info
Tableproducttest.dim_drug_info stats: [numFiles=1, numRows=0, totalSize=31552921,rawDataSize=0]
OK
Time taken: 0.619seconds
hive> select * from dim_drug_info limit 10;
hdfs@bigdata:/root$hdfs dfs -ls -R /hive
drwxrwxr-x+ - hdfs supergroup 0 2018-07-11 16:52 /hive/warehouse
drwxrwxr-x+ - hdfs supergroup 0 2018-07-11 16:52/hive/warehouse/process.db
drwxrwxr-x+ - hdfs supergroup 0 2018-07-11 16:56/hive/warehouse/process.db/dim_drug_info
hdfs@bigdata-148024:/root$ hive