hive的本地安裝部署,元數據存儲到mysql中

要想使用Hive先要有hadoop集羣的支持,使用本地把元數據存儲在mysql中。java

  mysql要能夠遠程鏈接:mysql

  能夠設置user表,把localhost改成%,全部可鏈接。記住刪除root其餘用戶,否則可能會有影響sql

  update user set host='%' where host='localhost';數據庫

Hive的安裝部署:oop

  一、解壓tar文件spa

  二、修改文件:日誌

  修改conf/下面的文件:code

    cp hive-env.sh.tempalte hive-env.shxml

  配置hive-env.sh文件:
blog

    一、配置HIVE_HOME路徑

    二、配置HIVE_CONF_DIR路徑

  在hdfs中新建

    /user/hive/warehouse

    /tmp 連個文件夾,並修改權限爲同組可寫

    hdfs dfs -chmod g+w /tmp

    hdfs dfs -chmod g+w /user/hive/warehouse

  配置元數據到mysql中:

    須要mysql的驅動jar包

    cp mysql-connector-java-5.1.27-bin.jar /hive/lib

  在hive/conf目錄中建立一個hive-site.xml文件,更改紅色部分:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>

<value>jdbc:mysql://hadoop102:3306/metastore?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</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>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
   <description>Whether  to  include    the    current    database    in    the    Hive prompt.</description>
</property>
<property>
<name>hive.cli.print.header</name>
<value>false</value>
<description>Whether to print the names of the columns in query output.</description>
</property>
</configuration>

 

-------------------------------------

  更改默認數據倉庫位置:

  hive默認的數據倉庫位置在:/user/hive/warehouse路徑下面, 在倉庫目錄下,沒有對默認的數據庫 default 建立文件夾。若是某張表屬於 default數據庫,直接在數據倉庫目錄下建立一個文件夾。

  能夠修改配置文件更改位置:紅色部分,切記修改路徑的權限爲同組可寫,配置文件hive-site.xml

<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>

  配置表頭顯示、數據顯示:配置文件hive-site.xml

<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>

<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>

  Hive運行日誌配置:

   Hive 的 log 默認存放在/tmp/hadoop/hive.log 目錄下(當前用戶名下)

   修改 hive 的 log 存放日誌到/opt/module/hive/logs

   修改/opt/module/hive/conf/hive-log4j.properties.template 文件名稱爲  hive-log4j.properties

   在 hive-log4j.properties 文件中修改 log 存放位置

      hive.log.dir=/opt/module/hive/logs

相關文章
相關標籤/搜索