How make puppet install postgresql in the given address - postgresql

I have a postgresql database cluster with one master and one standby node, I want to setup the puppet module for only configuring the database nodes and not installing postgresql, but the problem is that if I run the 'puppet agent -t' command, puppet will try to install a new postgresql in '/var/lib/pgsql/postgresql-10.21/' while my current database is installed in 'var/lib/pgsql'.
So my question is that how to force puppet to use /var/lib/pgsql as the correct directory and not try to install a new postgresql database?
I removed this part which is for installing the database in puppet module:
postgresql::server::db { 'mydb':
user => 'dbuser',
password => postgresql_password('dbuser', hiera('mydb_pass')),
grant => 'all',
encoding => 'UNICODE',
locale => 'C',
}
but I still get this error messages by running 'sudo puppet agent -t --noop':
symlink_realpath(/etc/sysconfig/pgsql/postgresql-10.21) realpath() failed: No such file or directory
symlink_realpath(/etc/sysconfig/pgsql/postgresql-10.21) realpath() failed: No such file or directory
symlink_realpath(/etc/sysconfig/pgsql/postgresql-10.21) realpath() failed: No such file or directory
symlink_realpath(/etc/sysconfig/pgsql/postgresql-10.21) realpath() failed: No such file or directory

Related

Citus 10.2 not starting an instance of PostgreSQL

I'm using RHEL 8.4 and I followed the installation instruction at Set up a single-node Citus cluster on your own Linux machine from RPM packages..
Step 1 and 2 (Install PostgreSQL 14 and the Citus extension and Initialize the Cluster) went through without any issues.
But When I tried (Step 3: Start the database server)
pg_ctl -D citus -o "-p 9700" -l citus_logfile start
I got the following error in terminal
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
The log output
FATAL: could not access file "citus": No such file or directory
LOG: database system is shut down
I do have a directory 'citus' in postgres user's home directory with all required files in it along with postgresql.conf
Kindly help.
It appears you ran into one of 2 issues:
Possible issue #1:
You did not successfully install citus package and the citus.so file is missing.
Can you see the file /usr/pgsql-14/lib/citus.so that should be installed via the package citus102_14?
If that is not the case, you should figure out why the package is not installed.
Possible issue #2
You do not run pg_ctl command in the home directory of postgres user.
I was getting the same error. I am using the Postgres compiled from the source file. Thus, instead of
sudo apt-get -y install postgresql-14-citus-10.2
I compiled the source of the Citus from Github and specified the path to location of my Postgres while configuring as:
git clone https://github.com/citusdata/citus.git
cd citus
./configure --prefix=/usr/local/pgsql/
make
sudo make install
I do not get an error during pg_ctl start and I can load extension as CREATE EXTENSION citus;.

Docker PostgreSQL 9.6 - installing extension plpython3u (clashing with quantile extension)

I am trying to install a PostgreSQL dockerised service, with plpython. I am able to build the image successfully, but when I come to run the container, I get the following error:
ERROR: could not open extension control file
"/usr/share/postgresql/9.5/extension/plpython3u.control": No such file
or directory STATEMENT: CREATE EXTENSION "plpython3u";
psql:/docker-entrypoint-initdb.d/create_db.sql:7: ERROR: could not
open extension control file
"/usr/share/postgresql/9.5/extension/plpython3u.control": No such file
or directory
my directory layout:
me#yourbox:~/Projects/experimental/docker/scratchdb$ tree
.
├── Dockerfile
└── sql
├── create_db.sql
└── schemas
└── DDL
└── db_schema_foo.sql
Dockerfile
FROM library/postgres:9.6
FROM zitsen/postgres-pgxn
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 postgresql-plpython3-9.6
RUN pgxn install quantile
COPY sql /docker-entrypoint-initdb.d/
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
# CMD ["/usr/lib/postgresql/9.6/bin/postgres", "-D", "/var/lib/postgresql/9.6/main", "-c", "config_file=/etc/postgresql/9.6/main/postgresql.conf"]
create_db.sql
# Uncomment line below for debugging purposes
set client_min_messages TO debug1;
CREATE EXTENSION "quantile"
CREATE EXTENSION "plpython3u";
-- Create myappuser
CREATE ROLE myappuser LOGIN ENCRYPTED PASSWORD 'passw0rd123' NOINHERIT;
CREATE DATABASE only_foo_and_horses WITH ENCODING 'UTF8' TEMPLATE template1;
-- \l+
GRANT ALL PRIVILEGES ON DATABASE only_foo_and_horses TO myappuser;
-- Import only_foo_and_horses DDL and initialise database data
\c only_foo_and_horses;
\i /docker-entrypoint-initdb.d/schemas/DDL/db_schema_foo.sql;
-- # enable python in database
[[Edit]]
These are the commands I use to build and run the container:
docker build -t scratch:pg .
docker run -it -rm scratch:pg
How do I install plpython in a dockerised PostgreSQL service?
I think your error was because of the initial erroneous CMD which pointed to the wrong location of PostgreSQL for this image (9.5 vs 9.6).
However, I think I've spotted the mistake for why the SQL isn't being imported.
The default ENTRYPOINT for this image (at https://github.com/docker-library/postgres/blob/bef8f02d1fe2bb4547280ba609f19abd20230180/9.6/docker-entrypoint.sh) is responsible for importing from /docker-entrypoint-initdb.d/. Since you are overwriting CMD and it is not equal to just postgresql, it is skipping this part.
The default ENTRYPOINT should do what you want. Try removing your CMD.
I have just run this all from scratch and seems extension have been successfully created. Is there still an issue ?
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/create_db.sql
SET
CREATE EXTENSION
CREATE ROLE
CREATE DATABASE
GRANT
LOG: received fast shutdown request
waiting for server to shut down...LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
.LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.

Postgres - Homebrew Install Cannot Find Server Files Multiple Versions

I am trying to use postgres on my machine and realized that some time ago I had installed the database software after running brew install postgres and receiving Error: postgresql-9.4.5_2 already installed. From there I decided to install homebrew/services to be able to run postgres in the background and successfully launched and closed the background job with
brew services start postgresql==> Successfully startedpostgresql(label: homebrew.mxcl.postgresql)
However, when I run postgres I received the error of:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
When I followed an answer on SO, cat /usr/local/var/postgres/server.log I received the following error:
LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.5.
Which makes me think that I had an older version of PostgreSQL installed that needs to be removed.
I then tried psql and received:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
And finally decided to init a new db with initdb /usr/local/var/postgres, but that didn't fix it, which resulted in following the original message and setting an env varible: export PGDATA=/usr/local/var/postgres. After trying postgres again, I receive
LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.5.
What this tells me is that there is clearly a version compatibility issue, which needs to be resolved in order to launch my postgres server, but I'm not sure what file paths need to be cleared or the proper way to clear them. Can anyone provide some guidance?
I had the same problem and I got it to work by running:
pg_ctl -D /usr/local/var/postgres start && brew services start postgresql
(this guide was good).

Installing postgresql on CentOS 5.5 postgresql-setup initdb command not found error

I was following these steps to install postgresql and then odoo v9 :
https://www.odoo.com/documentation/9.0/setup/install.html
Basically it follows these steps outlined here:
https://www.odoo.com/forum/help-1/question/issue-while-installing-following-the-instructions-for-packaged-installers-rpm-93756
I get exactly the same situation. The first steps go through without issue but then the postgresql-setup initdb command cannot be found.
I have root access to the server and I know it's running centOS5.5. How can I troubleshoot this? I believe I installed the 9.4 version but when I do psql -V I get the server has v8.3.
I ran some commands on the server and here are the results:
postgresql-setup initdb
command cannot be found
postgres
root execution is not permitted, server must be restarted as underprivileged id...
initdb
no data directory specified, you must identify dir where datase system will reside
locate postgresql
i get an .rb, .xml and .yml files
locate psql
/usr/lib64 - a few libodbcpsql.so files
pqsl -V
8.1.23
I get command not found for all other commands in the list of commands to install odoo up until sudo yum config manager --add-repo etc...
sudo su postgres -c "psql -c 'show data_directory'"
could not change directory to 'the directory im currently in on my server'

Shell script - connecting to Heroku database while running on (different) Heroku dyno?

I currently have a production PostgreSQL database running on a separate Heroku dyno.
I'd like to deploy a simple shell script on a different dyno (for a number of reasons), that among other things, will reset the database every 2 weeks.
I've tried using both the heroku and psql commands to connect to my database in my script, but unfortunately I get the following errors:
$ heroku pg:psql DATABASE_URL
bash: heroku: command not found
Which makes sense because the Heroku toolbelt isn't installed on a heroku dyno.
And then:
$ psql -h DATABASE_HOST -p
Error: You must install at least one postgresql-client-<version> package
Unfortunately, you can't do a simple apt-get install postgresql-client because Heroku prevents you from being able to install packages. (You'll get the following error):
~ $ apt-get install postgresql-client
W: Not using locking for read only lock file /var/lib/dpkg/lock
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.
Is there any workaround for this? I know I could write a python script and use a pip module to connect to the database, but I'd rather this be a shell script to build off an existing one.
Thanks.