hive 命令

Last updated on November 20, 2024 am

🧙 Questions

☄️Ideas

重启hive服务

  1. 查找hive进程
sudo netstat -ntpl | grep 30121
  • 查找hive2服务进程
ps -aux|grep org.apache.hive.service.server.HiveServer2
  • 查找metastore服务进程
ps -aux|grep org.apache.hadoop.hive.metastore.HiveMetaStore
  1. 杀死进程
sudo kill -9 ${hive2ServicePid}
sudo kill -9 ${metaStoreServicePid}
  1. 重新启动hive服务
mkdir /data/apache-hive-3.1.2-bin/logs
nohup hive --service metastore >> /data/apache-hive-3.1.2-bin/logs/metastore.log 2>&1 &      
nohup hive --service hiveserver2 >> /data/apache-hive-3.1.2-bin/logs/hiveserver2.log 2>&1 &

初始化hive数据源

schematool -dbType mysql -initSchema

**Note:**需要下载对应的数据库驱动 且驱动文件不可重复

wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.22.tar.gz
tar -vzxf mysql-connector-java-8.0.22.tar.gz 
sudo cp mysql-connector-java-8.0.22/mysql-connector-java-8.0.22.jar /opt/flink/lib/
解析表
analyze table user_consumption_summary compute statistics

导出csv文件

Note:
默认都会用 /t 导出数据

set hive.cli.print.header=false 取消头
s/[\t]/,/g 将 \t转为,逗号

hive -e 'set set hive.cli.print.header=false; select * from cdh_dev.jac_contract_item' | sed 's/[\\t]/,/g' >  ./jac_contract_item.csv;
hive -e 'set set hive.cli.print.header=false; select * from cdh_dev.partmaster limit 160000' >  ./partmaster.csv;
# 查看版本号
hive
version
cat /opt/cloudera/parcels/CDH/lib/hive/lib

hive 命令
https://ispong.isxcode.com/hadoop/hive/hive 命令/
Author
ispong
Posted on
December 16, 2020
Licensed under