时间:2021-07-01 10:21:17 帮助过:27人阅读
下载地址:http://archive.cloudera.com/cdh/3/ 以版本 hive-0.7.1 为例 解压到安装路径: tar -xvf hive-0.7.1.tar.gz 将/conf/hive-env.sh.template 配置环境模板 拷贝一份 cp hive-env.sh.template hive-env.sh 添加以下配置项 #Hadoop 安装路径 HADOOP_HO
下载地址:http://archive.cloudera.com/cdh/3/
以版本 hive-0.7.1 为例
解压到安装路径: tar -xvf hive-0.7.1.tar.gz
将/conf/hive-env.sh.template 配置环境模板 拷贝一份
cp hive-env.sh.template hive-env.sh
添加以下配置项
#Hadoop 安装路径
HADOOP_HOME=/usr/local/hadoop/hadoop-0.20.2
#hive安装路径
export HIVE_HOME=/usr/local/hadoop/hive-0.7.1-cdh3u6
export PATH=$PATH:$HIVE_HOME/bin
#配置Ant LIB 库(启动后台管理服务需要用到)
export ANT_LIB=$ANT_HOME/lib
安装MySQL(略)
安装方法网上很多,这里就不介绍了。
安装完成后,可以使用命令行链接Mysql
mysql -h localhost -u root -p
创建个hive账户
CREATE USER 'hive' IDENTIFIED BY ‘123456‘;
#添加权限
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' WITH GRANT OPTION;
建立Hive专用的元数据库
create database hive
修改hive-site.xml
(如果没有该文件,复制hive-default.xml并改名为hive-site.xml)
javax.jdo.option.ConnectionURL jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true JDBC connect string for a JDBC metastore javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver Driver class name for a JDBC metastore javax.jdo.option.ConnectionUserName hive username to use against metastore database javax.jdo.option.ConnectionPassword 123456 password to use against metastore database
把MySQL的JDBC驱动包(mysql-connector-java-5.1.*-bin.jar)复制到Hive的lib目录下。
启动hive
[root@idc01-vm-test-124 bin]# ./hive
Hive history file=/tmp/root/hive_job_log_root_201404201145_884718504.txt
hive>
show tables;
OK
Time taken: 2.962 seconds
#创建元数据表
hive> create table lss(id int,name string,age int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
OK
Time taken: 0.467 seconds
#查看创建的表
hive> show tables;
OK
lss
#SELECT
hive> select * from lss;
OK
#接下来我们进入MySQL中看下hive库的信息
mysql> use hive;
Database changed
mysql> show tables;
+-----------------+
| Tables_in_hive |
+-----------------+
| BUCKETING_COLS |
| COLUMNS |
| DATABASE_PARAMS |
| DBS |
| PARTITION_KEYS |
| SDS |
| SD_PARAMS |
| SEQUENCE_TABLE |
| SERDES |
| SERDE_PARAMS |
| SORT_COLS |
| TABLE_PARAMS |
| TBLS |
+-----------------+
13 rows in set (0.00 sec)
mysql> select * from TBLS;
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER | RETENTION | SD_ID | TBL_NAME | TBL_TYPE | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| 1 | 1397961996 | 1 | 0 | root | 0 | 1 | kevin | MANAGED_TABLE | NULL | NULL |
| 6 | 1397965611 | 1 | 0 | root | 0 | 6 | lss | MANAGED_TABLE | NULL | NULL |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
2 rows in set (0.00 sec)