Ubuntu系统下安装并配置hive-2.1.0

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:

 说在前面的话

  默认情况下,Hive元数据保存在内嵌的Derby数据库中,只能允许一个会话连接,只适合简单的测试。实际生产环境中不使用,为了支持多用户会话,

则需要一个独立的元数据库,使用MySQL作为元数据库,Hive内部对MySQL提供了很好的支持。

 

  

 在Ubuntu系统下安装并配置hive详细正确步骤如下!

 

 

一、mysql-server和mysql-client的下载

root@SparkSingleNode:/usr/local#  sudo apt-get install mysql-server  mysql-client (Ubuntu版本)

 

  我这里,root密码,为rootroot。

 

 

 

 

 

二、启动MySQL服务

root@SparkSingleNode:/usr/local# sudo /etc/init.d/mysql start      (Ubuntu版本)     
* Starting MySQL database server mysqld [ OK ] 
root@SparkSingleNode:/usr/local#

 

 附加说明,

sudo /etc/init.d/mysql restart  这是重启

sudo /etc/init.d/mysql stop 这是停止

 

 

三、进入mysql服务

Ubuntu里 的mysql里有个好处,直接自己对root@下的所有,自己默认设置好了

root@SparkSingleNode:/usr/local# mysql -uroot -p
Enter password:   //输入rootroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.53-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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> CREATE USER  'hive'@'%'  IDENTIFIED BY 'hive';

mysql> GRANT ALL PRIVILEGES ON  *.* TO 'hive'@'%' WITH GRANT OPTION;

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> use hive;
Database changed
mysql> select user,host,password from mysql.user;
+------------------+-----------------+-------------------------------------------+
| user | host | password |
+------------------+-----------------+-------------------------------------------+
| root | localhost | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | sparksinglenode | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | 127.0.0.1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | ::1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| debian-sys-maint | localhost | *5DD77395EB71A702D01A6B0FADD8F2C0C88830C5 |
| hive | % | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
+------------------+-----------------+-------------------------------------------+
8 rows in set (0.00 sec)

mysql> exit;
Bye
root@SparkSingleNode:/usr/local#

 

 

 在ubuntu系统里,默认情况下MySQL只允许本地登录,所以需要修改配置文件将地址绑定注释。

sudo gedit /etc/mysql/my.cnf

找到 # bind-address         = 127.0.0.1    注释掉这一行就可以啦

 

重启mysql服务

sudo service mysqld restart

 

然后,建立Hive专用的元数据库,记得用我们刚创建的"hive"账号登录。

  mysql -u hive -p hive

  CREATE DATABASE hive_metadata

 

 四、安装hive

  这里,很简单,不多赘述。

spark@SparkSingleNode:/usr/local/hive$ ll
total 12
drwxr-xr-x 3 spark spark 4096 11月 21 10:39 ./
drwxr-xr-x 15 root root 4096 11月 21 10:25 ../
drwxrwxr-x 9 spark spark 4096 11月 21 10:38 apache-hive-2.1.0-bin/
spark@SparkSingleNode:/usr/local/hive$ mv apache-hive-2.1.0-bin hive-2.1.0
spark@SparkSingleNode:/usr/local/hive$ ls
hive-2.1.0
spark@SparkSingleNode:/usr/local/hive$ cd hive-2.1.0/
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0$ ls
bin examples jdbc LICENSE README.txt scripts
conf hcatalog lib NOTICE RELEASE_NOTES.txt
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0$ cd conf/
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/conf$ ls
beeline-log4j2.properties.template ivysettings.xml
hive-default.xml.template llap-cli-log4j2.properties.template
hive-env.sh.template llap-daemon-log4j2.properties.template
hive-exec-log4j2.properties.template parquet-logging.properties
hive-log4j2.properties.template
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/conf$ cp hive-default.xml.template hive-site.xml
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/conf$

 

 

 五、配置hive

 

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.80.128:3306/hive_metadata?createDatabaseIfNotExist=true</value>
<description>
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
</description>

 

 

<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>

 

 

<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>Username to use against metastore database</description>
</property>

 

 

<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>

 

 

 

spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/conf$ cp hive-env.sh.template hive-env.sh
spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/conf$ vim hive-env.sh

 

 

 

 

spark@SparkSingleNode:/usr/local/hive/hive-2.1.0/bin$ vim hive-config.sh 

export JAVA_HOME=/usr/local/jdk/jdk1.8.0_60
export HIVE_HOME=/usr/local/hive/hive-2.1.0
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.6.0

 

 

 

 vim /etc/profile

#hive
export HIVE_HOME=/usr/local/hive/hive-2.1.0
export PATH=$PATH:$HIVE_HOME/bin

source /etc/profile

 

将mysql-connector-java-***.jar,复制到hive安装目录下的lib下。

 

 

 

 

 

spark@SparkSingleNode:/usr/local/hadoop/hadoop-2.6.0$ sbin/start-all.sh

 

 

 

 

 

 

  一般,上面,就可以足够安装正确了!

 

 

 

 

 

 

 

 

附赠问题

 

 mysql-connector-java-5.1.21-bin.jar换成较高版本的驱动如mysql-connector-java-6.0.3-bin.jar

 

  试过了,不是这个问题。

 

 

 

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> delete from user where User='hive' and Host='%';
Query OK, 1 row affected (0.04 sec)

mysql> delete from user where User='hive' and Host='sparksinglenode';
Query OK, 1 row affected (0.01 sec)

mysql> update user set Host='%' where User='hive' and Host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

 

 

 

mysql> select User,Host,Password from user;
+------------------+-----------------+-------------------------------------------+
| User | Host | Password |
+------------------+-----------------+-------------------------------------------+
| root | localhost | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | sparksinglenode | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | 127.0.0.1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | ::1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| debian-sys-maint | localhost | *5DD77395EB71A702D01A6B0FADD8F2C0C88830C5 |
| hive | % | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
+------------------+-----------------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql>

 

mysql> exit;
Bye
root@SparkSingleNode:/usr/local#‘’

 

 

 

 

root@SparkSingleNode:/usr/local# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.5.53-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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> select user,host,password from mysql.user;
+------------------+-----------------+-------------------------------------------+
| user | host | password |
+------------------+-----------------+-------------------------------------------+
| root | localhost | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | sparksinglenode | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | 127.0.0.1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | ::1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| debian-sys-maint | localhost | *5DD77395EB71A702D01A6B0FADD8F2C0C88830C5 |
| hive | % | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
| hive | localhost | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
| hive | sparksinglenode | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
+------------------+-----------------+-------------------------------------------+
8 rows in set (0.00 sec)

mysql> drop user 'hive'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> drop user 'hive'@'SparkSingleNode';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+------------------+-----------------+-------------------------------------------+
| user | host | password |
+------------------+-----------------+-------------------------------------------+
| root | localhost | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | sparksinglenode | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | 127.0.0.1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| root | ::1 | *6C362347EBEAA7DF44F6D34884615A35095E80EB |
| debian-sys-maint | localhost | *5DD77395EB71A702D01A6B0FADD8F2C0C88830C5 |
| hive | % | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
+------------------+-----------------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql>

 

 

 

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
root@SparkSingleNode:/usr/local#

 

 


本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/6084704.html,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
Ubuntu Windows
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
|
2月前
|
Ubuntu NoSQL 关系型数据库
Ubuntu系统下安装常用软件
Ubuntu系统下安装常用软件
63 0
Ubuntu系统下安装常用软件
|
4月前
|
Ubuntu 安全 网络安全
百度搜索:蓝易云【Ubuntu系统SSH服务端配置】
现在,你已经成功在Ubuntu系统上配置了SSH服务端。这将允许其他计算机通过SSH协议连接到你的Ubuntu系统,并进行远程管理和操作。请注意,远程访问有安全风险,建议在生产环境中采取必要的安全措施来保护系统。
41 3
|
4月前
|
Ubuntu 网络安全
百度搜索:蓝易云【ubuntu系统ufw开放端口教程】
现在,你已经成功在Ubuntu系统中使用ufw开放了指定的端口。请确保只开放必要的端口,并注意网络安全。
108 3
|
4月前
|
存储 Ubuntu
百度搜索:蓝易云【在ubuntu系统下安装配置onedrive步骤】
现在,你已经成功在Ubuntu系统下安装和配置了OneDrive,可以使用该工具与OneDrive云端存储进行同步。
42 0
|
4月前
|
Ubuntu
百度搜索:蓝易云【Ubuntu系统apt添加第三方PPA源教程】
现在,你已经成功在Ubuntu系统中添加了第三方PPA源。系统将会从该源获取更新和软件包。请注意,添加第三方PPA源时要确保其来源可信,以免引入不安全的软件包。
40 5
|
1月前
|
Ubuntu Linux 网络安全
【ubuntu】MobaXtem远程登录ubuntu系统(或虚拟机)
【ubuntu】MobaXtem远程登录ubuntu系统(或虚拟机)
|
7天前
|
Ubuntu 网络协议 搜索推荐
如何在Ubuntu系统上定制文件系统
本文介绍了如何基于全志T507H处理器的OKT507-C开发板上定制Forlinx Desktop(Ubuntu)文件系统。首先,通过解压文件系统并进入OKT507-linux-ubuntu目录。接着,安装QEMU,包括更新下载源和安装相关包。然后,修改配置,如复制DNS配置和修改下载源。挂载文件系统,通过编写ch-mount.sh脚本实现挂载和卸载。安装所需软件,例如使用apt-get安装minicom。最后,打包文件系统,用tar命令压缩并替换旧的文件系统压缩包,重新编译生成新镜像,烧录到开发板。测试方法是通过minicom验证软件是否成功安装。这种定制方式简化了批量生产中的软件安装步骤。
24 3
|
9天前
|
Web App开发 缓存 Ubuntu
Ubuntu系统的基础操作和使用
Ubuntu系统的基础操作和使用
21 2
|
10天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
25 1