博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hive安装 (hive1.2.1+hadoop2.7+mysql)
阅读量:4202 次
发布时间:2019-05-26

本文共 3880 字,大约阅读时间需要 12 分钟。

1. 下载解压
cd /mk/softtar -xvzf apache-hive-1.2.1-bin.tar.gz -C /appl/cd /applmv apache-hive-1.2.1-bin hive-1.2.1
2. 配置环境变量
vi /etc/profileexport HIVE_HOME=/appl/hive-1.2.1export PATH=$PATH:$HIVE_HOME/binexport CLASSPATH=.:$HIVE_HOME/libwqsource /etc/profile
3. 配置Hive
cd /appl/hive-1.2.1/confcp hive-default.xml.template hive-default.xml (不改变)cp hive-default.xml.template hive-site.xml (覆盖hive-default.xml配置项)cp hive-env.sh.template hive-env.sh
cp hive-log4j.properties.template hive-log4j.propertiesvi hive-env.shexport HADOOP_HOME=${HADOOP_HOME}export HIVE_CONF_DIR=${HIVE_HOME}/conf
vi hive-log4j.properties#log4j.appender.EventCounter=org.apache.hadoop.hive.shims.HiveEventCounter#log4j.appender.EventCounter=org.apache.hadoop.metrics.jvm.EventCounterlog4j.appender.EventCounter=org.apache.hadoop.log.metrics.EventCounter
vi hive-site.xml
--------
javax.jdo.option.ConnectionURL
jdbc:mysql://centos1:3306/metastore_hive?createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
javax.jdo.option.ConnectionUserName
hive
username to use against metastore database
javax.jdo.option.ConnectionPassword
hive
password to use against metastore database
hive.metastore.warehouse.dir
/hive/warehouse
location of default database for the warehouse (hdfs path)
hive.metastore.uris
thrift://centos1:9083
hive.server2.authentication
NONE
--------
hadoop fs -mkdir /hivehadoop fs -mkdir /hive/warehousehadoop fs -chmod g+w /hive/warehousehadoop fs -mkdir /hive/tmphadoop fs -chmod g+w /hive/tmp
mysql
mysql -uroot -proot
create database metastore_hive;grant all on metastore_hive.* to hive@'%' identified by 'hive';grant all on metastore_hive.* to hive@localhost identified by 'hive';grant all on metastore_hive.* to hive@centos1 identified by 'hive';ALTER DATABASE metastore_hive CHARACTER SET latin1;show databases;exitmysql -hcentos1 -P3306 -uhive -phiveuse metastore_hiveexit
传mysql-connector-java-5.1.30-bin.jar到/appl/hive-2.1.0/lib/

hadoop 配置(这一步很多参考文章缺少了)

/appl/hadoop-2.7.0/etc/hadoop/hdfs-site.xml

dfs.permissions
false

/appl/hadoop-2.7.0/etc/hadoop/hadoop-env.sh

export HADOOP_CLASSPATH=$CLASSPATH:$HADOOP_CLASSPATH

# 开通端口(centos)
/sbin/iptables -I INPUT -p tcp --dport 9083 -j ACCEPT/sbin/iptables -I INPUT -p tcp --dport 10000 -j ACCEPT/etc/init.d/iptables saveservice iptables restart
5. 启动服务
1、启动metastore服务
hive --service metastore & (默认端口:9083,可-p 9083控制;测试:hive --service metastore)
2、启动hiveserver服务
hive --service hiveserver2 &  (测试:hive --service hiveserver2)
3、访问hiveserver的两种方式
(1) JDBC
Class.forName("org.apache.hive.jdbc.HiveDriver");
DriverManager.getConnection("jdbc:hive2://IP:10000/default","","");
(2) beeline
beeline -u jdbc:hive2://localhost:10000/ -n hive -p hive
beeline
!connect jdbc:hive2://localhost:10000show tables;create table test1 (id int, name string) row format delimited fields terminated by ',' stored as textfile;load data local inpath '/mk/test/test1.txt' into table test1;select * from test1;!quit
查看hive文件
hadoop fs -ls /hive/warehouse/test1
停止:因为不是通过服务启动,只能ps -ef|grep hive,再kill <pid>
参考
http://blog.csdn.net/an342647823/article/details/46048403
http://blog.fens.me/hadoop-hive-intro/
http://blog.csdn.net/jiangkai_nju/article/details/7292313
http://blog.csdn.net/reesun/article/details/8556078
http://www.micmiu.com/bigdata/hive/hive-metastore-config/
http://blog.csdn.net/stark_summer/article/details/45844403
你可能感兴趣的文章
技术人如何加速成长?提升你的思维和学习方式
查看>>
CentOS下载及安装
查看>>
juju
查看>>
MySQL下载及安装
查看>>
数据清洗
查看>>
Pentaho Data Integration(or Kettle)
查看>>
Nginx问题记录
查看>>
SAP简介
查看>>
Windows系统常用配置
查看>>
通用后台生产框架汇总
查看>>
MySQL 8
查看>>
Redis简介
查看>>
技术管理
查看>>
高并发
查看>>
MySQL常用设置
查看>>
Linux 运维常用网络命令
查看>>
JavaEE常用框架汇总
查看>>
分布式数据库汇总
查看>>
Vim 命令
查看>>
Flink
查看>>