hive使用derby的服务模式(可以远程模式)

hive默认使用的derby的嵌入模式。这个就面临着,无法多个并发hive shell共享的问题。 使用MySQL服务器也可以解决问题,但安装、配置太麻烦了。 可以使用轻量级的derby的c/s服务模式解决问题。 1、下载、配置derby 首先,从apache下载derby的最新版。

 

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基本是开箱即用的,如下启动

./bin/startNetworkServer -h myhost -p myport

  同时,还需要拷贝两个jar包到hive/lib下

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

  2、配置hive 需要修改2个配置,derby默认是可以没有用户名、密码的。注意看驱动,和嵌入模式的驱动是不一样的

<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>

 

初始化数据库

hive/bin/schematool -dbType mysql -initSchema

启动hive

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语句,只是掉最前面的两个function

posted @ 2018-04-15 23:23  lfm601508022  阅读(1053)  评论(0编辑  收藏  举报