提交 3183577d 编写于 作者: J Joao Pereira

Update GreenPlum Docker image:

 .Smaller image size
 .Change the role from gp to gpadmin
 .Remove libraries that are not needed
上级 a02dd9d0
# currently published as pivotaldata/pgadmin:gpdb-5 # currently published as pivotaldata/gpdb5:latest
FROM ubuntu:16.04 FROM ubuntu:16.04
...@@ -6,53 +6,41 @@ EXPOSE 5432 ...@@ -6,53 +6,41 @@ EXPOSE 5432
# explicitly set user/group IDs # explicitly set user/group IDs
RUN groupadd -r postgres --gid=999 && useradd -m -r -g postgres --uid=999 postgres RUN groupadd -r postgres --gid=999 && useradd -m -r -g postgres --uid=999 postgres
RUN apt-get update && apt-get install -y dirmngr
# Install initial dependencies
# grab gosu for easy step-down from root RUN apt-get update \
ENV GOSU_VERSION 1.7 && apt-get install -y dirmngr software-properties-common python-software-properties less ssh sudo
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ # Install GreenPlum
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ && add-apt-repository ppa:greenplum/db \
&& export GNUPGHOME="$(mktemp -d)" \ && apt update \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ && apt install -y greenplum-db-oss \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ && locale-gen en_US.utf8
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \ # Create GreenPlum data folders and copy/edit configuration to use a single node
&& gosu nobody true RUN mkdir /data \
&& mkdir /data/data1 \
RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && mkdir /data/data2 \
&& mkdir /data/master \
RUN apt update && . /opt/gpdb/greenplum_path.sh && cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_singlenode /data/ \
RUN apt install -y software-properties-common python-software-properties less && sed -i 's/gpdata1/data\/data1/g' /data/gpinitsystem_singlenode \
RUN add-apt-repository ppa:greenplum/db && sed -i 's/gpdata2/data\/data2/g' /data/gpinitsystem_singlenode \
RUN apt update && sed -i 's/gpmaster/data\/master/g' /data/gpinitsystem_singlenode
RUN apt install -y greenplum-db-oss
RUN . /opt/gpdb/greenplum_path.sh # Create gpadmin user and add the user to the sudoers
RUN useradd -md /home/gpadmin/ gpadmin \
RUN locale-gen en_US.utf8 && chown gpadmin -R /data \
RUN mkdir /gpdata && echo "source /opt/gpdb/greenplum_path.sh" > /home/gpadmin/.bash_profile && chown gpadmin:gpadmin /home/gpadmin/.bash_profile \
RUN mkdir /gpdata/gpdata1 && su - gpadmin bash -c 'mkdir /home/gpadmin/.ssh' \
RUN mkdir /gpdata/gpdata2 && echo "gpadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
RUN mkdir /gpdata/gpmaster && echo "root ALL=NOPASSWD: ALL" >> /etc/sudoers
RUN . /opt/gpdb/greenplum_path.sh && cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_singlenode /gpdata/
RUN sed -i 's/gpdata1/gpdata\/gpdata1/g' /gpdata/gpinitsystem_singlenode
RUN sed -i 's/gpdata2/gpdata\/gpdata2/g' /gpdata/gpinitsystem_singlenode ## Add setup and start script to run when the container starts
RUN sed -i 's/gpmaster/gpdata\/gpmaster/g' /gpdata/gpinitsystem_singlenode ADD install_and_start_gpdb.sh /home/gpadmin/install_and_start_gpdb.sh
RUN apt install -y ssh RUN chown gpadmin:gpadmin /home/gpadmin/install_and_start_gpdb.sh \
&& chmod a+x /home/gpadmin/install_and_start_gpdb.sh
RUN useradd -md /home/gp/ gp
RUN chown gp -R /gpdata CMD sudo su - gpadmin bash -c /home/gpadmin/install_and_start_gpdb.sh && tail -f /dev/null
RUN echo "source /opt/gpdb/greenplum_path.sh" > /home/gp/.bash_profile && chown gp:gp /home/gp/.bash_profile
RUN su - gp bash -c 'mkdir /home/gp/.ssh'
ADD install_and_start_gpdb.sh /home/gp/install_and_start_gpdb.sh
RUN chown gp:gp /home/gp/install_and_start_gpdb.sh
RUN chmod a+x /home/gp/install_and_start_gpdb.sh
RUN apt-get install -y sudo
RUN echo "gp ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN echo "root ALL=NOPASSWD: ALL" >> /etc/sudoers
CMD sudo su - gp bash -c /home/gp/install_and_start_gpdb.sh && tail -f /dev/null
# Docker container with Version 5.4 of GPDB running # Docker container running the latest GPDB version available for ubuntu
## Build your own container ## Build your own container
``` ```
docker build -t pivotaldata/gpdb:5.4 ubuntu-16.04 docker build -t pivotaldata/gpdb5:latest ubuntu-16.04
``` ```
## Run the container ## Run the container
...@@ -12,7 +12,7 @@ The container will keep running forever until it is stopped and the GreenPlum da ...@@ -12,7 +12,7 @@ The container will keep running forever until it is stopped and the GreenPlum da
will be listenning in the port `localhost:5433` will be listenning in the port `localhost:5433`
``` ```
docker run -dp 127.0.0.1:5433:5432 pivotaldata/gpdb:5.4 docker run -dp 127.0.0.1:5433:5432 pivotaldata/gpdb5:latest
``` ```
_The container takes around 30 seconds to instantiate and start the new GP Instance_ _The container takes around 30 seconds to instantiate and start the new GP Instance_
......
sudo /etc/init.d/ssh start sudo /etc/init.d/ssh start
sleep 2 sleep 2
source /home/gp/.bash_profile source /home/gpadmin/.bash_profile
ssh-keygen -f /home/gp/.ssh/id_rsa -t rsa -N "" ssh-keygen -f /home/gpadmin/.ssh/id_rsa -t rsa -N ""
echo `hostname` > /gpdata/hostlist_singlenode echo `hostname` > /data/hostlist_singlenode
sed -i 's/hostname_of_machine/`hostname`/g' /gpdata/gpinitsystem_singlenode sed -i 's/hostname_of_machine/`hostname`/g' /data/gpinitsystem_singlenode
gpssh-exkeys -f /gpdata/hostlist_singlenode gpssh-exkeys -f /data/hostlist_singlenode
pushd /gpdata pushd /data
gpinitsystem -ac gpinitsystem_singlenode gpinitsystem -ac gpinitsystem_singlenode
echo "host all all 0.0.0.0/0 trust" >> /gpdata/gpmaster/gpsne-1/pg_hba.conf echo "host all all 0.0.0.0/0 trust" >> /data/master/gpsne-1/pg_hba.conf
MASTER_DATA_DIRECTORY=/gpdata/gpmaster/gpsne-1/ gpstop -a MASTER_DATA_DIRECTORY=/data/master/gpsne-1/ gpstop -a
MASTER_DATA_DIRECTORY=/gpdata/gpmaster/gpsne-1/ gpstart -a MASTER_DATA_DIRECTORY=/data/master/gpsne-1/ gpstart -a
popd popd
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册