hive 环境搭建需要hadoop的环境。hadoop环境的搭建不在这里赘述。参考:http://www.cnblogs.com/parkin/p/6952370.html
1.准备阶段
hive 官网下载 :
2.解压缩
tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /home/q/
3.hive 配置
hive-env.sh 配置
cp hive-env.sh.template hive-env.shvi hive-env.sh #添加以下代码 export HADOOP_HOME=/home/q/hadoop-2.6.5 export HIVE_HOME=/home/q/apache-hive-2.1.1-bin
hive-site.xml 配置
cp hive-site.xml.template hive-site.xml vi hive-site.xml #添加以下代码javax.jdo.option.ConnectionURL jdbc:mysql://192.168.251.114:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8 javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver javax.jdo.option.DetachAllOnCommit true detaches all objects from session so that they can be used after transaction is committed javax.jdo.option.NonTransactionalRead true reads outside of transactions javax.jdo.option.ConnectionUserName root javax.jdo.option.ConnectionPassword b6f3g2 javax.jdo.option.Multithreaded true Set this to true if multiple threads access metastore through JDO concurrently. hive.metastore.warehouse.dir /user/hive/warehouse location of default database for the warehouse hive.exec.scratchdir /user/hive/scratch hive.aux.jars.path file:///home/q/apache-hive-2.1.1-bin/auxlib/json-serde-1.3.1-SNAPSHOT-jar-with-dependencies.jar,file:///home/q/apache-hive-2.1.1-bin/auxlib/qunar-udf.jar,file:///home/q/apache-hive-2.1.1-bin/auxlib/brickhouse-0.7.1-SNAPSHOT.jar,file:///home/q/apache-hive-2.1.1-bin/auxlib/joda-time-2.1.jar hbase.zookeeper.quorum localhost hive.exec.dynamic.partition true hive.exec.dynamic.partition.mode nostrict hive.server2.thrift.port 12121 mapred.max.split.size 48000000 mapred.min.split.size.per.node 24000000 mapred.min.split.size.per.rack 24000000 hive.hadoop.supports.splittable.combineinputformat true hive.exec.max.dynamic.partitions.pernode 1000 hive.merge.mapredfiles true hive.merge.smallfiles.avgsize 32000000 hive.hadoop.supports.splittable.combineinputformat true hive.metastore.schema.verification false Enforce metastore schema version consistency. True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures proper metastore schema migration. (Default) False: Warn if the version information stored in metastore doesn't match with one from in Hive jars. hive.server2.long.polling.timeout 5000 Time in milliseconds that HiveServer2 will wait, before responding to asynchronous calls that use long polling
4.metastore 数据库初始化
cd /home/q/apache-hive-2.1.1-bin/bin schematool -dbType mysql -initSchema
5. hive 启动
# CLI 交互式查询 hive 仓库 cd /home/q/apache-hive-2.1.1-bin/bin ./hive
6.hive metastore 服务启动 (主要用于hive client客户端的访问)
cd /home/q/apache-hive-2.1.1-bin/bin hive --service metastore # -p不指定该参数,则默认端口为9083#
7.hiveserver2 服务启动(主要用于rpc方式访问hive数据仓库的表)
cd /home/q/apache-hive-2.1.1-bin/bin./hiveserver2