1.什么是hive
Hive是基于Hadoop的数据仓库解决方案。由于Hadoop本身在数据存储和计算方面有很好的可扩展性和高容错性,因此使用Hive构建的数据仓库也秉承了这些特性。
简单来说,Hive就是在Hadoop上架了一层SQL接口,可以将SQL翻译成MapReduce去Hadoop上执行,这样就使得数据开发和分析人员很方便的使用SQL来完成海量数据的统计和分析,而不必使用编程语言开发MapReduce那么麻烦。
hive安装之前需要hadoop环境请先安装hadoop
1、下载hive
我这里已经下载好的,可以使用我的。hive对版本兼容性比较高
链接:https://pan.baidu.com/s/1KVCwNhfyx3Wu6g8WsPGKqg
提取码:vo70
下载hive——地址:http://mirror.bit.edu.cn/apache/hive/
1、开始安装
2.1、上传hive到服务器任意位置
2.1、 解压hive文件这里以hive-2.1.0为例子
tar -zxvf apache-hive-2.1.0-bin.tar.gz
2.3、重名了hive文件为hive
mv apache-hive-2.1.1-bin hive
2.4、修改环境变量vi /etc/profile
export HIVE_HOME=/usr/local/java/hive(安装路径)
export PATH=$PATH:$HIVE_HOME/bin
执行source /etc/profile (使文件生效)
执行hive –version
有hive的版本显现,安装成功!
2.5、修改配置文件
切换到hive/conf目录下拷贝 hive-default.xml.template 为 hive-site.xml
修改hive-site.xml 文件
Hive-site.xml文件修改地方比较多,主要是些数据库连接信息(hive存在默认的配置信息,只需要修改即可,如不想拷贝下边内容可以直接把我的hive-site.xml文件拷贝修改即可)
以下需要指定数据连接信息(jdbc:mysql://192.168.2.115:3306/hive //hive数据库事先必须创建好)
javax.jdo.option.ConnectionPassword
root
password to use against metastore database
javax.jdo.option.ConnectionUserName
root
Username to use against metastore database
javax.jdo.option.ConnectionURL
jdbc:mysql://192.168.2.115:3306/hive
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
hive.exec.local.scratchdir
/home/centos/hive
Local scratch space for Hive jobs
hive.downloaded.resources.dir
/home/centos/hive/downloads
Temporary local directory for added resources in the remote file system.
hive.querylog.location
/home/hive/querylog
Location of Hive run time structured log file
hive.server2.logging.operation.log.location
/home/hive/server2_logs
Top level directory where operation logs are stored if logging functionality is enabled
hive.server2.enable.doAs
false
Setting this property to true will have HiveServer2 execute
Hive operations as the user making the calls to it.
2.6、复制mysql的驱动程序到hive/lib下面(这里已经拷贝好了)
切换到hive/bin目录下执行以下命令生成hive元数据
schematool -dbType mysql -initSchema
hive 命令验证是否安装成功
./hive
成功进入hive界面
2.7、hive命令行操作
1.创建hive的数据库
$hive>hive --version
$hive>hive --help
$hive>create database mydb2 ;
$hive>show databases ;
$hive>use mydb2 ;
$hive>create table mydb2.t(id int,name string,age int);
$hive>drop table t ;
$hive>drop table mydb2.t ;
$hive>select * from mydb2.t ; //查看指定库的表
$hive>exit ; //退出
2.8、参考资料
https://www.cnblogs.com/dxxblog/p/8193967.html