After you install PXF on every host in your WarehousePG (WHPG) cluster, set up its environment, initialize and start the service, and create the pxf extension.
Setting environment variables
Set $PXF_HOME to the directory created during installation, so PXF and your shell can find the PXF service and its default configuration templates. PXF also needs a separate, writable runtime directory, $PXF_BASE, where your per-cluster configuration, server definitions, and logs live. Keeping $PXF_BASE separate from $PXF_HOME means a PXF upgrade doesn't overwrite your configuration.
On the coordinator, set PXF_HOME, PXF_BASE, and add the PXF bin directory to your PATH:
export PXF_HOME=/usr/local/pxf
export PXF_BASE=$HOME/pxf-base
export PATH="$PXF_HOME/bin:$PATH"Add these lines to ~/.bashrc on the coordinator so they persist across sessions.
Initializing and starting PXF
Set up PXF's runtime configuration across the cluster and start the service, so PXF is ready to handle queries. Run the following commands from the coordinator host. Each pxf cluster command applies the action to every host in the cluster.
Create the runtime configuration directory on every host:
bashpxf cluster prepareThis command creates
$PXF_BASEon every host and copies the default configuration templates from$PXF_HOME/confinto it. If$PXF_BASEdoesn't already exist,pxf cluster preparecreates it for you.Set
JAVA_HOMEin$PXF_BASE/conf/pxf-env.shon the coordinator:bashecho "export JAVA_HOME=$(readlink -f $(which java) | sed 's:/bin/java$::')" >> $PXF_BASE/conf/pxf-env.shSync the change to every host:
bashpxf cluster syncStart the PXF Java service on every host, listening on port 5888 by default:
bashpxf cluster startConfirm PXF is running on every host:
bashpxf cluster status __OUTPUT__ Checking status of PXF servers on coordinator host and 2 segment hosts... PXF is running on 3 out of 3 hosts
Creating the PXF extension
Create the pxf extension in each database that needs external table access. pxf cluster register, run as the last step of installing PXF, already placed the extension's control, SQL, and shared library files under $GPHOME on every host, so you don't need to repeat it here.
Connect to the target database and create the extension:
sqlCREATE EXTENSION IF NOT EXISTS pxf;If the extension already exists from a previous PXF version, update it instead:
sqlALTER EXTENSION pxf UPDATE;Repeat this step in every database where you want to query external tables.
Grant roles access. Only WHPG superusers can use the
pxfprotocol by default, so grantSELECTto let a role read external tables through PXF, andINSERTto let it write them:sqlGRANT SELECT ON PROTOCOL pxf TO <role_name>; GRANT INSERT ON PROTOCOL pxf TO <role_name>;
Note
If you need to drop the pxf extension, use DROP EXTENSION pxf CASCADE to drop it along with any external table still using the pxf protocol.
Next steps
See Managing the PXF cluster for the PXF configuration files and ongoing cluster management commands, or go straight to configuring a connector, such as Object stores or Hadoop, to reach an external data source.
