当前位置:   article > 正文

HIVE搭建教程

HIVE搭建教程

一、卸载Centos7自带的mariadb

  1. rpm -qa | grep mariadb
  2. rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
  3. rpm -qa|grep mariadb

二、安装MySQL

  1. # 创建MySQL工作目录
  2. mkdir -p /opt/module/mysql
  3. # 将mysql上传并解压到mysql工作目录下
  4. tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar -C /opt/module/mysql
  5. # 执行安装库
  6. yum -y install libaio
  7. yum install net-tools
  8. # 进行安装mysql
  9. cd /opt/module/mysql
  10. rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm
  11. rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm
  12. rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm
  13. rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpm
  14. # 初始化
  15. mysqld --initialize --user=mysql
  16. #更改所属组
  17. chown mysql:mysql /var/lib/mysql -R
  18. # 启动MySQL
  19. systemctl start mysqld.service
  20. # 查看生成的临时密码
  21. cat /var/log/mysqld.log | tail -n 10
  22. # 进入MySQL
  23. mysql -u root -p
  24. 输入刚才的临时密码
  25. # 更新root密码 设置为123456
  26. alter user user() identified by "123456";
  27. # 授权
  28. use mysql;
  29. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
  30. # 建议设置为开机自启动服务
  31. systemctl enable mysqld
  32. # 设置MySQL远程访问
  33. mysql -uroot -p
  34. use mysql
  35. 查询用户表,查看已有用户的访问权限
  36. select User,authentication_string,Host from user;
  37. # 修改用户远程访问权限
  38. GRANT ALL PRIVILEGES ON * . * TO "root"@"%" IDENTIFIED BY "123456";
  39. # 刷新数据库
  40. flush privileges;

三、安装hive

  1. #安装hive
  2. tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/module/
  3. # 解决Hive与Hadoop之间的guava版本差异
  4. cd /opt/module/apache-hive-3.1.2-bin/
  5. rm -rf lib/guava-19.0.jar
  6. rm -rf lib/log4j-slf4j-impl-2.10.0.jar
  7. # 向下兼容配置
  8. cp /opt/module/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
  9. # 修改配置文件
  10. mv hive-env.sh.template hive-env.sh
  11. vi hive-env.sh
  12. 加到文件最后
  13. export HADOOP_HOME=/opt/module/hadoop3.3.0
  14. export HIVE_CONF_DIR=/opt/module/apache-hive-3.1.2-bin/conf
  15. export HIVE_AUX_JARS_PATH=/opt/module/apache-hive-3.1.2-bin/lib
  16. # 修改hive-site.xml(没有此文件直接新建即可)
  17. vi hive-site.xml
  18. <configuration>
  19. <!-- 存储元数据mysql相关配置 -->
  20. <property>
  21. <name>javax.jdo.option.ConnectionURL</name>
  22. <value>jdbc:mysql://192.168.88.101:3306/hive3?createDatabaseIfNotExist=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8</value>
  23. </property>
  24. <property>
  25. <name>javax.jdo.option.ConnectionDriverName</name>
  26. <value>com.mysql.jdbc.Driver</value>
  27. </property>
  28. <property>
  29. <name>javax.jdo.option.ConnectionUserName</name>
  30. <value>root</value>
  31. </property>
  32. <property>
  33. <name>javax.jdo.option.ConnectionPassword</name>
  34. <value>123456</value>
  35. </property>
  36. <!-- H2S运行绑定host -->
  37. <property>
  38. <name>hive.server2.thrift.bind.host</name>
  39. <value>master</value>
  40. </property>
  41. <!-- 远程模式部署metastore metastore地址 -->
  42. <property>
  43. <name>hive.metastore.uris</name>
  44. <value>thrift://master:9083</value>
  45. </property>
  46. <!-- 关闭元数据存储授权 -->
  47. <property>
  48. <name>hive.metastore.event.db.notification.api.auth</name>
  49. <value>false</value>
  50. </property>
  51. <property>
  52. <name>datanucleus.connectionPoolingType</name>
  53. <value>dbcp</value>
  54. <description>
  55. Expects one of [bonecp, dbcp, hikaricp, none].
  56. Specify connection pool library for datanucleus
  57. </description>
  58. </property>
  59. </configuration>
  60. # 上传mysql的jdbc驱动到hive的安装包lib下
  61. # 初始化数据
  62. cd /opt/module/apache-hive-3.1.2-bin
  63. bin/schematool -initSchema -dbType mysql -verbos
  64. # 在hdfs中创建hive存储目录(如果存在就不需要创建了)
  65. hadoop fs -mkdir /tmp
  66. hadoop fs -mkdir -p /user/hive/warehouse
  67. hadoop fs -chmod g+w /tmp
  68. hadoop fs -chmod g+w /user/hive/warehouse

四、启动hive

  1. # 启动metastore服务
  2. nohup /opt/module/apache-hive-3.1.2-bin/bin/hive --service metastore &
  3. # 启动hiveserver2服务
  4. nohup /opt/module/apache-hive-3.1.2-bin/bin/hive --service hiveserver2 &

五、beeline客户端链接

拷贝master安装包到beeline客户端机器上(任意一个节点即可)

scp -r /opt/module/apache-hive-3.1.2-bin/ root@slave2 /opt/module

测试链接

  1. /opt/module/apache-hive-3.1.2-bin/bin/beeline
  2. beeline> ! connect jdbc:hive2://master:10000
  3. beeline> root
  4. beeline> 直接回车

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

闽ICP备14008679号