v1.2, 2024-09-25
This project includes a set of Dockerfiles that lets you build the Crunchy Certified PostgreSQL 9.5 Docker images.
The image by default is built on a RHEL 7.2 64 bit base, but can also be built on a centos 7 64 bit base. NOTE: to build the RHEL 7 version of this container, you need to build the Docker container on a licensed RHEL 7 host!
The containers will execute in a couple of environments:
-
Standalone - run the containers on a simple Docker environment
-
Openshift - run the containers within an Openshift environment
The project includes the following containers:
-
crunchy-postgres - executes Postgres
-
crunchy-backup - performs a full database backup
-
crunchy-pgpool - executes pgpool
-
crunchy-pgbadger - executes pgbadger
-
crunchy-watch - performs a form of automated failover
-
crunchy-collect - collects Postgres metrics
-
crunchy-prometheus -stores Postgres metrics
-
crunchy-grafana - graphs Postgres metrics
-
crunchy-dns - standalone DNS server useful for standalone execution
-
crunchy-vacuum - performs a Postgres VACUUM
-
crunchy-dba - cron scheduler, useful for routine DBA tasks
1) Installing / configuring Docker
On an EL7 system, docker can be installed with the following commands:
-
sudo yum -y install docker
-
sudo groupadd docker
-
sudo usermod -a -G docker ${USER}
-
sudo systemctl start docker
2) Installing / configuring Go
"Go" can be installed with the following command:
-
subscription-manager repos --enable=rhel-7-server-optional-rpms
-
sudo yum -y install golang
To build the containers, add the following lines to your environment, adjusting the GOPATH as fits your actual path:
export GOPATH=$HOME/cdev export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN
3) Add the wget dependency
-
sudo yum -y install wget
4) Setting up config files for compilation
In order to compile the openshift-dedicated-container code, two files must be placed in the conf directory:
-
crunchypg95.repo or crunchypg93.repo
-
CRUNCHY-GPG-KEY.public
Both of these files can be obtained with the following procedure:
-
Request an account on access.crunchydata.com
-
In the upper-right, click "Customer Log In"
-
Enter your provided username and password
-
Click "submit"
-
Read the terms of use and click "I agree"
-
Change your password (first login) by Clicking on "Profile" in the upper right; enter your old password, a new password, and click "Change password"
-
Click on "Downloads" in the upper right corner
-
The "Download GPG Key" button will automatically download the CRUNCHY-GPG-KEY.public file
-
The "Download repo file (RHEL)" button will automatically download a personalized (to your user) crunchypg95.repo file
To build the documentation, you need some things installed:
yum -y install asciidoc ruby gem install --pre asciidoctor-pdf cd $HOME wget http://laurent-laville.org/asciidoc/bootstrap/bootstrap-4.5.0.zip asciidoc --backend install ./bootstrap-4.5.0.zip mkdir -p .asciidoc/backends/bootstrap/js cp $GOPATH/src/github.com/crunchydata/crunchy-containers/docs/bootstrap.js .asciidoc/backends/bootstrap/js/
To build the watch container, there is a dependency on the openshift oc command, install it as follows:
cd /tmp wget https://github.com/openshift/origin/releases/download/v1.1.3/openshift-origin-client-tools-v1.1.3-cffae05-linux-64bit.tar.gz tar xvzf openshift-origin-client-tools-v1.1.3-cffae05-linux-64bit.tar.gz sudo cp openshift-origin-client-tools-v1.1.3-cffae05-linux-64bit/oc /usr/bin/oc
Build targets include two environment variables that determine the Docker base image to be used and the version of Postgresql to use.
Modify the following Makefile env variables for your desired target, currently rhel7 and centos7 are supported OS base images and 9.3 and 9.5 are supported versions of Postgresql:
OSFLAVOR=rhel7 PGVERSION=9.3
A complete build is performed as follows:
mkdir -p $HOME/cdev/pkg $HOME/cdev/bin $HOME/cdev/src cd $GOPATH go get github.com/tools/godep cd $GOPATH/src/github.com/ mkdir crunchydata cd crunchydata git clone https://github.com/crunchydata/crunchy-containers.git cd crunchy-containers git checkout 1.2 godep restore make downloadprometheus make downloadgrafana make all
For most of the examples, I use the psql command as a postgres client. To install PostgreSQL locally, run the following:
sudo cp crunchypg93.repo /etc/yum.repos.d sudo yum -y install postgresql93-server postgresql93
The installation of postgres locally is also required to create a postgres user and group which are used by the examples to set the correct file permissions on local files used by the containers.
There is a small test suite to test out your initial installation, you run it with the following command:
make test
Testing openshift is performed as follows:
make testopenshift
You can adjust the following Postgres configuration parameters by setting environment variables:
MAX_CONNECTIONS - defaults to 100 SHARED_BUFFERS - defaults to 128MB TEMP_BUFFERS - defaults to 8MB WORK_MEM - defaults to 4MB MAX_WAL_SENDERS - defaults to 6
You have the ability to override the pg_hba.conf and postgresql.conf files used by the container. To enable this, you create a directory to hold your own copy of these configuration files.
Then you mount that directory into the container using the /pgconf volume mount as follows:
-v $YOURDIRECTORY:/pgconf
Inside YOURDIRECTORY would be your pg_hba.conf and postgresql.conf files. These files are not manipulated or changed by the container start scripts.
Various examples are provided in the /examples directory.