当前位置:   article > 正文

Hive安装(图文并茂)_hive宝塔

hive宝塔

环境

阿里云ECS服务器

hadoop-2.7.2

apache-hive-1.2.1

注意、注意、注意:我的hive软件装在  /opt/module/  下,注意一下下面代码执行的目录

前提

请记住快照一下,无论文章写的在差,也有人点赞,无论文章写的在好,也还是有人看不懂,如果您没有搭建起来,也不至于毁你的环境

请记住快照一下,无论文章写的在差,也有人点赞,无论文章写的在好,也还是有人看不懂,如果您没有搭建起来,也不至于毁你的环境

请记住快照一下,无论文章写的在差,也有人点赞,无论文章写的在好,也还是有人看不懂,如果您没有搭建起来,也不至于毁你的环境

hadoop安装成功并且运行起来,yarn必须启动起来

怎么搭建hadoop环境?

ECS服务器搭建hadoop伪分布式_CBeann的博客-CSDN博客_宝塔部署hadoop

apache-hive-1.2.1-bin.tar.gz下载

链接:https://pan.baidu.com/s/1l6t2a3xL2f09GXfKOVJyng 
提取码:adsw 
复制这段内容后打开百度网盘手机App,操作更方便哦

安装步骤

将Hive的压缩包上传到Linux系统中的/opt/software中

将Hive的压缩包解压到/opt/module中

tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /opt/module/

进入 /opt/module中,并且将解压的的文件名称改为hive(方便后面写名字)

  1. [root@iZm5ea99qngm2v98asii1aZ module]# cd /opt/module/
  2. [root@iZm5ea99qngm2v98asii1aZ module]# ls
  3. apache-hive-1.2.1-bin hadoop-2.7.2
  4. [root@iZm5ea99qngm2v98asii1aZ module]# mv apache-hive-1.2.1-bin/ hive
  5. [root@iZm5ea99qngm2v98asii1aZ module]# ls
  6. hadoop-2.7.2 hive
  7. [root@iZm5ea99qngm2v98asii1aZ module]#

修改 /exc/profile 文件,配置Hive的环境变量

  1. #HIVE_HOME
  2. export HIVE_HOME=/opt/module/hive
  3. export PATH=$PATH:$HIVE_HOME/bin

修改前

修改后

使配置文件生效

 source /etc/profile

在hive中配置hadoop的HADOOP_HOME和HIVE_CONF_DIR

进入/opt/module/hive/conf  目录

将 hive-env.sh.template 复制一份 并且命名为 hive-env.sh

修改hive-env.sh文件

其中 HADOOP_HOME的获取方式为

HIVE_CONF_DIR的值为修改的这个文件的目录

修改前

修改后

在HDFS上创建几个Hive规定的文件

  1. hadoop fs -mkdir /tmp
  2. hadoop fs -mkdir -p /user/hive/warehouse
  3. hadoop fs -chmod g+w /tmp
  4. hadoop fs -chmod g+w /user/hive/warehouse

启动Hive

进入/opt/module/hive/ 目录下

 cd /opt/module/hive/

启动hive

 bin/hive

退出hive(后面带分号)

quit;

Hive安装MySQL服务:将hive的数据存储到MySQL中,将hive和MySQL结合起来

安装MySQL

安装方式一:

https://blog.csdn.net/qq_37171353/article/details/80040662

安装方式二:

用宝塔界面   宝塔面板 - 简单好用的Linux/Windows服务器运维管理面板

ECS服务器搭建hadoop伪分布式_CBeann的博客-CSDN博客_宝塔部署hadoop          里面有怎么安装宝塔界面

步骤一:安装宝塔界面,注意看里面最后生成的用户名、密码、URL

步骤二:和手机应用宝一样安装MySQL

配置MySQL无主机登录

目的

解决在别的电脑上也能能连接到服务器MySQL

解决办法

grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;

这样你就可以在任何机器上输入正确的ip,用户名,密码就可以访问数据库了,前提其他都没有问题(mysql服务开启,端口开放等等)

修改hive的配置文件

  • 在/opt/module/hive/conf目录下创建一个hive-site.xml

在hive-site.xml添加下面信息

其中需要修改三处信息:jdbcURL,MySQL的用户名、密码

  1. <value>jdbc:mysql://127.0.0.1:3306/metastore?createDatabaseIfNotExist=true</value>
  2. <value>root</value>
  3. <value>000000</value>
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <configuration>
  4. <property>
  5. <name>javax.jdo.option.ConnectionURL</name>
  6. <value>jdbc:mysql://127.0.0.1:3306/metastore?createDatabaseIfNotExist=true</value>
  7. <description>JDBC connect string for a JDBC metastore</description>
  8. </property>
  9. <property>
  10. <name>javax.jdo.option.ConnectionDriverName</name>
  11. <value>com.mysql.jdbc.Driver</value>
  12. <description>Driver class name for a JDBC metastore</description>
  13. </property>
  14. <property>
  15. <name>javax.jdo.option.ConnectionUserName</name>
  16. <value>root</value>
  17. <description>username to use against metastore database</description>
  18. </property>
  19. <property>
  20. <name>javax.jdo.option.ConnectionPassword</name>
  21. <value>000000</value>
  22. <description>password to use against metastore database</description>
  23. </property>
  24. <property>
  25. <name>hive.cli.print.header</name>
  26. <value>true</value>
  27. </property>
  28. <property>
  29. <name>hive.cli.print.current.db</name>
  30. <value>true</value>
  31. </property>
  32. </configuration>

上传MySQL驱动(mysql-connector-java-5.1.27-bin.jar)

将mysql-connector-java-5.1.27-bin上传到     ( /opt/module/hive/lib)  下

mysql-connector-java-5.1.27-bin.jar下载链接

链接:https://pan.baidu.com/s/1-qfK3nwrm07tg6zVKk1Vrw 
提取码:737r 
复制这段内容后打开百度网盘手机App,操作更方便哦

初始化schematool(敲黑板)

schematool -dbType mysql -initSchema

否则会报下面的错误

hive配置远程仓库异常:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStor_TRX的博客-CSDN博客

  1. Logging initialized using configuration in jar:file:/bigdata/hive/apache-hive-1.2.1-bin/lib/hive-common-1.2.1.jar!/hive-log4j.properties
  2. Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
  3. at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
  4. at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
  5. at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
  6. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  7. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  8. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  9. at java.lang.reflect.Method.invoke(Method.java:498)
  10. at org.apache.hadoop.util.RunJar.run(RunJar.java:239)
  11. at org.apache.hadoop.util.RunJar.main(RunJar.java:153)
  12. Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
  13. at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1523)
  14. at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:86)
  15. at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:132)
  16. at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:104)
  17. at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3005)
  18. at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3024)
  19. at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:503)
  20. ... 8 more
  21. Caused by: java.lang.reflect.InvocationTargetException
  22. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  23. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  24. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  25. at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  26. at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1521)
  27. ... 14 more
  28. Caused by: javax.jdo.JDOException: Exception thrown calling table.exists() for hive.`SEQUENCE_TABLE`
  29. NestedThrowables:
  30. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
  31. at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:596)
  32. at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:732)
  33. at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
  34. at org.apache.hadoop.hive.metastore.ObjectStore.setMetaStoreSchemaVersion(ObjectStore.java:6773)
  35. at org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:6670)
  36. at org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:6645)
  37. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  38. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  39. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  40. at java.lang.reflect.Method.invoke(Method.java:498)
  41. at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:114)
  42. at com.sun.proxy.$Proxy6.verifySchema(Unknown Source)
  43. at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:572)
  44. at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:624)
  45. at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:461)
  46. at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:66)
  47. at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:72)
  48. at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:5762)
  49. at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:199)
  50. at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.<init>(SessionHiveMetaStoreClient.java:74)

大功告成

启动hive

hive运行日志信息配置

在  (/opt/module/hive/conf) 里有         hive-log4j.properties.template  复制一份并且重命名为hive-log4j.properties

修改hive-log4j.properties文件

修改前

修改后

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/539750
推荐阅读
相关标签
  

闽ICP备14008679号