7.3.  Using Hue with PostgreSQL

To set up Hue to use a PostgreSQL database:

  1. Create a database in PostgreSQL using the PostgreSQL database admin utility:

    # sudo -u postgres psql 
    CREATE DATABASE $DBNAME; 
  2. Exit the database admin utility.

    \q <enter>
  3. Create the Hue user:

    # sudo -u postgres psql -d $DBNAME 
    CREATE USER $HUEUSER WITH PASSWORD '$HUEPASSWORD';

    Where $HUEUSER is the Hue user name and $HUEPASSWORD is the Hue user password.

  4. Open the /etc/hue/conf/hue.ini file and edit the [[database]] section (modify for your PostgreSQL setup).

    [[database]]
    engine=postgresql_psycopg2
    host=$DATABASEIPADDRESSORHOSTNAME
    port=$PORT
    user=$HUEUSER
    password=$HUEPASSWORD
    name=$DBNAME
  5. Install the PostgreSQL database adapter for Python (psycopg2):

     RHEL/CentOS/Oracle Linux

    yum install python-devel -y 
    yum install postgresql-devel -y 
    cd /usr/lib/hue 
    source build/env/bin/activate 
    pip install psycopg2 
  6. Synchronize Hue with the external database to create the schema and load the data:

    /usr/lib/hue/build/env/bin/hue syncdb --noinput
  7. Start Hue:

    # /etc/init.d/hue start


loading table of contents...