当前位置:   article > 正文

伪分布Hadoop下安装Hive_装hive的五个mysql安装包下载

装hive的五个mysql安装包下载

一、下载并安装Mysql

(1)下载mysql安装包(mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar)

        下载官网:MySQL :: Download MySQL Community Server (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/community/

(2)上传mysql安装包并解压至/usr/local/

tar -xvf /opt/mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C /usr/local

(3)进入/usr/local/,使用rpm安装mysql解压后的其中5个包(按照以下顺序安装)

  1. rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
  2. rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm 
  3. rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
  4. rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm

(4)启动/关闭Mysql服务器

  1. #启动mysql服务
  2. systemctl start mysqld
  3. #查看mysql服务状态
  4. systemctl status mysqld
  5. #关闭mysql服务
  6. systemctl stop mysqld
  7. #重启mysql服务
  8. service mysqld restart

二、查看Mysql的原始密码并登录进入mysql

(1)查看原始密码

  1. [root@hadoop ~]# cat /var/log/mysqld.log | grep password
  2. 2024-04-20T16:41:01.790879Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9m/O;xQbsfTk

 (2)使用原始密码登录

  1. [root@hadoop ~]# mysql -uroot -p'9m/O;xQbsfTk'
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.26
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>

(3)修改密码为Admin@123456

  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123456';
  2. ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  3. mysql> flush privileges;
  4. Query OK, 0 rows affected (0.00 sec)
  5. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123456';
  6. Query OK, 0 rows affected (0.01 sec)

三、下载并安装Hive

Hive下载官网:Index of /dist/hive (apache.org)icon-default.png?t=N7T8https://archive.apache.org/dist/hive/

MySQL Connector下载地址:

MySQL :: Download MySQL Connector/J (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/c-j/

(1)上传hive安装包到/opt目录,解压至/usr/local/

  1. cd /opt
  2. tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /usr/local/

(2)添加环境变量

  1. #打开系统环境变量配置文件
  2. vim /etc/profile
  3. #刷新一下配置文件
  4. source /etc/profile

(3)解决日志Jar包冲突 

Hive由日志slf4j配置,但是我们yarn也有,两者会冲突。将hive安装目录下的lib目录的日志文件名修改。

  1. cd /usr/local/apache-hive-3.1.2-bin/lib
  2. mv log4j-slf4j-impl-2.10.0.jar log4j-slf4j-impl-2.10.0.jar.bak

四、将Hive元数据配置到MySQL

(1)将MySQL的JDBC驱动拷贝到Hive的lib目录下

MySQL Connector下载地址:

MySQL :: Download MySQL Connector/J (Archived Versions)icon-default.png?t=N7T8https://downloads.mysql.com/archives/c-j/

 (2)配置hive-site.xml

进入hive安装目录下的conf目录:cd /usr/local/apache-hive-3.1.2-bin/conf

在hive/conf目录下新建hive-site.xml文件:vim hive-site.xml 

  1. <configuration>
  2. <property>
  3. <!--Mysql的连接协议-->
  4. <name>javax.jdo.option.ConnectionURL</name>
  5. <value>jdbc:mysql://localhost:3306/metastore?useSSL=true</value>
  6. </property>
  7. <property>
  8. <name>javax.jdo.option.ConnectionDriverName</name>
  9. <value>com.mysql.jdbc.Driver</value>
  10. </property>
  11. <property>
  12. <!--mysql 数据库账号-->
  13. <name>javax.jdo.option.ConnectionUserName</name>
  14. <value>root</value>
  15. </property>
  16. <property>
  17. <!--mysql 数据库密码-->
  18. <name>javax.jdo.option.ConnectionPassword</name>
  19. <value>Admin@123456</value>
  20. </property>
  21. <property>
  22. <!-- Hive 存储路径(hdfs路径)-->
  23. <name>hive.metastore.warehouse.dir</name>
  24. <value>/user/hive/warehouse</value>
  25. </property>
  26. <property>
  27. <!-- Hive 元数据存储版本的验证 -->
  28. <name>hive.metastore.schema.verification</name>
  29. <value>false</value>
  30. </property>
  31. <property>
  32. <!-- Hive jdbc连接端口:10000 -->
  33. <name>hive.server2.thrift.port</name>
  34. <value>10000</value>
  35. </property>
  36. <!-- Hive 连接的主机 -->
  37. <property>
  38. <name>hive.server2.thrift.bind.host</name>
  39. <value>localhost</value>
  40. </property>
  41. <!--元数据存储授权-->
  42. <property>
  43. <name>hive.metastore.event.db.notification.api.auth</name>
  44. <value>false</value>
  45. </property>
  46. <!-- 后两个是配置hive提示显示当前数据库名 -->
  47. <property>
  48. <name>hive.cli.print.header</name>
  49. <value>true</value>
  50. </property>
  51. <property>
  52. <name>hive.cli.print.current.db</name>
  53. <value>true</value>
  54. </property>
  55. <!-- 将hive可以设置成本地模式来执行任务,不然会namenode内存空间不够,jvm不够新job启动导致。 -->
  56. <property>
  57. <name>hive.exec.mode.local.auto</name>
  58. <value>true</value>
  59. </property>
  60. </configuration>

五、启动Hive

        启动Hive之前,一定要先启动Hadoop集群。

(1)初始化客户端(进入mysql,新建Hive元数据库)

  1. [root@hadoop conf]# mysql -uroot -p'Admin@123456'
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 10
  5. Server version: 8.0.26 MySQL Community Server - GPL
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> create database metastore;
  12. Query OK, 1 row affected (0.07 sec)
  13. mysql> exit;
  14. Bye
  15. [root@hadoop conf]#

(2)初始化Mysql服务器 

在启动Hive之前,需要执行schematool -dbType mysql initSchema

(3)启动hive

如果出现以下启动错误:

 解决方案:

查看该jar包在hadoop安装目录和hive的安装目录中的版本信息,将hadopp安装目录下的jar包替换hive安装目录下的jar包。

cd /usr/local/hadoop-3.1.4/share/hadoop/common/lib

cd /usr/local/apache-hive-3.1.2-bin/lib 

启动hive成功的界面(一定要先启动Hadoop集群):

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

闽ICP备14008679号