Skip to content

PL Container

Hubert Zhang edited this page Jan 16, 2018 · 4 revisions

Milestone

  • Basic Functionality ready: Run simple functions in container (finished)
  • Full Functionality ready: Run complex functions in container (finished)
  • User Experience Improvement (finished)
  • Resource Management (in-progress)

User Guide

To setup an environment to test PL/Container, you should follow the steps as belows:

  1. Ensure to meet the prerequisites.
    Greenplum database version: 5.2.0 and later.(postgresql support in ongoing)
    Redhat/Centos version: 7.x or 6.6 and later
    Docker version: 17.05 and later on Redhat/Centos7 or 1.7 and later on Redhat/Centos6

  2. Install the PL/Container extension
    As a developer, you should build and install PL/Container according to the guide https://github.com/greenplum-db/plcontainer#building-plcontainer-language
    As a normal user, you should install PL/Container by running:
    Install package: gppkg -i plcontainer-1.0.0-rhel7-x86_64.gppkg
    Reload environment variable: source $GPHOME/greenplum_path.sh
    Restart Greenplum Database: gpstop -ra
    Install PL/Container environment: psql -d your_database -f $GPHOME/share/postgresql/plcontainer/plcontainer_install.sql

  3. Install Docker images
    Using plcontainer command to install the Docker image for PL/Python from a Docker image file: plcontainer image-add -i /home/gpadmin/plcontainer-python-images-1.0.0.tar.gz
    Using plcontainer command to install the Docker image for PL/R from a Docker image file: plcontainer image-add -i /home/gpadmin/plcontainer-r-images-1.0.0.tar.gz

  4. Add PL/Container runtimes
    Using plcontainer command to install the python runtime: plcontainer runtime-add -r plc_python_shared -i pivotaldata/plcontainer_python_shared:devel -l python
    Using plcontainer command to install the r runtime: plcontainer runtime-add -r plc_r_shared -i pivotaldata/plcontainer_r_shared:devel -l r

  5. Example to create and run PL/Container function:

CREATE OR REPLACE FUNCTION pylog100() RETURNS double precision AS $$
# container: plc_python_shared
import math
return math.log10(100)
$$ LANGUAGE plcontainer;

select pylog100() from a;