您好,欢迎访问一九零五行业门户网

安装HIVE

下载地址: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)
其它类似信息

推荐信息