Set up an Oracle database

You install an Oracle database to serve as the backend database for the Hive metastore. You can use the free Express edition. You also install the Oracle driver on your cluster, and then configure the database.

  1. Install Oracle on a node in your cluster.
  2. Download the Oracle JDBC driver from the Oracle web site, and put the JDBC JAR into /usr/lib/hive/lib/ if you are using a Package install method or place the JAR in /opt/cloudera/parcels/CDH/lib/hive/lib/ if you are using a Parcel install method.
    -- For Package install method:
    sudo mv ojdbc<version_number>.jar /usr/lib/hive/lib/
    -- For Parcel install method:
    sudo mv ojdbc<version_number>.jar /opt/cloudera/parcels/CDH/lib/hive/lib/
  3. Connect to the Oracle database as administrator, and create a user account to access the metastore.
    sqlplus "sys as sysdba"
    SQL> create user hiveuser identified by mypassword;
    SQL> grant connect to hiveuser;
    SQL> grant all privileges to hiveuser;
  4. Connect as the hiveuser, and load the initial schema, using the script for your release n.n.n.
    sqlplus hiveuser
    -- For Package install method:
    SQL> @/usr/lib/hive/scripts/metastore/upgrade/oracle/
    -- For Parcel install method:
    SQL> @/opt/cloudera/parcels/CDH/lib/hive/scripts/metastore/upgrade/oracle/
  5. Connect to the Oracle database as administrator and remove the power privileges from user hiveuser.
    sqlplus "sys as sysdba"
    SQL> revoke all privileges from hiveuser;
  6. Grant limited access to all the tables.
    FOR R IN (SELECT owner, table_name FROM all_tables WHERE owner='HIVEUSER') LOOP
      EXECUTE IMMEDIATE 'grant  SELECT,INSERT,UPDATE,DELETE on '||R.owner||'.'||R.table_name||' to hiveuser';
      END LOOP;