1. Set the hive database to be exported by default
VI ~/.hivercUse logbase;2. Create a temporary directory of data
HDFs Dfs-mkdir/tmp/hive-export
3. Generate the Export Data script
hive-e "Show Tables" | awk ' {printf ' export table%s to @/tmp/hive-export/%[email protected];\n ', $1,$1} ' | Sed "s/@/'/g" > export.hql Manually remove the first line (because the first row is tab_name, not the actual table)
4. Manually export data to HDFs
hive-f EXPORT.HQL
5. Download HDFs data to the/tmp/hive-export directory on-premises and delivered to the target Hadoop cluster
HDFs dfs-get/tmp/hive-export/*
HDFs Dfs-put */tmp/hive-export
7. Construct the import statementCP Export.sql Import.sqlsed-i ' s/export table/import table/g ' Import.sql
Reference website:
Https://cwiki.apache.org/confluence/display/Hive/LanguageManual+ImportExport
Hive Data Migration