一、安装Hadoop
学习Hive首先需要有Hadoop环境,可参考
二、安装Hive
下载
http://mirrors.hust.edu.cn/apache/hive/stable/apache-hive-1.2.2-bin.tar.gz
解压安装
tar zxf /application/apache-hive-1.2.2-bin.tar.gz -C /application/&&ln -s /application/apache-hive-1.2.2-bin /application/hive
配置环境变量
echo -e '##################HIVE环境变量配置#############\nexport HIVE_HOME=/application/hive\nexport PATH=$HIVE_HOME/bin:$PATH' >> /etc/profile&& source /etc/profile&&tail -3 /etc/profile
修改配置文件
cp /application/hive/conf/hive-env.sh.template /application/hive/conf/hive-env.sh
vim /application/hive/conf/hive-site.xml
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.200.9:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<!-- 临时目录配置-->
<property>
<name>hive.querylog.location</name>
<value>/application/hive/tmp</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/application/hive/tmp</value>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/application/hive/tmp</value>
</property>
</configuration>
上面存放元数据使用的是外部mysql,具体可以参考:
请参考:mysql安装
mysql的相关设置:
登录 mysql -uroot -p
set global binlog_format='MIXED';
create database hive;
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'192.168.200.%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
alter database hive character set latin1;
上传mysql驱动mysql-connector-java-5.1.43.jar到/application/hive/lib下。
运行:./bin/hive
启动成功后,mysql的hive库会生成如下表
mysql> show tables;
+--------------------------+
| Tables_in_hive |
+--------------------------+
| CDS |
| DATABASE_PARAMS |
| DBS |
| FUNCS |
| FUNC_RU |
| GLOBAL_PRIVS |
| PARTITIONS |
| PART_COL_STATS |
| ROLES |
| SDS |
| SEQUENCE_TABLE |
| SERDES |
| SKEWED_COL_VALUE_LOC_MAP |
| SKEWED_STRING_LIST |
| TAB_COL_STATS |
| TBLS |
| VERSION
hive会生成一个默认默认数据库(default):
hive> show databases;
OK
default
Time taken: 0.027 seconds, Fetched: 1 row(s)
hive> use default;
OK
Time taken: 0.021 seconds
网友评论