(二)Hive在hadoop环境下搭建

2020-09-20 19:46:41 浏览数 (1)

5,安装Hive

上传解压

cd /opt/bdp/

rz

tar -zxvf apache-hive-1.2.1-bin.tar.gz

rm -rf pache-hive-1.2.1-bin.tar.gz

配置文件

vim/opt/bdp/apache-hive-1.2.1-bin/conf/hive-site.xml

<?xmlversion="1.0"?>

<?xml-stylesheettype="text/xsl" href="configuration.xsl"?>

<configuration>

<!--元数据管理-->

<property>

<name>javax.jdo.option.ConnectionURL</name>

<value>jdbc:mysql://bd1601: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>root</value>

</property>

<property>

<name>javax.jdo.option.ConnectionPassword</name>

<value>123456</value>

</property>

<!--默认为/user/hive/warehouse,用于配置Hive默认的数据文件存储路径, 这是一个HDFS路径。可按需调整。-->

<property>

<name>hive.metastore.warehouse.dir</name>

<value>/bdp/hive/metastore/warehouse</value>

</property>

<!--查询输出时是否打印名字和列,默认是false.-->

<property>

<name>hive.cli.print.header</name>

<value>true</value>

</property>

<!--hive的提示里是否包含当前的db,默认是false..-->

<property>

<name>hive.cli.print.current.db</name>

<value>true</value>

</property>

<!--强制metastore的schema一致性,开启的话会校验在metastore中存储的信息的版本和hive的jar包中的版本一致性,并且关闭自动schema迁移,用户必须手动的升级hive并且迁移schema,关闭的话只会在版本不一致时给出警告,默认是false不开启;-->

<property>

<name>hive.metastore.schema.verification</name>

<value>false</value>

</property>

<!--在启动时创建必要的架构(如果不存在)。创建一次后,将其设置为false-->

<property>

<name>datanucleus.schema.autoCreateAll</name>

<value>true</value>

</property>

</configuration>

vim/opt/bdp/hadoop-2.6.5/etc/hadoop/core-site.xml

<!--该参数表示可以通过httpfs接口hdfs的ip地址限制-->

<property>

<name>hadoop.proxyuser.root.hosts</name>

<value>*</value>

</property>

<!--通过httpfs接口访问的用户获得的群组身份-->

<property>

<name>hadoop.proxyuser.root.groups</name>

<value>*</value>

</property>

添加连接包

cd/opt/bdp/apache-hive-1.2.1-bin/lib/

rz

vim/etc/profile

exportHIVE_HOME=/opt/bdp/apache-hive-1.2.1-bin

exportPATH=$PATH:$HIVE_HOME/bin

source/etc/profile

scp到其他节点

scp /etc/profile bd1602:/etc/

scp /etc/profile bd1603:/etc/

scp-r/opt/bdp/apache-hive-1.2.1-bin bd1602:/opt/bdp/

scp-r/opt/bdp/apache-hive-1.2.1-bin bd1603:/opt/bdp/

修改客户端配置文件

vim/opt/bdp/apache-hive-1.2.1-bin/conf/hive-site.xml

<?xmlversion="1.0"?>

<?xml-stylesheettype="text/xsl" href="configuration.xsl"?>

<configuration>

<property>

<name>hive.metastore.warehouse.dir</name>

<value>/bdp/hive/metastore/warehouse</value>

</property>

<property>

<name>hive.cli.print.header</name>

<value>true</value>

</property>

<property>

<name>hive.cli.print.current.db</name>

<value>true</value>

</property>

<property>

<name>hive.metastore.schema.verification</name>

<value>false</value>

</property>

<property>

<name>datanucleus.schema.autoCreateAll</name>

<value>true</value>

</property>

<!--指定hive.metastore.uris的port.为了启动metastore服务的时候不用指定端口hive 双杠)service metastore -p 9083 & | hive (双杠)service metastore-->

<property>

<name>hive.metastore.uris</name>

<value>thrift://bd1603:9083</value>

</property>

</configuration>

scp /opt/bdp/hadoop-2.6.5/etc/hadoop/core-site.xml bd1602:/opt/bdp/hadoop-2.6.5/etc/hadoop/

scp /opt/bdp/hadoop-2.6.5/etc/hadoop/core-site.xml bd1603:/opt/bdp/hadoop-2.6.5/etc/hadoop/

rm-rf/opt/bdp/hadoop-2.6.5/share/hadoop/yarn/lib/jline-0.9.94.jar

cp ./jline-2.12.jar /opt/bdp/hadoop-2.6.5/share/hadoop/yarn/lib/

验证,以下为脚本文件的命令

#!/bin/sh

echo"=======================START==========================="

zkServer.sh start

sshroot@bd1601"/opt/bdp/apache-zookeeper-3.5.6-bin/bin/zkServer.sh start"

sshroot@bd1602"/opt/bdp/apache-zookeeper-3.5.6-bin/bin/zkServer.sh start"

echo"=======================休息一下,让zookeeper飞一会==========================="

sleep10

jps

echo"=======================启动hadoop集群==========================="

sshroot@bd1601"/opt/bdp/hadoop-2.6.5/sbin/start-all.sh"

echo"=======================启动resourcemanager==========================="

yarn-daemon.shstart resource manager

#ssh root@bd1602 "/opt/bdp/hadoop-2.6.5/sbin/yarn-daemon.sh start resourcemanager"

echo"=======================启动metastore==========================="

nohup hive--servicemetastore > /dev/null2>&1 &

jps

echo"=======================休息一小会,再让metastore飞一会==========================="

sleep5

jps

echo"=======================启动hiveserver2==========================="

nohup hiveserver2 > /dev/null2>&1 &

sleep5

jps

nohup hiveserver2 > /dev/null2>&1 &

8353 DataNode

8882 Jps

8245 QuorumPeerMain

8550 NodeManager

8631 RunJar

8603 ResourceManager

8444 JournalNode

#!/bin/sh

hbase-daemon.sh stop master

sshroot@bd1601"/opt/bdp/hbase-1.4.13/bin/hbase-daemon.sh stop master"

sshroot@bd1602"/opt/bdp/hbase-1.4.13/bin/hbase-daemon.sh stop master"

hbase-daemon.sh stop regionserver

sshroot@bd1601"/opt/bdp/hbase-1.4.13/bin/hbase-daemon.sh stop regionserver"

sshroot@bd1602"/opt/bdp/hbase-1.4.13/bin/hbase-daemon.sh stop regionserver"

yarn-daemon.sh stop resource manager

sshroot@bd1602"/opt/bdp/hadoop-2.6.5/sbin/yarn-daemon.sh stop resourcemanager"

sshroot@bd1601"/opt/bdp/hadoop-2.6.5/sbin/stop-all.sh"

zkServer.sh stop

sshroot@bd1601"/opt/bdp/apache-zookeeper-3.5.6-bin/bin/zkServer.sh stop"

sshroot@bd1602"/opt/bdp/apache-zookeeper-3.5.6-bin/bin/zkServer.sh stop"

启动matestore

nohup hive --service metastore > /dev/null 2>&1 &

启动hivesever2

nohup hiveserver2 > /dev/null 2>&1 &

查看matestore线程

netstat -lnp|grep 9083

查看hivesever2线程

netstat -lnp|grep 10000

6,Hive交互方式

1.hive cli

2.beeline -u jdbc:hive2://bd1603:10000 -n root

3.hive -e|f beeline -e|f

7,Hive元数据

DBS,SDS,TBLS

0 人点赞