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


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

  mysql要可以遠程連接:

  可以設置user表,把localhost改為%,所有可連接。記住刪除root其他用戶,不然可能會有影響

  update user set host='%' where host='localhost';

Hive的安裝部署:

  1、解壓tar文件

  2、修改文件:

  修改conf/下面的文件:

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

  配置hive-env.sh文件:

    1、配置HIVE_HOME路徑

    2、配置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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM