hive使用derby的服務模式(能夠遠程模式)

hive默認使用的derby的嵌入模式。這個就面臨着,沒法多個併發hive shell共享的問題。 使用MySQL服務器也能夠解決問題,但安裝、配置太麻煩了。 能夠使用輕量級的derby的c/s服務模式解決問題。 一、下載、配置derby 首先,從apache下載derby的最新版。java

 

wget https://mirrors.tuna.tsinghua.edu.cn/apache//db/derby/db-derby-10.14.1.0/db-derby-10.14.1.0-bin.tar.gz
tar -xzvf ./db-derby-10.14.1.0-bin.tar.gz
cd db-derby-10.14.1.0-bin 

derby基本是開箱即用的,以下啓動mysql

./bin/startNetworkServer -h myhost -p myport

  同時,還須要拷貝兩個jar包到hive/lib下sql

cp ./derbyclient.jar ~/hive-current/lib/
cp ./derbytools.jar ~/hive-current/lib/

  二、配置hive 須要修改2個配置,derby默認是能夠沒有用戶名、密碼的。注意看驅動,和嵌入模式的驅動是不同的shell

<property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:derby://s007132.cm8:1527/hive_meta;create=true</value>
                <description>JDBC connect string for a JDBC metastore</description>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>org.apache.derby.jdbc.ClientDriver</value>
                <description>Driver class name for a JDBC metastore</description>
        </property>

 

此外,注意hdfs上的路徑,不要和已有的衝突了。PS:這裏配置的路徑是hdfs上的數據庫

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

        <property>
                <name>hive.exec.scratchdir</name>
                <value>/user/lhy/product_search/hive-tmp</value>
                <description>Scratch space for Hive jobs</description>
        </property>

 

初始化數據庫apache

hive/bin/schematool -dbType mysql -initSchema

啓動hivebash

hive/bin/schematool

 

報錯:服務器

Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!

解決辦法:併發

修改derby的script的sql語句,只是掉最前面的兩個functionoop

相關文章
相關標籤/搜索