分享

Ubuntu下安装eclipse开发环境for Hive(mysql)

一。安装mysql for Hive metadata
  1. $ sudo apt-get install mysql-server
  2. $ mysql -u root -ppassword
  3. $ vi /etc/mysql/my.cnf
  4.    port=3306
  5.     socket=/var/run/mysqld/mysqld.sock
  6.     ...
复制代码
二. Hive的配置


hive-site.xml的编辑:
  1. <configuration>
  2. <property>
  3. <name>hive.metastore.local</name>
  4. <value>true</value>
  5. </property>
  6. <property>
  7. <name>javax.jdo.option.ConnectionDriverName</name>
  8. <value>com.mysql.jdbc.Driver</value>
  9. </property>
  10. <property>
  11. <name>javax.jdo.option.ConnectionURL</name>
  12. <value>jdbc:mysql://localhost:3306/hive01?createDatabaseIfNotExist=true</value>
  13. </property>
  14. <property>
  15. <name>javax.jdo.option.ConnectionUserName</name>
  16. <value>root</value>
  17. </property>
  18. <property>
  19. <name>javax.jdo.option.ConnectionPassword</name>
  20. <value>password</value>
  21. </property>
  22. </configuration>
复制代码
三。 Hadoop的配置
Hadoop的配置采用伪分布式方式(新版的希望采用分为core,hdfs,mapred三个配置文件的方式,我还是用的单个:hadoop-site.xml):
  1. <configuration>
  2. <property>
  3. <name>fs.default.name</name>
  4. <value>hdfs://localhost:9000</value>
  5. </property>
  6. <property>
  7. <name>hadoop.tmp.dir</name>
  8. <value>/home/allen/data</value>
  9. <description>A base for other temporary directories.</description>
  10. </property>
  11. <property>
  12. <name>dfs.replication</name>
  13. <value>1</value>
  14. </property>
  15. <property>
  16. <name>mapred.job.tracker</name>
  17. <value>localhost:9001</value>
  18. </property>
  19. </configuration>
复制代码
尝试start-all.sh
  1. <p><span><span>localhost: ssh: connect to host localhost port 22: Connection refused
  2. </span></span></p><p><span><span>$ sudo apt-get install ssh</span></span></p>
复制代码
搞定
  1. <div>ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa</div><div>cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys</div><div><span>ssh-add   ~/.ssh/id_rsa</span></div>
复制代码
搞定Hive(mysql)+Hadoop!
-----------------------------------------------------下面就是eclipse了---------------------------------------------
四。Eclipse中运行Hive
上来就报找不到java
在eclipse文件夹下新建一个jre/bin/
  1. ln -s $JAVA_HOME/bin/java
复制代码
就ok了。
  1. new peoject,location:/home/allen/Desktop/hive0.7.1
复制代码
从$HADOOP_HOME/拷贝core,test,tools,servlet,jetty等jar到hive0.7.1/lib下,添加进build path。
在build path中删除一些src/jdbc/src/java/...等等不是一级的src path。
将conf文件夹加到classpath:
0_1330937220e3rR.gif


run CliDriver
  1. Hive history file=/tmp/allen/hive_job_log_allen_201203041606_843912565.txt
  2. hive> show tables;
  3. show tables;
  4. FAILED: Error in metadata: org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "org.apache.hadoop.hive.metastore.model.MDatabase" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
  5. NestedThrowables:
  6. org.datanucleus.exceptions.ClassNotPersistableException: The class "org.apache.hadoop.hive.metastore.model.MDatabase" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
  7. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
  8. hive>
复制代码
需要安装DataNucleus for Eclipse 插件,见http://guoyunsky.iteye.com/blog/1178076

1)通过Eclipse安装datanucleus
        Help->Install New Software->Work with输入框里输入网址http://www.datanucleus.org/downloads/eclipse-update/
    2)设置datanucleus
       Window->Preferences->DataNucleus->SchemaTool->
       根据你在hive-default.xml里的配置进行设置Drive Path、Driver Name、Connection URL:




0_133087595464Xi.gif    3)在你到工程上部署datanucleus,也就是hive源码:
      右击Hive源码工程->DataNucleus->Add DataNucleus Support->
      之后再看Hive源码工程的Dataucleus会多几项,Enable Auto-Enhancement

再次运行CliDriver,OK!:
  1. Hive history file=/tmp/allen/hive_job_log_allen_201203041630_1488547381.txt
  2. hive> show tables;
  3. show tables;
  4. OK
  5. Time taken: 3.312 seconds
  6. hive>
复制代码
Debug CliDriver
  1. hive> select * from table02 where id =500000;
  2. select * from table02 where id =500000;
  3. Total MapReduce jobs = 1
  4. Launching Job 1 out of 1
  5. Number of reduce tasks is set to 0 since there's no reduce operator
  6. java.io.IOException: Cannot run program "null/bin/hadoop" (in directory "/home/allen/Desktop/hive-0.7.1"): java.io.IOException: error=2, No such file or directory
  7.         at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
  8.         at java.lang.Runtime.exec(Runtime.java:593)
  9.         at java.lang.Runtime.exec(Runtime.java:431)
  10.         at org.apache.hadoop.hive.ql.exec.MapRedTask.execute(MapRedTask.java:246)
  11.         at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:130)
  12.         at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:57)
  13.         at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1066)
  14.         at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:900)
  15.         at org.apache.hadoop.hive.ql.Driver.run(Driver.java:748)
  16.         at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
  17.         at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:242)
  18.         at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:457)
  19. Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
  20.         at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
  21.         at java.lang.ProcessImpl.start(ProcessImpl.java:65)
  22.         at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
  23.         ... 11 more
复制代码
看打印猜应该跟程序读不到$HADOOP_HOME有关,通过往eclipse配置环境中set变量解决:
0_13309342449G9g.gif






没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条