Hive的安装
- 上传安装包 解压
tar zxvf apache-hive-3.1.2-bin.tar.gzmv apache-hive-3.1.2-bin hive
- 解决Hive与Hadoop之间guava版本差异
cd /export/software/hive/rm-rf lib/guava-19.0.jarcpcp /export/software/hadoop/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar /export/software/hive/lib
- 修改配置文件- hive-env.sh
cd /export/software/hive/confmv hive-env.sh.template hive-env.shvim hive-env.shexportHADOOP_HOME=/export/software/hadoop/hadoop-3.3.0exportHIVE_CONF_DIR=/export/software/hive/confexportHIVE_AUX_JARS_PATH=/export/software/hive/lib
- hive-site.xmlvim hive-site.xml``````<configuration><!-- 存储元数据mysql相关配置 --><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://node1:3306/metastore?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8</value></property><property><name>javax.jdo.option.ConnectionDriverName</name><value>com.mysql.jdbc.Driver</value></property><property><name>javax.jdo.option.ConnectionUserName</name><value>root</value></property><property><name>javax.jdo.option.ConnectionPassword</name><value>123456</value></property><!-- H2S运行绑定host --><property><name>hive.server2.thrift.bind.host</name><value>node1</value></property><!-- 远程模式部署metastore metastore地址 --><property><name>hive.metastore.uris</name><value>thrift://node1:9083</value></property><!-- 关闭元数据存储授权 --><property><name>hive.metastore.event.db.notification.api.auth</name><value>false</value></property><!-- Hive 默认在 HDFS 的工作目录 --><property><name>hive.metastore.warehouse.dir</name><value>/user/hive/warehouse</value></property></configuration>
- 上传mysql jdbc驱动到hive安装包lib下
mysql-connector-java-5.1.32.jar
- 初始化元数据
cd /export/software/hivebin/schematool -initSchema-dbType mysql -verbos#初始化成功会在mysql中创建74张表
- 在hdfs创建hive存储目录(如存在则不用操作)
hadoop fs -mkdir /tmphadoop fs -mkdir-p /user/hive/warehousehadoop fs -chmod g+w /tmphadoop fs -chmod g+w /user/hive/warehouse
1)启动 Hive
# 启动metastore服务[root@node1 hive]$ bin/hive --service metastore &[root@node1 hive]$ bin/hive
2)使用 Hive
hive> show databases;
hive> show tables;
hive> create table test(id int);
hive> insert into test values(1);
hive>select * from test;
标签:
hive
本文转载自: https://blog.csdn.net/tonyshi1989/article/details/135190503
版权归原作者 程序喵猴 所有, 如有侵权,请联系我们删除。
版权归原作者 程序喵猴 所有, 如有侵权,请联系我们删除。