Hive - 安装

1 启动集群

start-all.sh

2 hive压缩包解压缩

tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /usr/local/

3 移动到规划位置

mv /usr/local/apache-hive-1.2.1-bin/ /usr/local/hive-1.2.1

4 添加环境变量

[root@hadoop02 ~]# vi /etc/profile

追加内容如下:

export HIVE_HOME=/usr/local/hive-1.2.1
export PATH=$PATH:$HIVE_HOME/bin

5 加载环境变量

source /etc/profile

6 查看hive位置(which命令的作用是,在PATH变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果)

which hive

7 配置

[root@hadoop02 ~]# vi /usr/local/hive-1.2.1/conf/hive-site.xml

内容如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>

<!--指定根目录-->
<property>
   <name>hive.metastore.warehouse.dir</name>
   <value>/user/hive/warehouse</value>
</property>

<!--hive的元数据服务-->
<property>
    <name>hive.metastore.uris</name>
    <value>thrift://hadoop01:9083</value>
</property>

<!--配置mysql的连接字符串-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
</property>

<!--配置mysql的连接驱动-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>

<!--配置登录mysql的用户-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>

<!--配置登录mysql的密码-->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>

</configuration>

8 如果要在其它的服务器安装hive,并访问metastore的server,只需要按照上述步骤安装后,在第7步中,将hive-site.xml配置文件设置为以下内容

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>

<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop01:9083</value>
</property>

<property>
  <name>hive.metastore.local</name>
  <value>false</value>
</property>

<!--hiveserver2的相关属性配置-->
 <property>
    <name>hive.server2.authentication</name>
    <value>NONE</value>
</property>

</configuration>

9 测试

[root@hadoop02 ~]# hive
Logging initialized using configuration in jar:file:/usr/local/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> create table test2(a string, b int);
OK
Time taken: 1.241 seconds
hive> show tables;
OK
test
test2
Time taken: 0.23 seconds, Fetched: 2 row(s)
hive> quit;
[root@hadoop02 ~]# 
发布了544 篇原创文章 · 获赞 289 · 访问量 23万+

猜你喜欢

转载自blog.csdn.net/BlessingXRY/article/details/100628696