安装hadoop 1.0.1 http://blog.chinaunix.net/uid-26867092-id-3203519.html
1) 安装hive
- hadoop@hadoop-master:/opt$sudo wget -c
- hadoop@hadoop-master:/opt$ sudo tar xvzf hive-0.8.1.tar.gz
- hadoop@hadoop-master:/opt$sudo mv hive-0.8.1 /home/hadoop/hadoop-1.0.1/contrib/hive
2)配置环境变量
- hadoop@hadoop-master:/opt$ cat /etc/profile
- export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
- export HADOOP_HOME=/home/hadoop/hadoop-1.0.1
- export ANT_HOME=$HADOOP_HOME/apache-ant-1.7.1
- export PATH=$PATH:$HADOOP_HOME/bin:$JAVA_HOME/bin:$HADOOP_HOME/contrib/hive/bin:$ANT_HOME/bin
- export HADOOP_HOME_WARN_SUPPRESS=1
3)启动hive
- hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/bin$ hive
- hive> show tables;
- OK
- Time taken:7.032 seconds
执行成功。
4) 安装mysql和mysql操作
- hadoop@hadoop-master:~$ sudo apt-get install mysql-server mysql mysql-client
- hadoop@hadoop-master:~$ sudo /etc/init.d/mysqld restart
- hadoop@hadoop-master:~$ mysql -uroot -proot
- mysql>create database hive;
- mysql>grant all on hive.* to hive@localhost identified by '123456';
-
安装Mysql的JDBC驱动包
- hadoop@hadoop-master:~$ sudo wget -c http://downloads.mysql.com/archives/mysql-connector-java-5.0/mysql-connector-java-5.0.8.tar.gz
- hadoop@hadoop-master:~$ mv mysql-connector-java-5.0.8.tar.gz /home/hadoop/hadoop-1.0.1/contrib/hive/lib
5) 修改hive配置文件
- hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/conf$ cp hive-default.xml.template hive-defalut.xml
- hadoop@hadoop-master:~/hadoop-1.0.1/contrib/hive/conf$ cp hive-default.xml.template hive-site.xml
#修改hive-site.xml 如下部分
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://localhost:3306/hive?createDataBaseIfNotExist=True</value>
- <description>JDBC connect string for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver</value>
- <description>Driver class name for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionUserName</name>
- <value>hive</value>
- <description>username to use against metastore database</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionPassword</name>
- <value>123456</value>
- <description>password to use against metastore database</description>
- </property>
6)启动Hive shell,执行
- hive>show tables;
- hive>CREATE TABLE my(id INT,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
- show tables;
- hive>select name from my;
7)在数据库看到hive下有存在表结构。
阅读(1924) | 评论(0) | 转发(1) |