MacOS部署Hive Debug环境

本文以hive3.1为示例,分别配置hadoop和spark做为计算引擎。

1环境准备

1.1 下载jdk

登陆 Oracle官网 下载jdk
oracle账号:amador.sun@foxmail.com
密码:1211WaN!

1.2 配置jdk环境变量

编辑环境变量:vim ~/.bash_profile

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 

1.3 验证

使用java -version命令,查看安装jdk版本

duyanyong@duyanyongdeMacBook-Air apache-hive-3.1.3-bin % java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

2部署hadoop

查看hive源码确认hadoop对应版本为<hadoop.version>3.1.0</hadoop.version>

2.1 下载hadoop

进入下载地址下载匹配版本的hadoop

2.2 免密登陆

因为Hadoop是分布式平台,需要多个机器之间协作,设置ssh免密码登录可以减少每次登陆主机输入密码的繁琐流程。

  1. 在Mac的系统偏好设置–>共享中打开远程登录:
  2. 在terminal中输入 ssh-keygen -t rsa ,生成rsa公钥,接下来一路按回车键或者输入y就行了:
  3. 在terminal中输入 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ,将公钥的内容写入到authorized_keys文件中。
  4. 在terminal中输入 ssh localhost ,不需要密码也能登录,说明设置成功。

2.3 修改Hadoop配置文件

进入路径/Users/duyanyong/bigdata/hadoop-3.1.0/etc/hadoop编辑以下配置文件
1.core-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
        <name>fs.defaultFS</name>
        <value>hdfs://0.0.0.0:9000</value>
    </property>
    <!-- 指定hadoop运行时产生文件的存储路径 -->
    <property>
        <name>hadoop.tmp.dir</name>
        <!-- 配置到hadoop目录下temp文件夹 -->
        <value>/Users/duyanyong/bigdata/hadoop-3.1.0/tmp</value>
    </property>
</configuration>

2.hdfs-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
    <!--指定hdfs保存数据副本的数量,包括自己,默认为3-->
    <!--伪分布式模式,此值必须为1-->
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    <property>
        <name>dfs.namenode.name.dir</name>
        <!-- name node 存放 name table 的目录 -->
        <value>file:/Users/duyanyong/bigdata/hadoop-3.1.0/tmp/hdfs/name</value>
    </property>
    <property>
        <name>dfs.datanode.data.dir</name>
        <!-- data node 存放数据 block 的目录 -->
        <value>file:/Users/duyanyong/bigdata/hadoop-3.1.0/tmp/hdfs/data</value>
    </property>
    <property>
        <name>dfs.namenode.secondary.http-address</name>
        <value>localhost:9001</value>
    </property>
    <property>
        <name>dfs.webhdfs.enabled</name>
        <value>true</value>
    </property>
</configuration>

3.mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
    <!--指定mapreduce运行在yarn上-->
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
</configuration>

4.yarn-site.xml

<?xml version="1.0"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->
<configuration>

<!-- Site specific YARN configuration properties -->
<property>
    <name>yarn.resourcemanager.hostname</name>
    <value>localhost</value>
    </property>
    <property>
    <!--NodeManager获取数据的方式-->
    <name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
    </property>
    <property>
         <name>yarn.application.classpath</name>
         <value>/Users/duyanyong/bigdata/hadoop-3.1.0/etc/hadoop:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/common/lib/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/common/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/hdfs:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/hdfs/lib/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/hdfs/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/mapreduce/lib/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/mapreduce/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/yarn:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/yarn/lib/*:/Users/duyanyong/bigdata/hadoop-3.1.0/share/hadoop/yarn/*</value>
    </property>
</configuration>

2.4 初始化及启动

初始化hdfshdfs namenode -format
启动hadoopstart-all.sh 或者分别输入start-dfs.shstart-yarn.sh)

2.5 验证

查看NameNodeYarn

NameNode

Yarn

3部署hive

3.1 下载hive

进入官方下载下载hive源码,使用idea打开,切换到3.1.3分支

3.2 编译hive源文件

进入hive根目录/Users/duyanyong/IdeaProjects/hive
编辑hive源码mvn clean package -DskipTests -Phadoop -Pdist
编译完成之后会在hive根目录下生成packaging文件

packaging文件

3.3 添加hadoop配置

进入路径/Users/duyanyong/IdeaProjects/hive/packaging/target/apache-hive-3.1.3-bin/apache-hive-3.1.3-bin/conf修改hive-env.sh
添加hadoop路径配置

HADOOP_HOME=/Users/duyanyong/bigdata/hadoop-3.1.0

3.4 初始化元数据库

3.4.1 在mysql创建hive用户

# 进入mysql
hadoop@ubuntu:~$ mysql -u root -p mysql
# 创建hive用户,密码为hive
mysql> CREATE USER 'hive' IDENTIFIED BY 'hive';、
# 为hive赋权
mysql> GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' WITH GRANT OPTION;
# 刷新权限
mysql> flush privileges;

3.4.2 修改hive元数据库配置

在Hive的conf目录下的文件“hive-site.xml”中增加如下配置:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
    <property>
        <name>hive.metastore.local</name>
        <value>true</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hive_metastore?characterEncoding=UTF-8</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>hive</value>
    </property>
</configuration>

3.4.3 初始化mysql元数据库

进入路径:/Users/duyanyong/IdeaProjects/hive/bin
执行命令./schematool --dbType mysql --initSchema完成元数据库的初始化

myusql元数据库

3.5 开启hive debug

3.5.1 运行hive debug模式

以debug模式运行hivehive --debug -hiveconf hive.root.logger=DEBUG,console

hive debug

3.5.2 idea中添加远程debug配置

debug configuration

3.5.3 源码上打断点

找到CliDriver.java类,并打上断点


断点

3.5.4 debug

debug源码,输入hive命令,如:show databases;


进入断点

4部署spark

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,835评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,598评论 1 295
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,569评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,159评论 0 213
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,533评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,710评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,923评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,674评论 0 203
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,421评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,622评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,115评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,428评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,114评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,097评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,875评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,753评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,649评论 2 271

推荐阅读更多精彩内容