{"id":18589414,"url":"https://github.com/pmorie/crunchy-postgres-container-94","last_synced_at":"2025-10-04T23:26:19.359Z","repository":{"id":35994319,"uuid":"40286166","full_name":"pmorie/crunchy-postgres-container-94","owner":"pmorie","description":null,"archived":false,"fork":false,"pushed_at":"2015-08-05T15:19:43.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-16T08:07:45.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmorie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-06T05:23:54.000Z","updated_at":"2016-01-30T17:54:44.000Z","dependencies_parsed_at":"2022-09-16T15:51:41.962Z","dependency_job_id":null,"html_url":"https://github.com/pmorie/crunchy-postgres-container-94","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pmorie/crunchy-postgres-container-94","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorie%2Fcrunchy-postgres-container-94","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorie%2Fcrunchy-postgres-container-94/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorie%2Fcrunchy-postgres-container-94/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorie%2Fcrunchy-postgres-container-94/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmorie","download_url":"https://codeload.github.com/pmorie/crunchy-postgres-container-94/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorie%2Fcrunchy-postgres-container-94/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278386765,"owners_count":25978231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T00:51:58.370Z","updated_at":"2025-10-04T23:26:19.326Z","avatar_url":"https://github.com/pmorie.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Crunchy PostgreSQL 9.4.4\n==========================\n\nThis project includes a Dockerfile that lets you build\na PostgreSQL 9.4.4 Docker image.  The image by default\nis built on a RHEL 7.1 64 bit base, but can also be built\non a centos 7 64 bit base.  NOTICE, to build the RHEL 7 \nversion of this container, you need to build the Docker\ncontainer on a licensed RHEL 7 host!\n\nInstallation\n------------\n\nBuilds are done by issuing the make command:\n~~~~~~~~~~~~~~~~~~~~~\nmake\n~~~~~~~~~~~~~~~~~~~~~\n \n\nRunning Postgresql in Standalone Mode\n------------\n\nTo run the Crunchy PG container on Openshift (v1.0.1), see\nthe document docs/openshift-setup-nodes.md for complete details\nand instructions.  The container has now been updated to run\nin a master-slave replication configuration as well as standalone.\n\nTo create the Docker container, you will need to have\nPostgreSQL installed on your local machine.  This is \ndue to the requirement of setting the data directory\nownership to the postgres user and also you will need\nthe psql command to test the container.\n\nTo install PostgreSQL locally, run the following:\n~~~~~~~~~~~~~~~~~~~~~\nsudo rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm\nsudo yum -y install postgresql94-server postgresql94\n~~~~~~~~~~~~~~~~~~~~~\n\nRun the container with this command:\n~~~~~~~~~~~~~~~~~~~~~\n./run-pg.sh\n~~~~~~~~~~~~~~~~~~~~~\n\nThis script will start up a container named crunchy-pg, it will\ncreate a data directory for the database in /tmp/crunchy-pg-data.\n\nIt will initialize the database using the passed in environment\nvariables, building a user, database, schema, and table based\non the environment variable values.\n\nThe script also maps the PostgreSQL port of 5432 in the container\nto your local host port of 12000.\n\n\nConnecting to  PostgreSQL\n------------\n\nThe container creates a default database called 'testdb', a default\nuser called 'testuser' with a default password of 'testpsw', you can\nuse this to connect from your local host as follows:\n~~~~~~~~~~~~~~~~~~~~~\npsql -h localhost -p 12000 -U testuser -W testdb\n~~~~~~~~~~~~~~~~~~~~~\n\n\nShutting Down \n------------\n\nTo shut down the instance, run the following commands:\n\n~~~~~~~~~~~~~~~~~~~~~\ndocker stop crunchy-pg\n~~~~~~~~~~~~~~~~~~~~~\n\t\n\nTo start the instance, run the following commands:\n\n~~~~~~~~~~~~~~~~~~~~~\ndocker start crunchy-pg\n~~~~~~~~~~~~~~~~~~~~~\n\t\nRunning Postgresql in Master-Slave Configuration\n------------\nThe container can be passed environment variables that will cause\nit to assume a PostgreSQL replication configuration with \na master instance streaming to a slave replica instance.\n\nThe following env variables are specified for this configuration option:\n~~~~~~~~~~~~~~~~~~~\nPG_MASTER_USER - The username used for master-slave replication value=master\nPG_MASTER_PASSWORD - The password for the PG master user\nPG_USER - The username that clients will use to connect to PG server value=user\nPG_PASSWORD  - The password for the PG master user\nPG_DATABASE - The name of the database that will be created value=userdb\nPG_ROOT_PASSWORD - The password for the PG admin\n~~~~~~~~~~~~~~~~~~~\n\nThe openshift sample template specifies values for these env variables.\n\nTo run the crunchy-pg container outside of Openshift, and when you\nwant a master-slave configuration, you would pass in suitable values\nfor these env variables when you run the container and you will\nneed a Docker-DNS bridge similar to what Crunchy PostgreSQL Manager\nuses, skybridge.  \n\nSee these for more details:\n~~~~~~~~~~~~~~~~~~~~~~~~~~\nhttps://github.com/CrunchyData/crunchy-postgresql-manager\nhttps://github.com/CrunchyData/skybridge\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDNS names are used within the PostgreSQL replication configuration\nwhereas the slave can find the master by hostname instead of IP address.\nOpenshift includes a DNS-to-Docker bridge for you.\n\n\n\n# crunchy-pg on Openshift\ncrunchy-pg is a container image that allows you to run\nPostgresql 9.4.4 within Openshift (v.1.0.3).\n\nThere are 4 possible scenarios that are included in this\nrepository:\n- standalone (emptydir volume)\n- master-slave (emptydir volumes, one master and one slave)\n- master-slave using replication controllers (emptydir volumes)\n- standalone (nfs volume)\n\n\n## Openshift Configuration\n\nThis example uses Openshift/Kube EmptyDir volumes to hold \nthe Postgresql data files.\n\nAt the moment, to run this example in Selinux Enforcing mode, \nthere is a slight bug in the selinux labels\non the Openshift /var/lib/openshift directory.  As root\nyou will need to run the following command to set the selinux\nlabels to the correct values:\n~~~~~~~~~~~~~~~~~\nchcon -Rt svirt_sandbox_file_t /var/lib/openshift\n~~~~~~~~~~~~~~~~~\n\nThis is being tracked with an Openshift github issue.\n\nhttps://github.com/openshift/origin/issues/3989\n\n## Finding the Postgresql Passwords\n\nThe passwords used for the Postgresql user accounts are generated\nby the Openshift 'process' command.  To inspect what value was\nsupplied, you can inspect the master pod as follows:\n\n~~~~~~~~~~~~~~~\noc get pod pg-master-rc-1-n5z8r -o json\n~~~~~~~~~~~~~~~\n\nLook for the values of the environment variables:\n- PG_USER\n- PG_PASSWORD\n- PG_DATABASE\n\n## DNS Names\n\nThis example used an Openshift project name of 'pgproject'.  The\nproject name is used as part of the DNS names set by Openshift\nfor Services.  \n\n## standalone.json\n\nThis openshift template will create a single Postgresql instance.\n\n### Running the example\n\n~~~~~~~~~~~~~~~~\noc create -f standalone.json | oc create -f -\n~~~~~~~~~~~~~~~~\n\nThen in the running standalone pod, you can run the following\ncommand to test the database:\n\n~~~~~~~~~~~~~~\npsql -h pg-standalone.pgproject.svc.cluster.local -U testuser userdb\n~~~~~~~~~~~~~~\n\n\n## master-slave.json\n\nThis openshift template will create a single master Postgresql instance\nand a single slave instance, configured for streaming replication.\n\n### Running the example\n\n~~~~~~~~~~~~~~~~\noc create -f master-slave.json | oc create -f -\n~~~~~~~~~~~~~~~~\n\nThen in the running standalone pod, you can run the following\ncommand to test the database:\n\n~~~~~~~~~~~~~~\npsql -h pg-master.pgproject.svc.cluster.local -U testuser userdb\npsql -h pg-slave.pgproject.svc.cluster.local -U testuser userdb\n~~~~~~~~~~~~~~\n\n## master-slave-rc.json\n\nThis openshift template will create a single master Postgresql instance\nand a single slave instance, configured as a Replication Controller, allowing\nyou to scale up the number of slave instances.\n\n### Running the example\n\n~~~~~~~~~~~~~~~~\noc create -f master-slave-rc.json | oc create -f -\n~~~~~~~~~~~~~~~~\n\nConnect to the postgresql instances with the following:\n\n~~~~~~~~~~~~~~\npsql -h pg-master-rc.pgproject.svc.cluster.local -U testuser userdb\npsql -h pg-slave-rc.pgproject.svc.cluster.local -U testuser userdb\n~~~~~~~~~~~~~~\n\n## Scaling up Slaves\nHere is an example of increasing or scaling up the Postgres 'slave'\npods to 2:\n~~~~~~~~~~\noc scale rc pg-slave-rc-1 --replicas=2\n~~~~~~~~~~\n\n## Verify Postgresql Replication is Working\n\nEnter the following commands to verify the Postgresql \nreplication is working.\n\nFirst, find the pods:\n\n~~~~~~~~~~~~~~~~\n[root@origin openshift]# oc get pods\nNAME                      READY     STATUS    RESTARTS   AGE\ndocker-registry-1-vrli4   1/1       Running   1          6h\npg-master-rc-1-n5z8r      1/1       Running   0          15m\npg-slave-rc-1-4gsfo       1/1       Running   0          15m\npg-slave-rc-1-f1rlo       1/1       Running   0          11m\n~~~~~~~~~~~~~~~~~\n\nNext, exec into the master pod:\n\n~~~~~~~~~~~~~~~~~~~~~\n[root@origin openshift]# oc exec -it pg-master-rc-1-n5z8r /bin/bash\n\n~~~~~~~~~~~~~~~~~~~~~~~\n\nNext, run the psql command to view the replication status, you\nshould see something similar to this output, in this example \nwe are replicating database state to 2 pods:\n\n~~~~~~~~~~~~~~~~~\nbash-4.2$ psql -U postgres postgres\npsql (9.4.4)\nType \"help\" for help.\n\npostgres=# select * from pg_stat_replication;\n pid | usesysid | usename | application_name | client_addr | client_hostname | client_port |         backend_start         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | sync_priority | sync_state \n -----+----------+---------+------------------+-------------+-----------------+-------------+-------------------------------+--------------+-----------+---------------+----------------+----------------+-----------------+---------------+------------\n   86 |    16384 | master  | walreceiver      | 172.17.0.11 |                 |       34522 | 2015-07-26 20:26:39.688865-04 |              | streaming | 0/5000210     | 0/5000210      | 0/5000210      | 0/5000210       |             0 | async\n    130 |    16384 | master  | walreceiver      | 172.17.0.13 |                 |       37211 | 2015-07-26 20:30:41.29627-04  |              | streaming | 0/5000210     | 0/5000210      | 0/5000210      | 0/5000210       |             0 | async\n    (2 rows)\n~~~~~~~~~~~~~~~~~\n\n\n## NFS Example\n\nI have provided an example of using NFS for the postgres data volume.\nThe NFS example is able to run in selinux Enforcing mode if you \nfollowing the instructions here:\n\nhttps://github.com/openshift/origin/tree/master/examples/wordpress\n\nTo run it, you would execute the following as the openshift administrator:\n\n~~~~~~~~~~~~~~~\noc create -f pv.json\n~~~~~~~~~~~~~~~\n\nThen as the normal openshift user account, create the Persistence Volume\nClaim as follows:\n~~~~~~~~~~~~~~~\noc create -f pvc.json\n~~~~~~~~~~~~~~~\n\nLastly,  as the normal openshift user account, create the standalone\npod which specifies the NFS PVC:\n~~~~~~~~~~~~~~~\noc process -f standalone-nfs.json | oc create -f -\n~~~~~~~~~~~~~~~\n\nThis will create a single standalone postgres pod that is using \nan NFS volume to store the postgres data files.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmorie%2Fcrunchy-postgres-container-94","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmorie%2Fcrunchy-postgres-container-94","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmorie%2Fcrunchy-postgres-container-94/lists"}