Hue High Availability
This page explains how to configure Hue for high availability with Cloudera Manager and at the command line. It assumes that you have the Hue service installed and one or more Hue server roles defined. If not, see Adding a Hue Service and Role Instance.
Configuring a Cluster for Hue High Availability Using Cloudera Manager
Minimum Required Role: Cluster Administrator (also provided by Full Administrator)
In Cloudera Manager, you can configure your Hue cluster for high availability by adding a Hue load balancer and multiple Hue servers.
Prerequisite
- An external database was added and each Hue server is configured to use it. See Using an External Database for Hue Using Cloudera Manager.
Configuring Hue for High Availability in Cloudera Manager
- Go to the Hue service.
- Select the Hue Instances tab.
- Add one or more Hue servers to an existing Hue server role. At least two Hue server roles are required for high availability:
- Click Add Role Instances.
- Click Select hosts under Hue Server (HS).
- Check the box for each host on which you want a Hue server (which adds HS icons).
- Click OK.
- Add one load balancer:
- Click Select hosts under Load Balancer (LB).
- Check the box for the host on which you want the load balancer (which adds an LB icon).
- Click OK.
- Click Continue.
- Select the Configuration tab and review the options to ensure they meet your needs. Some items to consider are:
- Hue Load Balancer Port - The Apache Load Balancer listens on this port. The default is 8889.
- Path to TLS/SSL Certificate File - The TLS/SSL certificate file.
- Path to TLS/SSL Private Key File - The TLS/SSL private key file.
- Save any configuration changes.
- Start the load balancer and new Hue servers:
- Check the box by each new role type.
- Select .
- Click Start and Close.
For more information, see Automatic High Availability and Load Balancing of Hue.
Configuring a Cluster for Hue High Availability Using the Command Line
This section applies to unmanaged deployments without Cloudera Manager. It explains how to install and configure nginx from the command line. To make the Hue service highly available, configure at least two instances of the Hue service, each on a different host. Also configure the nginx load balancer to direct traffic to an alternate host if the primary host becomes unavailable. For advanced configurations, see the nginx documentation.
Prerequisites
- The Hue service is installed and two or more Hue server roles are configured.
- You have network access through SSH to the host machines with the Hue server role(s).
- An external database was added each Hue server is configured to use it. See Using an External Database for Hue Using Cloudera Manager.
Installing and Configuring the nginx Load Balancer
To enable high availability for Hue, install the nginx load balancer on one of the Hue instances. Clients access this instance through a designated port number, and the nginx load balancer directs the request to one of the Hue server instances.
- With SSH, log in as the root user to the host machine of one of the Hue instances.
- Install nginx:
Red Hat/Centos:
yum install nginx
Debian/Ubuntu:apt-get install nginx
- Create the following Hue cluster configuration file:
/etc/nginx/conf.d/hue.conf
- Configure hue.conf with the following template:
server { server_name NGINX_HOSTNAME; charset utf-8; listen 8001; # Or if running hue on https:// ## listen 8001 ssl; ## ssl_certificate /path/to/ssl/cert; ## ssl_certificate_key /path/to/ssl/key; client_max_body_size 0; location / { proxy_pass http://hue; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; # Or if the upstream Hue instances are running behind https:// ## proxy_pass https://hue; } location /static/ { # Uncomment to expose the static file directories. ## autoindex on; # If Hue was installed with packaging install: ## alias /usr/lib/hue/build/static/; # Or if on a parcel install: alias /opt/cloudera/parcels/CDH/lib/hue/build/static/; expires 30d; add_header Cache-Control public; } } upstream hue { ip_hash; # List all the Hue instances here for high availability. server HUE_HOST1:8888 max_fails=3; server HUE_HOST2:8888 max_fails=3; ... }
- Update the following in the hue.conf file:
- Replace NGINX_HOSTNAME with the URL of the host where you installed nginx. For example:
server_name myhost-2.myco.com;
- In the location/static block, comment or uncomment the alias lines, depending on whether your cluster was installed using parcels or packages. (The comment indicator is #.)
- In the upstream hue block, list all the hostnames, including port number, of the Hue instances in your cluster. For example:
server myhost-1.myco.com:8888 max_fails=3; server myhost-2.myco.com:8888 max_fails=3; server myhost-4.myco.com:8888 max_fails=3;
- If the Hue service in your cluster is configured to use TLS/SSL:
- Uncomment these lines, and replace the path names with the paths for your cluster:
## listen 8001 ssl; ## ssl_certificate /path/to/ssl/cert; ## ssl_certificate_key /path/to/ssl/key;
- Uncomment the following line in the location / block:
## proxy_pass https://hue;
and comment out the following line:proxy_pass http://hue;
- Comment out the following line:
listen 8001
- Uncomment these lines, and replace the path names with the paths for your cluster:
- Replace NGINX_HOSTNAME with the URL of the host where you installed nginx. For example:
- Start nginx:
sudo service nginx start
- Test your installation by opening the Hue application in a web browser, using the following URL:
-
Without TLS/SSL: http://NGINX_HOSTNAME:8001
-
With TLS/SSL: https://NGINX_HOSTNAME:8001
NGINX_HOSTNAME is the name of the host machine where you installed nginx.
-
- Test high availability:
- Stop the Hue service instance on the host where you installed nginx.
- Access the Hue application as described in the previous step. If you can connect to the Hue application, you have successfully enabled high availability.
- If necessary, configure your backend database for high availability. Consult the vendor documentation for the database that you configured for Hue.