This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • HiveDerbyServerMode
Skip to end of metadata
Go to start of metadata

Hive Using Derby in Server Mode

Hive in embedded mode has a limitation of one active user at a time. You may want to run Derby as a Network Server, this way multiple users can access it simultaneously from different systems.

See Metadata Store and Embedded Metastore for more information.

Download Derby

It is suggested you download the version of Derby that ships with Hive. If you have already run Hive in embedded mode, the first line of derby.log contains the version.

My structure looks like this:

cd /opt/hadoop
tar -xzf db-derby-
mkdir db-derby-

Set Environment

The variable to set has changed over the years. DERBY_HOME is now the proper name. I set this and the legacy name.



Hive also likes to know where Hadoop is installed:


export HADOOP

Starting Derby

Likely you are going to want to run Derby when Hadoop starts up. An interesting place for this other than as an lsb-init-script might be alongside Hadoop scripts like start-dfs. By default Derby will create databases in the directory it was started from.

cd /opt/hadoop/db-derby-
# If you are using JDK 1.7u51+, you'll need to either specify an ephemeral port (typically between 49152 and 65535)
# or add a grant to your JDK version's java.policy file.
# See for details.
nohup /opt/hadoop/db-derby- -h &

Configure Hive to Use Network Derby

Edit /opt/hadoop/hive/conf/hive-site.xml as follows. Note that "hadoop1" should be replaced with the hostname or IP address where the Derby network server can be found.


  <description>JDBC connect string for a JDBC metastore</description>

  <description>Driver class name for a JDBC metastore</description>


      Version: JPOX properties are NOT used in Hive 5.0 or later.
      JPOX properties can be specified in hive-site.xml. Normally changes are not required.


Copy Derby Jar Files

Now since there is a new client you MUST make sure Hive has these jar files in the lib directory or in the classpath. The same would be true if you used MySQL or some other DB.

cp /opt/hadoop/db-derby- /opt/hadoop/hive/lib
cp /opt/hadoop/db-derby- /opt/hadoop/hive/lib

If you receive the error "javax.jdo.JDOFatalInternalException: Error creating transactional connection factory" where the stack trace originates at "org.datanucleus.exceptions.ClassNotResolvedException: Class 'org.apache.derby.jdbc.ClientDriver' was not found in the CLASSPATH. Please check your specification and your CLASSPATH", you may benefit from putting the Derby jar files directly in the Hadoop lib directory:

cp /opt/hadoop/db-derby- /opt/hadoop/hadoop-
cp /opt/hadoop/db-derby- /opt/hadoop/hadoop-

Start Up Hive

The metastore will not be created until the first query hits it.

cd /opt/hadoop/hive
hive> show tables;

A directory should be created: /opt/hadoop/db-derby- .

The Result

Now you can run multiple Hive instances working on the same data simultaneously and remotely.

  • No labels