Linux搭建Hive开发环境
Linux搭建Hive开发环境
1.Hive
The Apache Hive ™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage using SQL. Structure can be projected onto data already in storage. A command line tool and JDBC driver are provided to connect users to Hive.
2.Hive安装
【1】官网下载Hive【https://hive.apache.org/】安装包:apache-hive-2.3.3-bin.tar.gz
【2】利用Sftp5工具把Hive安装包上传到:/usr/local/hive
【3】利用Xshell工具登录到Linux服务器,解压hive安装包:apache-hive-2.3.3-bin.tar.gz
[root@marklin ~]# cd /usr/local/hive
[root@marklin hive]# ll
total 226788
-rw-r--r--. 1 root root 232229830 Apr 5 21:42 apache-hive-2.3.3-bin.tar.gz
drwxr-xr-x. 10 root root 184 Apr 5 12:40 hive-2.3.3
[root@marklin hive]# ll
total 0
drwxr-xr-x. 10 root root 184 Apr 5 12:40 hive-2.3.3
[root@marklin hive]#
【4】配置环境变量,输入:vim /etc/profile
#Setting HIVE_HOME PATH
export HIVE_HOME=/usr/local/hive/hive-2.3.3
export PATH=${PATH}:${HIVE_HOME}/bin
保存退出后,运行[source /etc/profile]使配置立即生效。
【5】进入到:cd /usr/local/hive/hive-2.3.3/conf,修改配置文件hive-env.sh:
[root@marklin ~]# cd /usr/local/hive/hive-2.3.3/conf
[root@marklin conf]# ll
total 288
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
生成hive-env.sh文件,输入:cp hive-env.sh.template hive-env.sh
[root@marklin conf]# cp hive-env.sh.template hive-env.sh
[root@marklin conf]# ll
total 292
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rw-r--r--. 1 root root 2365 Apr 5 22:18 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
授权hive-env.sh脚本文件,输入:chmod +x hive-env.sh:
[root@marklin conf]# chmod +x hive-env.sh
[root@marklin conf]# ll
total 292
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2365 Apr 5 22:18 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
修改配置,输入:vim hive-env.sh
[root@marklin conf]# vim hive-env.sh
[root@marklin conf]#
export JAVA_HOME=/usr/local/java/jdk1.8.0_162
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.7.5
export HIVE_HOME=/usr/local/hive/hive-2.3.3
export HIVE_AUX_JARS_PATH=${HIVE_HOME}/lib/*
export HIVE_CONF_DIR=${HIVE_HOME}/conf
export HADOOP_HEAPSIZE=1024
【6】将hive-default.xml.template文件复制一份,并且改名为hive-site.xml,输入:cp hive-default.xml.template hive-site.xml
[root@marklin conf]# cp hive-default.xml.template hive-site.xml
[root@marklin conf]# chmod +x hive-site.xml
[root@marklin conf]# ll
total 544
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2590 Apr 5 22:41 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:46 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
修改hive-site.xml,并添加:
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8</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>123456Abc</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/tmp/hive/repository</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://marklin.com:9083</value>
</property>
</configuration>
Hive的配置需要Hadoop和Mysql的支持,本教程已经默认安装Hadoop和Mysql的支持。
【6】将hive-exec-log4j2.properties.template文件复制一份,并且改名为 hive-exec-log4j2.properties,输入:cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties
[root@marklin conf]# cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties
[root@marklin conf]# ll
total 548
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]# chmod +x hive-exec-log4j2.properties
[root@marklin conf]# ll
total 548
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
【7】将hive-log4j2.properties.template文件复制一份,并且改名为 hive-log4j2.properties.,输入:cp hive-log4j2.properties.template hive-log4j2.properties
[root@marklin conf]# cp hive-log4j2.properties.template hive-log4j2.properties
[root@marklin conf]# ll
total 552
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]# chmod +x hive-log4j2.properties
[root@marklin conf]# ll
total 552
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
【7】将beeline-log4j2.properties.template文件复制一份,并且改名为 beeline-log4j2.properties.,输入:cp beeline-log4j2.properties.template beeline-log4j2.properties
[root@marklin conf]# cp beeline-log4j2.properties.template beeline-log4j2.properties
[root@marklin conf]# ll
total 556
-rw-r--r--. 1 root root 1596 Apr 6 01:19 beeline-log4j2.properties
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]# chmod +x beeline-log4j2.properties
[root@marklin conf]# ll
total 556
-rwxr-xr-x. 1 root root 1596 Apr 6 01:19 beeline-log4j2.properties
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
【8】配置llap-x文件:
[root@marklin conf]# cp llap-cli-log4j2.properties.template llap-cli-log4j2.properties
[root@marklin conf]# ll
total 560
-rwxr-xr-x. 1 root root 1596 Apr 6 01:19 beeline-log4j2.properties
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Apr 6 01:22 llap-cli-log4j2.properties
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]# chmod +x llap-cli-log4j2.properties
[root@marklin conf]# ll
total 560
-rwxr-xr-x. 1 root root 1596 Apr 6 01:19 beeline-log4j2.properties
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rwxr-xr-x. 1 root root 2719 Apr 6 01:22 llap-cli-log4j2.properties
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]# cp llap-daemon-log4j2.properties.template llap-daemon-log4j2.properties
[root@marklin conf]# chmod +x llap-daemon-log4j2.properties
[root@marklin conf]# ll
total 568
-rwxr-xr-x. 1 root root 1596 Apr 6 01:19 beeline-log4j2.properties
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 19:58 hive-default.xml.template
-rwxr-xr-x. 1 root root 2618 Apr 6 00:23 hive-env.sh
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rwxr-xr-x. 1 root root 2274 Apr 6 01:12 hive-exec-log4j2.properties
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rwxr-xr-x. 1 root root 2925 Apr 6 01:16 hive-log4j2.properties
-rw-r--r--. 1 root root 2925 Mar 7 16:37 hive-log4j2.properties.template
-rwxr-xr-x. 1 root root 257573 Apr 5 22:50 hive-site.xml
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rwxr-xr-x. 1 root root 2719 Apr 6 01:22 llap-cli-log4j2.properties
-rw-r--r--. 1 root root 2719 Mar 7 16:38 llap-cli-log4j2.properties.template
-rwxr-xr-x. 1 root root 7041 Apr 6 01:23 llap-daemon-log4j2.properties
-rw-r--r--. 1 root root 7041 Mar 7 16:38 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@marklin conf]#
【9】对数据进行初始化,输入:schematool -dbType mysql -initSchema
[root@marklin ~]# schematool -dbType mysql -initSchema
Metastore connection URL: jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed
【10】输入hive执行:
[root@marklin ~]# hive
Logging initialized using configuration in file:/usr/local/hive/hive-2.3.3/conf/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> show databases; --显示数据库
OK
default
Time taken: 2.962 seconds, Fetched: 1 row(s)
hive> show tables; --显示数据库表
OK
Time taken: 0.46 seconds
hive>
【11】浏览器输入:http://192.168.3.4:50070/explorer.html#/
相关推荐
archive 2020-07-30
成长之路 2020-07-28
eternityzzy 2020-07-19
taisenki 2020-07-05
tugangkai 2020-07-05
SignalDu 2020-07-05
zlsdmx 2020-07-05
tomson 2020-07-05
tugangkai 2020-07-04
tomson 2020-07-05
Zhangdragonfly 2020-06-28
genshengxiao 2020-06-26
成长之路 2020-06-26
tomson 2020-06-26
蜗牛之窝 2020-06-26
成长之路 2020-06-25