Oracle Database

Collecting Oracle Database Information

To configure Cloudera Manager to work with an Oracle database, get the following information from your Oracle DBA:

  • Hostname - The DNS name or the IP address of the host where the Oracle database is installed.
  • SID - The name of the schema that will store Cloudera Manager information.
  • Username - A username for each schema that is storing information. You could have four unique usernames for the four schema.
  • Password - A password corresponding to each user name.

Configuring the Oracle Server

Adjusting Oracle Settings to Accommodate Larger Clusters

Cloudera Management services require high write throughput. Depending on the size of your deployments, your DBA may need to modify Oracle settings for monitoring services. These guidelines are for larger clusters and do not apply to the Cloudera Manager configuration database and to smaller clusters. Many factors help determine whether you need to change your database settings, but in most cases, if your cluster has more than 100 hosts, you should consider making the following changes:
  • Enable direct and asynchronous I/O by setting the FILESYSTEMIO_OPTIONS parameter to SETALL.
  • Increase the RAM available to Oracle by changing the MEMORY_TARGET parameter. The amount of memory to assign depends on the size of the Hadoop cluster.
  • Create more redo log groups and spread the redo log members across separate disks or logical unit numbers.
  • Increase the size of redo log members to be at least 1 GB.

Reserving Ports for HiveServer 2

HiveServer2 uses port 10000 by default, but Oracle database changes the local port range. This can cause HiveServer2 to fail to start.

Manually reserve the default port for HiveServer2. For example, the following command reserves port 10000 and inserts a comment indicating the reason:

echo << EOF > /etc/sysctl.cnf
# HS2 uses port 10000
net.ipv4.ip_local_reserved_ports = 10000
EOF

sysctl -q -w net.ipv4.ip_local_reserved_ports=10000

Modifying the Maximum Number of Oracle Connections

Work with your Oracle database administrator to ensure appropriate values are applied for your Oracle database settings. You must determine the number of connections, transactions, and sessions to be allowed.

Allow 100 maximum connections for each service that requires a database and then add 50 extra connections. For example, for two services, set the maximum connections to 250. If you have five services that require a database on one host (the databases for Cloudera Manager Server, Activity Monitor, Reports Manager, Cloudera Navigator, and Hive metastore), set the maximum connections to 550.

From the maximum number of connections, you can determine the number of anticipated sessions using the following formula:

sessions = (1.1 * maximum_connections) + 5

For example, if a host has a database for two services, anticipate 250 maximum connections. If you anticipate a maximum of 250 connections, plan for 280 sessions.

Once you know the number of sessions, you can determine the number of anticipated transactions using the following formula:

transactions = 1.1 * sessions

Continuing with the previous example, if you anticipate 280 sessions, you can plan for 308 transactions.

Work with your Oracle database administrator to apply these derived values to your system.

Using the sample values above, Oracle attributes would be set as follows:

alter system set processes=250;
alter system set transactions=308;
alter system set sessions=280;

Ensuring Your Oracle Database Supports UTF8

The database you use must support UTF8 character set encoding. You can implement UTF8 character set encoding in Oracle databases by using the dbca utility. In this case, you can use the characterSet AL32UTF8 option to specify proper encoding. Consult your DBA to ensure UTF8 encoding is properly configured.

Installing the Oracle JDBC Connector

You must install the JDBC connector on the Cloudera Manager Server host and on hosts to which you assign the Activity Monitor, Reports Manager, Hive Metastore Server, Sentry Server, Cloudera Navigator Audit Server, and Cloudera Navigator Metadata Server server roles.

Cloudera recommends that you assign all roles that require a database on the same host and install the connector on that host. Locating all such roles on the same host is recommended but not required. If you install a role, such as Activity Monitor, on one host and other roles on a separate host, you would install the JDBC connector on each host running roles that access the database.

  1. Download the Oracle JDBC Driver from the Oracle website. For example, the version 6 JAR file is named ojdbc6.jar.

    For more information about supported Oracle Java versions, see CDH and Cloudera Manager Supported JDK Versions.

    To download the JDBC driver, visit the Oracle JDBC and UCP Downloads page, and click on the link for your Oracle Database version. Download the ojdbc6.jar file.

  2. Copy the Oracle JDBC JAR file to /usr/share/java/oracle-connector-java.jar. The Cloudera Manager databases and the Hive Mestastore database use this shared file. For example:
    mkdir /usr/share/java
    cp /tmp/ojdbc6.jar /usr/share/java/oracle-connector-java.jar

Creating Databases for the Cloudera Manager Server, Activity Monitor, Reports Manager, Hive Metastore Server, Sentry Server, Cloudera Navigator Audit Server, and Cloudera Navigator Metadata Server

Create schema and user accounts for components that require databases:
  • Cloudera Manager Server (not required if you are using the Cloudera Manager installer)
  • Cloudera Management Service roles:
    • Activity Monitor (if using the MapReduce service)
    • Reports Manager
    • Cloudera Navigator Audit Server
    • Cloudera Navigator Metadata Server
  • Hive Metastore
  • Sentry Server

You can create the Oracle database, schema and users on the host where the Cloudera Manager Server will run, or on any other hosts in the cluster. For performance reasons, you should install each database on the host on which the service runs, as determined by the roles you assign during installation or upgrade. In larger deployments or in cases where database administrators are managing the databases the services use, you can separate databases from services, but use caution.

The database must be configured to support UTF-8 character set encoding.

Record the values you enter for database names, user names, and passwords. The Cloudera Manager installation wizard requires this information to correctly connect to these databases.

  1. Log into the Oracle client:
    sqlplus system@localhost
    Enter password: ******
  2. Create a schema and user for the Cloudera Manager Server. The minimum permissions required are:
    create user username identified by password default tablespace tablespace;
    grant CREATE SESSION to username;
    grant CREATE TABLE to username;
    grant CREATE SEQUENCE to username;
    grant EXECUTE on sys.dbms_lob to username;
    where username and password are the credentials you specified in Preparing a Cloudera Manager Server External Database.
  3. Grant a quota on the tablespace (the default tablespace is SYSTEM) where tables will be created:
    SQL> ALTER USER username quota 100m on tablespace 
    or for unlimited space:
    SQL> ALTER USER username quota unlimited on tablespace
  4. Create schema and users for Activity Monitor, Reports Manager, Hive Metastore Server, Sentry Server, Cloudera Navigator Audit Server, and Cloudera Navigator Metadata Server:schema, user, and password can be any value. The examples match the default names provided in the Cloudera Manager configuration settings:
    Role Schema User Password
    Activity Monitor amon amon amon_password
    Reports Manager rman rman rman_password
    Hive Metastore Server metastore hive hive_password
    Sentry Server sentry sentry sentry_password
    Cloudera Navigator Audit Server nav nav nav_password
    Cloudera Navigator Metadata Server navms navms navms_password
  5. For each user in the table in the preceding step, create a user and add privileges for the each user:
    create user username identified by password default tablespace tablespace;
    grant CREATE SESSION to username;
    grant CREATE TABLE to username;
    grant CREATE SEQUENCE to username;
    grant EXECUTE on sys.dbms_lob to username;
  6. Grant a quota on the tablespace (the default tablespace is SYSTEM) where tables will be created:
    SQL> ALTER USER username quota 100m on tablespace 
    or for unlimited space:
    SQL> ALTER USER username quota unlimited on tablespace
    For further information about Oracle privileges, see Authorization: Privileges, Roles, Profiles, and Resource Limitations.
  7. After creating the Cloudera Navigator Audit Server database, set the following additional privileges:
    GRANT EXECUTE ON sys.dbms_crypto TO nav;
    GRANT CREATE VIEW TO nav;
    where nav is the Navigator Audit Server user you specified above when you created the database.

Return to Establish Your Cloudera Manager Repository Strategy.

Configuring the Hue Server to Store Data in Oracle (Parcel Installation)

Use the following instructions to configure the Hue Server with an Oracle database if you are working on a parcel-based deployment. If you are using packages, see Configuring the Hue Server to Store Data in Oracle (Package Installation).

For information about installing and configuring an Oracle database , see Oracle Database.
  1. Install the required packages.

    RHEL

    $ sudo yum install gcc python-devel python-pip python-setuptools libaio

    SLES:

    Python devel packages are not included in SLES. Add the SLES Software Development Kit (SDK) as a repository and then install:
    $ zypper install gcc libaio python-pip python-setuptools python-devel

    Ubuntu or Debian

    $ sudo apt-get install gcc python-dev python-pip python-setuptools libaio1
  2. Download and add the Oracle Client parcel to the Cloudera Manager remote parcel repository URL list and download, distribute, and activate the parcel.
  3. For CDH versions lower than 5.3, install the Python Oracle library:
    $ HUE_HOME/build/env/bin/pip install cx_Oracle
  4. For CDH versions lower than 5.3, upgrade django south:
    $ HUE_HOME/build/env/bin/pip install south --upgrade
  5. In the Cloudera Manager Admin Console, go to the Hue service status page.
  6. Select Actions > Stop. Confirm you want to stop the service by clicking Stop.
  7. Select Actions > Dump Database. Confirm you want to dump the database by clicking Dump Database.
  8. Click the Configuration tab.
  9. Select Scope > All.
  10. Select Category > Advanced.
  11. Set the Hue Service Advanced Configuration Snippet (Safety Valve) for hue_safety_valve.ini property. Add the following options (and modify accordingly for your setup):
    [desktop]
    [[database]]
    host=localhost
    port=1521
    engine=oracle
    user=hue
    password=secretpassword
    name=<SID of the Oracle database, for example, 'XE'>
    For CDH 5.1 and higher you can use an Oracle service name. To use the Oracle service name instead of the SID, use the following configuration instead:
    port=0
    engine=oracle
    user=hue
    password=secretpassword
    name=oracle.example.com:1521/orcl.example.com

    The directive port=0 allows Hue to use a service name. The name string is the connect string, including hostname, port, and service name.

    To add support for a multithreaded environment, set the threaded option to true under the [desktop]>[[database]] section.

    options={"threaded":true}
  12. Grant required permissions to the hue user in Oracle:
    GRANT CREATE <sequence> TO <user>; 
    GRANT CREATE <session> TO <user>; 
    GRANT CREATE <table> TO <user>; 
    GRANT CREATE <view> TO <user>; 
    GRANT CREATE <procedure> TO <user>; 
    GRANT CREATE <trigger> TO <user>; 
    GRANT EXECUTE ON sys.dbms_crypto TO <user>; 
    GRANT EXECUTE ON SYS.DBMS_LOB TO <user>;
  13. Go to the Hue Server instance in Cloudera Manager and select Actions > Synchronize Database.
  14. Ensure you are connected to Oracle as the hue user, then run the following command to delete all data from Oracle tables:
    > set pagesize 100;
    > SELECT 'DELETE FROM ' || table_name || ';' FROM user_tables; 
  15. Run the statements generated in the preceding step.
  16. Commit your changes.
    commit;
  17. Load the data that you dumped. Go to the Hue Server instance and select Actions > Load Database. This step is not necessary if you have a fresh Hue install with no data or if you don’t want to save the Hue data.
  18. Start the Hue service.

Configuring the Hue Server to Store Data in Oracle (Package Installation)

If you have a parcel-based environment, see Configuring the Hue Server to Store Data in Oracle (Parcel Installation).

  1. Download the Oracle libraries at Instant Client for Linux x86-64 Version 11.1.0.7.0, Basic and SDK (with headers) zip files to the same directory.
  2. Unzip the Oracle client zip files.
  3. Set environment variables to reference the libraries.
    $ export ORACLE_HOME=oracle_download_directory 
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
  4. Create a symbolic link for the shared object:
    $ cd $ORACLE_HOME 
    $ ln -sf libclntsh.so.11.1 libclntsh.so
  5. Install the required packages.

    RHEL

    $ sudo yum install gcc python-devel python-pip python-setuptools libaio

    SLES:

    Python devel packages are not included in SLES. Add the SLES Software Development Kit (SDK) as a repository and then install:
    $ zypper install gcc libaio python-pip python-setuptools python-devel

    Ubuntu or Debian

    $ sudo apt-get install gcc python-dev python-pip python-setuptools libaio1
  6. For CDH versions lower than 5.3, install the Python Oracle library:
    $ HUE_HOME/build/env/bin/pip install cx_Oracle
  7. For CDH versions lower than 5.3, upgrade django south:
    $ HUE_HOME/build/env/bin/pip install south --upgrade
  8. In the Cloudera Manager Admin Console, go to the Hue service status page.
  9. Select Actions > Stop. Confirm you want to stop the service by clicking Stop.
  10. Select Actions > Dump Database. Confirm you want to dump the database by clicking Dump Database.
  11. Click the Configuration tab.
  12. Select Scope > All.
  13. Select Category > Advanced.
  14. Set the Hue Service Environment Advanced Configuration Snippet (Safety Valve) property to
    ORACLE_HOME=oracle_download_directory
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:oracle_download_directory
  15. Set the Hue Service Advanced Configuration Snippet (Safety Valve) for hue_safety_valve.ini property. Add the following options (and modify accordingly for your setup):
    [desktop]
    [[database]]
    host=localhost
    port=1521
    engine=oracle
    user=hue
    password=secretpassword
    name=<SID of the Oracle database, for example, 'XE'>
    For CDH 5.1 and higher you can use an Oracle service name. To use the Oracle service name instead of the SID, use the following configuration instead:
    port=0
    engine=oracle
    user=hue
    password=secretpassword
    name=oracle.example.com:1521/orcl.example.com

    The directive port=0 allows Hue to use a service name. The name string is the connect string, including hostname, port, and service name.

    To add support for a multithreaded environment, set the threaded option to true under the [desktop]>[[database]] section.

    options={"threaded":true}
  16. Grant required permissions to the hue user in Oracle:
    GRANT CREATE <sequence> TO <user>; 
    GRANT CREATE <session> TO <user>; 
    GRANT CREATE <table> TO <user>; 
    GRANT CREATE <view> TO <user>; 
    GRANT CREATE <procedure> TO <user>; 
    GRANT CREATE <trigger> TO <user>; 
    GRANT EXECUTE ON sys.dbms_crypto TO <user>; 
    GRANT EXECUTE ON SYS.DBMS_LOB TO <user>;
  17. Go to the Hue Server instance in Cloudera Manager and select Actions > Synchronize Database.
  18. Ensure you are connected to Oracle as the hue user, then run the following command to delete all data from Oracle tables:
    > set pagesize 100;
    > SELECT 'DELETE FROM ' || table_name || ';' FROM user_tables; 
  19. Run the statements generated in the preceding step.
  20. Commit your changes.
    commit;
  21. Load the data that you dumped. Go to the Hue Server instance and select Actions > Load Database. This step is not necessary if you have a fresh Hue install with no data or if you don’t want to save the Hue data.
  22. Start the Hue service.

Configuring Oracle for Oozie

Install and Start Oracle 11g

Use Oracle's instructions.

Create the Oozie Oracle User and Grant Privileges

The following example uses the Oracle sqlplus command-line tool, and shows the privileges Cloudera recommends. Oozie needs CREATE SESSION to start and manage workflows. The additional roles are needed for creating and upgrading the Oozie database.

$ sqlplus system@localhost

Enter password: ******

SQL> create user oozie identified by oozie default tablespace users temporary tablespace temp;

User created.

SQL> grant alter index to oozie;
grant alter table to oozie;
grant create index to oozie;
grant create sequence to oozie;
grant create session to oozie;
grant create table to oozie;
grant drop sequence to oozie;
grant select dictionary to oozie;
grant drop table to oozie;
alter user oozie quota unlimited on users; 
alter user oozie quota unlimited on system;

SQL> exit

$

Add the Oracle JDBC Driver JAR to Oozie

Copy or symbolically link the Oracle JDBC driver JAR into the /var/lib/oozie/ directory.