IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> Hive安装 -> 正文阅读

[大数据]Hive安装

???????

目录

1.安装单用户模式

2.安装MySQL

3.文件配置

?4.启动验证


?????????数据仓库工具hive是基于Hadoop集群运行的,在安装hive之前,确保电脑已经启动Hadoop集群。

1.安装单用户模式

????????对hive软件包进行上传解压,重命名后,输入命令启动hive。

[root@master ~]# cd /export/software/
[root@master software]# rz -be

[root@master software]# tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /export/servers/
[root@master software]# cd /export/servers/
[root@master servers]# ls
apache-hive-1.2.1-bin  hadoop-2.6.4  jdk
[root@master servers]# mv apache-hive-1.2.1-bin hive
[root@master servers]# ls
hadoop-2.6.4  hive  jdk
[root@master servers]# cd hive/
[root@master hive]# bin/hive

???????启动hive时,若出现以下错误:

? ? ? ?若启动集群后,NamNode处于安全模式,会造成hive启动不成功,需要关闭安全模式。

?图1-1 NameNode处于安全模式

[root@master hive]# hadoop dfsadmin -safemode leave

? ? ? ?若启动集群后,出现如图1-2所示错误。需要将hive安装目录lib文件下一个jar包复制到Hadoop安装目录下,并需要把原来版本删除。

??图1-2 初始化失败

[root@master hive]# cd /export/servers/hadoop-2.6.4/share/hadoop/yarn/lib/
[root@master lib]# cp /export/servers/hive/lib/jline-2.12.jar .
[root@master lib]# ls
activation-1.1.jar             jaxb-impl-2.2.3-1.jar
aopalliance-1.0.jar            jersey-client-1.9.jar
asm-3.2.jar                    jersey-core-1.9.jar
commons-cli-1.2.jar            jersey-guice-1.9.jar
commons-codec-1.4.jar          jersey-json-1.9.jar
commons-collections-3.2.2.jar  jersey-server-1.9.jar
commons-compress-1.4.1.jar     jettison-1.1.jar
commons-httpclient-3.1.jar     jetty-6.1.26.jar
commons-io-2.4.jar             jetty-util-6.1.26.jar
commons-lang-2.6.jar           jline-0.9.94.jar
commons-logging-1.1.3.jar      jline-2.12.jar
guava-11.0.2.jar               jsr305-1.3.9.jar
guice-3.0.jar                  leveldbjni-all-1.8.jar
guice-servlet-3.0.jar          log4j-1.2.17.jar
jackson-core-asl-1.9.13.jar    netty-3.6.2.Final.jar
jackson-jaxrs-1.9.13.jar       protobuf-java-2.5.0.jar
jackson-mapper-asl-1.9.13.jar  servlet-api-2.5.jar
jackson-xc-1.9.13.jar          stax-api-1.0-2.jar
javax.inject-1.jar             xz-1.0.jar
jaxb-api-2.2.2.jar             zookeeper-3.4.6.jar
[root@master lib]# rm -f jline-0.9.94.jar
[root@master lib]# cd /export/servers/hive/
[root@master hive]# bin/hive

Logging initialized using configuration in jar:file:/export/servers/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> exit;
[root@master hive]# 

?????????出现hive命令行窗口表示单用户模式安装成功。

2.安装MySQL

????????查询Linux系统中数据库软件安装情况。

[root@master hive]# rpm -qa|grep mariadb*
mariadb-libs-5.5.56-2.el7.x86_64
[root@master hive]# yum remove mariadb*
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
--> Finished Dependency Resolution
base/7/x86_64                                        | 3.6 kB     00:00     
extras/7/x86_64                                      | 2.9 kB     00:00     
updates/7/x86_64                                     | 2.9 kB     00:00     

Dependencies Resolved

============================================================================
 Package            Arch         Version              Repository       Size
============================================================================
Removing:
 mariadb-libs       x86_64       1:5.5.56-2.el7       @anaconda       4.4 M
Removing for dependencies:
 postfix            x86_64       2:2.10.1-6.el7       @anaconda        12 M

Transaction Summary
============================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 17 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:postfix-2.10.1-6.el7.x86_64                            1/2 
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                       2/2 
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                       1/2 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                            2/2 

Removed:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                        

Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7                                             

Complete!
[root@master hive]#

? ??????将系统中自带的mariadb软件卸载,卸载过程若出现交互,一律填写"y"。

? ? ? ? 以下代码实现安装MySQL数据库,并将数据库登录权限更改为:root用户在任何主机上使用密码可登录MySQL。

[root@master hive]# sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]
[root@master hive]# yum install mysql mysql-server mysql-devel
[root@master hive]# service mysql start
Redirecting to /bin/systemctl start mysql.service
[root@master hive]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select user,host,password from user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | master    |          |
| root | 127.0.0.1 |          |
| root | ::1       |          |
|      | localhost |          |
|      | master    |          |
+------+-----------+----------+
6 rows in set (0.00 sec)

mysql> update user set host='%' where host='::1';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> delete from user where host='127.0.0.1';
Query OK, 1 row affected (0.00 sec)

mysql> delete from user where host='master';
Query OK, 2 rows affected (0.00 sec)

mysql> delete from user where host='localhost';
Query OK, 2 rows affected (0.00 sec)

mysql> update user set password=password('123456') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select user,host,password from user;
+------+------+-------------------------------------------+
| user | host | password                                  |
+------+------+-------------------------------------------+
| root | %    | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
[root@master hive]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@master hive]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

????????若出现yum 安装不成功情况,可查看主机是否可上网。访问外网不成功,可查看设置静态IP文件是否出错。

3.文件配置

???????hive-env.sh

????????设置hadoop环境变量,作用是无论系统是否配置hadoop环境变量,在hive执行时可通过hive-env.sh加载hadoop环境变量。将以下内容添加到hive-env.sh文件末尾。

????????????????export HADOOP_HOME=/export/servers/hadoop-2.6.4
????????????????export HIVE_CONF_DIR=/export/servers/hive/conf

[root@master ~]# cd /export/servers/hive
[root@master hive]# cd conf/
[root@master conf]# cp hive-env.sh.template hive-env.sh
[root@master conf]# vi hive-env.sh

????????hive-site.xml

?????????conf目录下没有该文件,利用vi新建该文件,并将以下内容粘贴到hive-site.xml文件中。(注意: <value>jdbc:mysql://master:3306/metastore?createDatabaseIfNotExist=true</value>这行内容作用是:在master主机上的Mysql数据库中新建数据库Metastore保存元数据,若你的主机名不是master,需要将“master”改成你的主机名)

<configuration>
????????<!--mysql连接协议以及mysql地址-->
? ?????????<property>?
????????????????<name>javax.jdo.option.ConnectionURL</name>
????????????????<value>jdbc:mysql://master:3306/metastore?createDatabaseIfNotExist=true</value>
????????</property>
????????<!--JDBC连接驱动-->
????????<property>
????????????????<name>javax.jdo.option.ConnectionDriverName</name>
????????????????<value>com.mysql.jdbc.Driver</value>
???????? </property>
????????<!--mysql连接用户名-->
????????<property>
????????????????<name>javax.jdo.option.ConnectionUserName</name>
????????????????<value>root</value>
????????</property>
????????<!--mysql连接密码-->
????????<property>
????????????????<name>javax.jdo.option.ConnectionPassword</name>
????????????????<value>123456</value>
????????</property>
</configuration>

[root@master conf]# vi hive-site.xml

????????上传连接Mysql JDBC驱动jar包。

[root@master conf]# cd ../lib/
[root@master lib]# rz -be

?4.启动验证

? ? ? ?输入对应启动hive命令,成功进入命令行窗口。同时Mysql下出现metastore数据库,表示多用户模式安装成功。

[root@master hive]# bin/hive

Logging initialized using configuration in jar:file:/export/servers/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive>?
[root@master hive]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| metastore          |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

mysql>
  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2021-10-02 14:56:26  更:2021-10-02 14:59:14 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年1日历 -2025/1/18 10:00:39-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码