hive环境部署

$ tar -zxvf apache-hive-2.1.1-bin.tar.gz 
$ mv apache-hive-2.1.1-bin.tar.gz hive-2.1.1 
配置环境变量(同上)

export HIVE_HOME=/home/ranrl/opt/hive-2.1.1 
export HIVE_CONF_DIR=$HIVE_HOME/conf 
export PATH=\$PATH:\$HIVE_HOME/bin

在hive的目录下,新建warehouse、tmp、log文件夹。 
修改配置文件,下面是hive的配置文件conf目录

-rw-r--r-- 1 ranrl root   1596 Nov 29 05:32 beeline-log4j2.properties.template
-rw-r--r-- 1 ranrl root 229198 Nov 30 03:46 hive-default.xml.template
-rw-r--r-- 1 ranrl root   2378 Nov 29 05:35 hive-env.sh.template
-rwxr-xr-x 1 ranrl root   2274 Feb  7 17:09 hive-exec-log4j2.properties
-rw-r--r-- 1 ranrl root   2274 Nov 29 05:32 hive-exec-log4j2.properties.template
-rw-r--r-- 1 ranrl root   2925 Nov 29 05:32 hive-log4j2.properties.template
-rw-r--r-- 1 ranrl root   2060 Nov 29 05:32 ivysettings.xml
-rw-r--r-- 1 ranrl root   2719 Nov 29 05:32 llap-cli-log4j2.properties.template
-rw-r--r-- 1 ranrl root   4353 Nov 29 05:35 llap-daemon-log4j2.properties.template
-rw-r--r-- 1 ranrl root   2662 Nov 29 05:32 parquet-logging.properties
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

$ cp hive-env.sh.template hive-env.sh 
$ cp hive-log4j2.properties.template hive-log4j2.properties 
$ cp hive-default.xml.template hive-site.xml

修改后配置文件如下:

-rw-r--r-- 1 ranrl root   1596 Nov 29 05:32 beeline-log4j2.properties.template
-rw-r--r-- 1 ranrl root 229198 Nov 30 03:46 hive-default.xml.template
-rwxr-xr-x 1 ranrl root   2440 Feb  7 17:31 hive-env.sh
-rw-r--r-- 1 ranrl root   2378 Nov 29 05:35 hive-env.sh.template
-rwxr-xr-x 1 ranrl root   2274 Feb  7 17:09 hive-exec-log4j2.properties
-rw-r--r-- 1 ranrl root   2274 Nov 29 05:32 hive-exec-log4j2.properties.template
-rwxr-xr-x 1 ranrl root   2925 Feb  7 17:09 hive-log4j2.properties
-rw-r--r-- 1 ranrl root   2925 Nov 29 05:32 hive-log4j2.properties.template
-rwxr-xr-x 1 ranrl root   2514 Feb  7 18:43 hive-site.xml
-rw-r--r-- 1 ranrl root   2060 Nov 29 05:32 ivysettings.xml
-rw-r--r-- 1 ranrl root   2719 Nov 29 05:32 llap-cli-log4j2.properties.template
-rw-r--r-- 1 ranrl root   4353 Nov 29 05:35 llap-daemon-log4j2.properties.template
-rw-r--r-- 1 ranrl root   2662 Nov 29 05:32 parquet-logging.properties
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

修改hive-env.sh,去掉前面的注释#,加上相应的路径 
export HADOOP_HEAPSIZE=1024 
HADOOP_HOME=/home/ranrl/opt/hadoop-2.7.3 
export HIVE_CONF_DIR=/home/ranrl/opt/hive-2.1.1/conf 
export HIVE_AUX_JARS_PATH=/home/ranrl/opt/hive-2.1.1/lib

这儿采用mysql作为hive的元数据库 
在自己的mysql中为hive新建一个用户:grant all privileges on . to ‘hive’ @ ‘%’ identified by ‘password’ 
修改hive-site.xml文件,添加相应的路径和mysql数据库,用户名,密码

<property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/home/ranrl/opt/hive-2.1.1/warehouse</value>
    <description>location of default database for the warehouse</description>
 </property>
 <property>
    <name>hive.querylog.location</name>
    <value>/home/ranrl/opt/hive-2.1.1/log</value>
    <description>Location of Hive run time structured log file</description>
 </property>
 <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/ranrl/opt/hive-2.1.1/tmp</value>
    <description>Temporary local directory for added resources in the remote file system.</description>
 </property>
 <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://localhost:3306/hive</value>
    <description>
      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
    </description>
  </property>
  <property>
<name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
 <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
    <description>Username to use against metastore database</description>
  </property>
<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>password</value>
    <description>password to use against metastore database</description>
  </property>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

5. 下载mysql-connector-java

地址:https://dev.mysql.com/downloads/connector/j/ 
解压得到mysql-connector-java-5.1.40.jar,拷贝到hive的lib目录下。

6. 在进入hive目录下的bin目录,运行命令:./schematool -initSchema -dbType mysql

现在hive已经安装成功,输入hive命令,即可运行hive

show databases; 
create databases test; 
use test; 
hive> CREATE TABLE test(id int,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’; 
select * from test ;运行正常说明hive已经安装成功

猜你喜欢

转载自blog.csdn.net/lby0307/article/details/80309206