IT评测·应用市场-qidao123.com

标题: hive-3.1.3部署文档 [打印本页]

作者: 南飓风    时间: 2024-11-13 05:12
标题: hive-3.1.3部署文档
提前预备

2、本地模式

2.1、安装数据库——mysql(和mariadb任选一个即可)

1、安装mysql 5.7.18
2、上传mysql的rpm安装包
mysql-community-client-5.7.18-1.el6.x86_64.rpm
mysql-community-libs-5.7.18-1.el6.x86_64.rpm
mysql-community-common-5.7.18-1.el6.x86_64.rpm
mysql-community-server-5.7.18-1.el6.x86_64.rpm
mysql-connector-java-5.1.32-bin.jar
3、到上传目录下执行
rpm -ivh mysql-community-*
报错如下
必要执行如下命令
yum remove mariadb-libs
yum -y install net-tools
  1. [root@master mysql]# ls
  2. mysql-community-client-5.7.18-1.el6.x86_64.rpm  mysql-community-libs-5.7.18-1.el6.x86_64.rpm    mysql-connector-java-5.1.32-bin.jar
  3. mysql-community-common-5.7.18-1.el6.x86_64.rpm  mysql-community-server-5.7.18-1.el6.x86_64.rpm
  4. [root@master mysql]# pwd
  5. /root/mysql
  6. [root@master mysql]# rpm -ivh mysql-community-*
  7. 警告:mysql-community-client-5.7.18-1.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
  8. 错误:依赖检测失败:
  9.         mariadb-libs 被 mysql-community-libs-5.7.18-1.el6.x86_64 取代
  10.         net-tools 被 mysql-community-server-5.7.18-1.el6.x86_64 需要
  11. [root@master mysql]# mount /dev/sr0 /media/
  12. mount: /dev/sr0 写保护,将以只读方式挂载
  13. [root@master mysql]# yum remove mariadb-libs
  14. 已加载插件:fastestmirror
  15. 正在解决依赖关系
  16. --> 正在检查事务
  17. ---> 软件包 mariadb-libs.x86_64.1.5.5.68-1.el7 将被 删除
  18. --> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
  19. --> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
  20. --> 正在检查事务
  21. ---> 软件包 postfix.x86_64.2.2.10.1-9.el7 将被 删除
  22. --> 解决依赖关系完成
  23. 依赖关系解决
  24. ==============================================================================================================================================================================================================
  25. Package                                            架构                                         版本                                                   源                                               大小
  26. ==============================================================================================================================================================================================================
  27. 正在删除:
  28. mariadb-libs                                       x86_64                                       1:5.5.68-1.el7                                         @anaconda                                       4.4 M
  29. 为依赖而移除:
  30. postfix                                            x86_64                                       2:2.10.1-9.el7                                         @anaconda                                        12 M
  31. 事务概要
  32. ==============================================================================================================================================================================================================
  33. 移除  1 软件包 (+1 依赖软件包)
  34. 安装大小:17 M
  35. 是否继续?[y/N]:y
  36. Downloading packages:
  37. Running transaction check
  38. Running transaction test
  39. Transaction test succeeded
  40. Running transaction
  41.   正在删除    : 2:postfix-2.10.1-9.el7.x86_64                                                                                                                                                             1/2
  42.   正在删除    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                                        2/2
  43.   验证中      : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                                        1/2
  44.   验证中      : 2:postfix-2.10.1-9.el7.x86_64                                                                                                                                                             2/2
  45. 删除:
  46.   mariadb-libs.x86_64 1:5.5.68-1.el7
  47. 作为依赖被删除:
  48.   postfix.x86_64 2:2.10.1-9.el7
  49. 完毕!
  50. [root@master yum.repos.d]# yum -y install  net-tools
  51. 已加载插件:fastestmirror
  52. Loading mirror speeds from cached hostfile
  53. 正在解决依赖关系
  54. --> 正在检查事务
  55. ---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
  56. --> 解决依赖关系完成
  57. 依赖关系解决
  58. ==============================================================================================================================================================================================================
  59. Package                                        架构                                        版本                                                          源                                             大小
  60. ==============================================================================================================================================================================================================
  61. 正在安装:
  62. net-tools                                      x86_64                                      2.0-0.25.20131004git.el7                                      c7-media                                      306 k
  63. 事务概要
  64. ==============================================================================================================================================================================================================
  65. 安装  1 软件包
  66. 总下载量:306 k
  67. 安装大小:917 k
  68. Downloading packages:
  69. Running transaction check
  70. Running transaction test
  71. Transaction test succeeded
  72. Running transaction
  73.   正在安装    : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                 1/1
  74.   验证中      : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                 1/1
  75. 已安装:
  76.   net-tools.x86_64 0:2.0-0.25.20131004git.el7
  77. 完毕!
  78. [root@master mysql]# rpm -ivh mysql-community-*
  79. 警告:mysql-community-client-5.7.18-1.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
  80. 准备中...                          ################################# [100%]
  81. 正在升级/安装...
  82.    1:mysql-community-common-5.7.18-1.e################################# [ 25%]
  83.    2:mysql-community-libs-5.7.18-1.el6################################# [ 50%]
  84.    3:mysql-community-client-5.7.18-1.e################################# [ 75%]
  85.    4:mysql-community-server-5.7.18-1.e^[a################################# [100%]
  86. [root@master mysql]#
复制代码
 4、启动数据库
  1. #启动数据库
  2. [root@master mysql]# systemctl start mysqld
  3. #查看数据库初始化密码
  4. [root@master mysql]# cat /var/log/mysqld.log |grep root
  5. 2024-10-28T09:30:24.600045Z 1 [Note] A temporary password is generated for root@localhost: g;jryD7tVd*w
  6. #登录mysql数据库
  7. [root@master mysql]# mysql -uroot -p'g;jryD7tVd*w'
  8. mysql: [Warning] Using a password on the command line interface can be insecure.
  9. Welcome to the MySQL monitor.  Commands end with ; or \g.
  10. Your MySQL connection id is 5
  11. Server version: 5.7.18
  12. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  13. Oracle is a registered trademark of Oracle Corporation and/or its
  14. affiliates. Other names may be trademarks of their respective
  15. owners.
  16. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  17. #修改初始化密码(必须符合指定的复杂程度规则)
  18. mysql> alter user 'root'@'localhost' identified by 'Class_123';
  19. Query OK, 0 rows affected (0.00 sec)
  20. #调整密码规则等级为0
  21. mysql> set global validate_password_policy=0;
  22. Query OK, 0 rows affected (0.00 sec)
  23. #调整密码长度
  24. mysql> set global validate_password_length=6;
  25. Query OK, 0 rows affected (0.00 sec)
  26. #设置新的密码
  27. mysql> set password for 'root'@'localhost'=password('123456');
  28. Query OK, 0 rows affected, 1 warning (0.01 sec)
  29. #赋权root用户可以远程登陆
  30. mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
  31. Query OK, 0 rows affected, 1 warning (0.00 sec)
  32. #刷新权限
  33. mysql> flush privileges;
  34. Query OK, 0 rows affected (0.00 sec)
  35. mysql> exit
  36. Bye
  37. [root@master mysql]#
复制代码
2.2、安装数据库——mariadb(和mysql任选一个即可)

yum -y install mariadb-server mysql-connector-java
 增长mysql的jar包
  1. cp /usr/share/java/mysql-connector-java.jar /opt/hive/lib/
复制代码
2.3、配置hive情况

1. 上传hive安装包、解压到指定位置
  1. [root@master ~]# tar xf apache-hive-3.1.3-bin.tar.gz -C /opt/
  2. [root@master ~]# cd /opt/
  3. [root@master ~]# mv apache-hive-3.1.3-bin hive
复制代码
 2. 配置情况变量
vi /etc/profile
  1. export HIVE_HOME=/opt/hive
  2. export PATH=$PATH:$HIVE_HOME/bin
复制代码
source /etc/profile 
 3. 修改hive配置
vi /opt/hive/conf/hive-site.xml
  1. <configuration>
  2.   <property>
  3.     <name>hive.metastore.warehouse.dir</name>
  4.     <value>/user/hive/warehouse</value>
  5.   </property>
  6.   <property>
  7.     <name>javax.jdo.option.ConnectionURL</name>
  8.     <value>jdbc:mysql://192.168.128.130:3306/hive?createDatabaseIfNotExist=true</value>
  9.   </property>
  10.   <property>
  11.     <name>javax.jdo.option.ConnectionDriverName</name>
  12.     <value>com.mysql.jdbc.Driver</value>
  13.   </property>
  14.   <property>
  15.     <name>javax.jdo.option.ConnectionUserName</name>
  16.     <value>root</value>
  17.   </property>
  18.   <property>
  19.     <name>javax.jdo.option.ConnectionPassword</name>
  20.     <value>123456</value>
  21.   </property>
  22.   <property>
  23.     <name>datanucleus.schema.autoCreateAll</name>
  24.     <value>true</value>
  25.   </property>
  26.   <property>
  27.     <name>hive.metastore.schema.verification</name>
  28.     <value>false</value>
  29.   </property>
  30. </configuration>
复制代码
 4. 增长mysql的jar包
使用mysql的jar包
  1. cp mysql-connector-java-5.1.32-bin.jar /opt/hive/lib/
复制代码
使用mariadb的jar包
  1. cp /usr/share/java/mysql-connector-java.jar /opt/hive/lib/
复制代码
5. 初始化元数据库
  1. [root@master conf]# schematool -dbType mysql -initSchema
  2. Metastore connection URL:        jdbc:mysql://192.168.128.130:3306/hive?createDatabaseIfNotExist=true
  3. Metastore Connection Driver :    com.mysql.jdbc.Driver
  4. Metastore connection User:       root
  5. Starting metastore schema initialization to 3.1.0
  6. Initialization script hive-schema-3.1.0.mysql.sql
  7. Initialization script completed
  8. schemaTool completed
复制代码
 2.4、登录验证

  1. [root@master conf]# hive
  2. which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/jdk1.8.0_112/bin:/usr/local/hadoop-3.3.6/bin:/usr/local/hadoop-3.3.6/sbin:/opt/hive/bin:/root/bin)
  3. Hive Session ID = d4f5afa7-fc5d-4985-9889-a2aa8842d1ae
  4. Logging initialized using configuration in jar:file:/opt/hive/lib/hive-common-3.1.3.jar!/hive-log4j2.properties Async: true
  5. Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
  6. Hive Session ID = 440763e5-41d1-4d8e-8c70-aa007f51c429
  7. hive> show databases;
  8. OK
  9. default
  10. Time taken: 1.63 seconds, Fetched: 1 row(s)
  11. hive> create database test1;
  12. OK
  13. Time taken: 0.193 seconds
  14. hive> show databases;
  15. OK
  16. default
  17. test1
  18. Time taken: 0.05 seconds, Fetched: 2 row(s)
  19. hive>
复制代码
3、远程模式访问

我要在192.168.128.131上远程访问上述的192.168.128.130服务器上的hive服务。
3.1、130节点上必要的操作

  1. [root@master conf]# hive --service metastore
  2. 2024-10-28 21:10:55: Starting Hive Metastore Server
  3. ##如果想后台运行可以写成如下命令
  4. hive --service metastore &
复制代码
3.2、131上必要配置

1. 上传hive安装包、解压到指定位置
  1. [root@master ~]# tar xf apache-hive-3.1.3-bin.tar.gz -C /opt/apps
  2. [root@master ~]# cd /opt/apache-hive-3.1.3-bin
  3. [root@master ~]# mv apache-hive-3.1.3-bin hive
复制代码
 2. 配置情况变量
vi /etc/profile
  1. export HIVE_HOME=/opt/hive
  2. export PATH=$PATH:$HIVE_HOME/bin
复制代码
source /etc/profile 
 3. 修改hive配置
vi /opt/hive/conf/hive-site.xml
  1. <configuration>
  2.   <property>
  3.     <name>hive.metastore.warehouse.dir</name>
  4.     <value>/user/hive/warehouse</value>
  5.   </property>
  6.   <property>
  7.     <name>hive.metastore.uris</name>
  8.     <value>thrift://192.168.128.130:9083</value>
  9.   </property>
  10. </configuration>
复制代码
4. 毗连hive
  1. [root@zhangsan opt]# hive
  2. which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/jdk1.8.0_112/bin:/usr/local/hadoop-3.3.6/bin:/usr/local/hadoop-3.3.6/sbin:/opt/hive/bin:/root/bin)
  3. Hive Session ID = 636bdaf9-c925-4a7f-9c4c-87e298982598
  4. Logging initialized using configuration in jar:file:/opt/hive/lib/hive-common-3.1.3.jar!/hive-log4j2.properties Async: true
  5. Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
  6. Hive Session ID = f52e0b08-66cb-4026-b07e-4bf016129df3
  7. hive> show databases;
  8. OK
  9. default
  10. test1
  11. Time taken: 0.941 seconds, Fetched: 2 row(s)
  12. hive>
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4