Chinaunix首页 | 论坛 | 博客
  • 博客访问: 516580
  • 博文数量: 240
  • 博客积分: 791
  • 博客等级: 军士长
  • 技术积分: 1694
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-23 18:21
文章分类

全部博文(240)

文章存档

2013年(21)

2012年(219)

我的朋友

分类:

2012-05-14 09:04:47

原文地址:hadoop 1.0.1 安装 hive 0.8.1 作者:zenir

安装hadoop 1.0.1  http://blog.chinaunix.net/uid-26867092-id-3203519.html

1) 安装hive

点击(此处)折叠或打开

  1. hadoop@hadoop-master:/opt$sudo wget -c
  2. hadoop@hadoop-master:/opt$ sudo tar xvzf hive-0.8.1.tar.gz
  3. hadoop@hadoop-master:/opt$sudo mv hive-0.8.1 /home/hadoop/hadoop-1.0.1/contrib/hive
2)配置环境变量

点击(此处)折叠或打开

  1. hadoop@hadoop-master:/opt$ cat /etc/profile
  2. export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
  3. export HADOOP_HOME=/home/hadoop/hadoop-1.0.1
  4. export ANT_HOME=$HADOOP_HOME/apache-ant-1.7.1
  5. export PATH=$PATH:$HADOOP_HOME/bin:$JAVA_HOME/bin:$HADOOP_HOME/contrib/hive/bin:$ANT_HOME/bin
  6. export HADOOP_HOME_WARN_SUPPRESS=1
3)启动hive

点击(此处)折叠或打开

  1. hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/bin$ hive
  2. hive> show tables;
  3. OK
  4. Time taken:7.032 seconds
执行成功。
4) 安装mysql和mysql操作

点击(此处)折叠或打开

  1. hadoop@hadoop-master:~$ sudo apt-get install mysql-server mysql mysql-client
  2. hadoop@hadoop-master:~$ sudo /etc/init.d/mysqld restart
  3. hadoop@hadoop-master:~$ mysql -uroot -proot
  4. mysql>create database hive;
  5. mysql>grant all on hive.* to hive@localhost identified by '123456';
  6.  
安装Mysql的JDBC驱动包

点击(此处)折叠或打开

  1. hadoop@hadoop-master:~$ sudo wget -c http://downloads.mysql.com/archives/mysql-connector-java-5.0/mysql-connector-java-5.0.8.tar.gz
  2. hadoop@hadoop-master:~$ mv mysql-connector-java-5.0.8.tar.gz /home/hadoop/hadoop-1.0.1/contrib/hive/lib



5) 修改hive配置文件

点击(此处)折叠或打开

  1. hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/conf$ cp hive-default.xml.template hive-defalut.xml
  2. hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/conf$ cp hive-default.xml.template hive-site.xml
#修改hive-site.xml 如下部分

点击(此处)折叠或打开

  1. <property>
  2.   <name>javax.jdo.option.ConnectionURL</name>
  3.   <value>jdbc:mysql://localhost:3306/hive?createDataBaseIfNotExist=True</value>
  4.   <description>JDBC connect string for a JDBC metastore</description>
  5. </property>

  6. <property>
  7.   <name>javax.jdo.option.ConnectionDriverName</name>
  8.   <value>com.mysql.jdbc.Driver</value>
  9.   <description>Driver class name for a JDBC metastore</description>
  10. </property>

  11. <property>
  12.   <name>javax.jdo.option.ConnectionUserName</name>
  13.   <value>hive</value>
  14.   <description>username to use against metastore database</description>
  15. </property>

  16. <property>
  17.   <name>javax.jdo.option.ConnectionPassword</name>
  18.   <value>123456</value>
  19.   <description>password to use against metastore database</description>
  20. </property>
6)启动Hive shell,执行

点击(此处)折叠或打开

  1. hive>show tables;
  2. hive>CREATE TABLE my(id INT,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
  3. show tables;
  4. hive>select name from my;
7)在数据库看到hive下有存在表结构。






阅读(707) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~