1

I am trying to install the pglogical extension in my postgres database, which I installed on my macOS with homebrew. I am following instructions provided on the GCP blog as I am preparing to migrate my database to CloudSQl with Database Migration Service.

I am struggling to complete the following step of these steps, and could use some advice:

Find where Homebrew installed Postgres, find include folder, add all include folders to C_INCLUDE_PATH

My questions are:

  • I found the include folder with pg_config --includedir
  • But now, where is the pglogical C_INCLUDE_PATH variable? (I searched the pglogical repo and didn't find it) Or where do I create the C_INCLUDE_PATH variable?
  • Am I to add all subdirectories of the include folder to the C_INCLUDE_PATH variable?

When I run make in the pglogical repo, I get the following:

sed 's/__PGLOGICAL_VERSION__/2.4.1/;s/__REQUIRES__//' /.../.../Documents/pglogical/pglogical.control.in > /.../.../Documents/pglogical/pglogical.control

1 Answer 1

1

pglogical is a third party postgreSQL extension provided by 2ndQuadrant and is not part of PostgreSQL. Some of it is written in C++, so must be compiled and built on the platform that it runs on. While many prebuilt tools and packages are available for macos via homebrew, pglogical doesn't seem to be one -- it was my search for this that led me to your question.

Options are:

  • build, install, and enable a version for macos from source code
  • install one of the packaged linux versions in a Docker container alongside postgres
  • run against a version on your cloud provider (I am using AWS, looks like you're on GCP)

Building and installing on macos is pretty straightforward. In my case, I installed postgresql (14.1) using homebrew. Once complete:

  • clone the pglogical extension from github
  • ensure that you have XCode and command-line tools installed -- run brew doctor if you're not sure
  • follow instructions for "unix-like platforms" here:
    • make PG_CONFIG=/usr/local/Cellar/postgresql/14.1_1/bin/pg_config
    • make PG_CONFIG=/usr/local/Cellar/postgresql/14.1_1/bin/pg_config install

Next, add the extension to shared_preload_libraries in postgres:

  • cd /usr/local/var/postgres
  • edit postgresql.conf
    • find the commented line shared_preload_libraries
    • add a line shared_preload_libraries = 'pglogical';
  • restart postgres (with homebrew: brew services restart postgresql)

Finally, enable the extension in your local server:

  • psql
    • CREATE EXTENSION pglogical which should respond with
    • CREATE EXTENSION

This all worked for me! Hope your luck is as good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.