单独安装hive



使用Derby数据库的安装方式



什么是Derby安装方式



•Apache Derby是一个完全用java编写的数据库,所以可以跨平台,但需要在JVM中运行



•Derby是一个Open source的产品,基于Apache License 2.0分发



•即将元数据存储在Derby数据库中,也是Hive默认的安装方式



 安装Hive



•解压Hive



1. tar zxvf  hive-0.8.1.tar  /home/test/Desktop


•建立软连接



1. ln –s hive-0.8.1 hive


•添加环境变量


1. •export HIVE_HOME=/home/test/Desktop/hive  
2. •export PATH=….HIVE_HOME/bin:$PATH:.


配置Hive



•进入hive/conf目录



•依据hive-env.sh.template,创建hive-env.sh文件



1. cp  hive-env.sh.template hive-env.sh


•修改hive-env.sh



•指定hive配置文件的路径



1. export HIVE_CONF_DIR=/home/test/Desktop/hive/conf


•指定Hadoop路径



1. HADOOP_HOME=/home/test/Desktop/hadoop



hive-site.xml



1. <property>  
2. <name>javax.jdo.option.ConnectionURL</name>  
3. <value>jdbc:derby:;databaseName=metastore_db;create=true</value>  
4. <description>JDBC connect string for a JDBC metastore</description>  
5. </property>  
6.    
7. <property>  
8. <name>javax.jdo.option.ConnectionDriverName</name>  
9. <value>org.apache.derby.jdbc.EmbeddedDriver</value>  
10. <description>Driver class name for a JDBC metastore</description>  
11. </property>  
12. <property>  
13. <name>javax.jdo.option.ConnectionUserName</name>  
14. <value>APP</value>  
15. <description>username to use against metastore database</description>  
16. </property>  
17.    
18. <property>  
19. <name>javax.jdo.option.ConnectionPassword</name>  
20. <value>mine</value>  
21. <description>password to use against metastore database</description>  
22. </property>



启动Hive



•命令行键入



•Hive



•显示



WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.



Logging initialized using configuration in jar:file:/home/test/Desktop/hive-0.8.1/lib/hive-common-0.8.1.jar!/hive-log4j.properties



Hive history file=/tmp/test/hive_job_log_test_201208260529_167273830.txt



hive>



测试语句



•建立测试表test



•create table test  (key string);



•show tables;