find out which class is missing - centos

I was trying to install liquibase on my CentOS 6.9 it needs java (i have openjdk version "1.8.0_121") but i got this error:
[root#sampleliquibase-3.6.2-bin..z]# ll
total 11412
drwxrwxrwx. 2 db2inst1 db2iadm1 4096 Dec 17 13:10 lib
-rwxrwxrwx. 1 db2inst1 db2iadm1 11358 Jul 3 23:27 LICENSE.txt
-rwxrwxrwx. 1 db2inst1 db2iadm1 1251 Jul 3 23:27 liquibase
-rwxrwxrwx. 1 db2inst1 db2iadm1 9406606 Dec 17 09:42 liquibase-3.6.2-
bin.zip
-rwxrwxrwx. 1 db2inst1 db2iadm1 884 Jul 3 23:27 liquibase.bat
-rwxrwxrwx. 1 db2inst1 db2iadm1 2167086 Jul 3 23:30 liquibase.jar
-rwxrwxrwx. 1 db2inst1 db2iadm1 7174 Jul 3 23:27 liquibase.spec
-rwxrwxrwx. 1 db2inst1 db2iadm1 3046 Jul 3 23:27 README.txt
drwxrwxrwx. 6 db2inst1 db2iadm1 4096 Dec 17 13:10 sdk
-rwxrwxrwx. 1 root root 41203 Mar 16 2017 slf4j-api-1.7.25.jar
[root#sampleliquibase-3.6.2-bin..z]# java -jar liquibase.jar
Error: A JNI error has occurred, please check your installation and try
again
Exception in thread "main" java.lang.NoClassDefFoundError:
ch/qos/logback/core/filter/Filter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at
sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
ch.qos.logback.core.filter.Filter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
[root#sampleliquibase-3.6.2-bin..z]#
I think some kind of class is missing but i dont know which one is and how i can add it to java classes. what should I do?

ch/qos/logback/core/filter/Filter
aka
ch.qos.logback.core.filter.Filter
is missing which is part of Logback, you can add it to the application using your buildscript. Or manually install it to your lib folder from https://mvnrepository.com/artifact/ch.qos.logback/logback-core
Maybe you are launching the wrong file. Instead of running the jar directly you might have to run the "launcher" script instead.

Related

CentOS 7, PostgreSQL 9.2.18 - Can't access $libdir/postgis-2.0

this is my first question on StackOverflow, hope I found some answers :D
I'm currently working on a database that I got to restore using Postgis. I installed that extension, but Postgres is unable to find it.
I'm working on a VM based on CentOS 7 that my boss gave me to troubleshoot this issue. He told me the VM, for prod purposes, had to use Postgre 9.2, that I installed using the following command :
yum install https://cbs.centos.org/kojifiles/packages/postgresql92-postgresql/9.2.18/1.el7/x86_64/postgresql92-postgresql-9.2.18-1.el7.x86_64.rpm
https://cbs.centos.org/kojifiles/packages/postgresql92-postgresql/9.2.18/1.el7/x86_64/postgresql92-postgresql-contrib-9.2.18-1.el7.x86_64.rpm
https://cbs.centos.org/kojifiles/packages/postgresql92-postgresql/9.2.18/1.el7/x86_64/postgresql92-postgresql-libs-9.2.18-1.el7.x86_64.rpm
https://cbs.centos.org/kojifiles/packages/postgresql92-postgresql/9.2.18/1.el7/x86_64/postgresql92-postgresql-server-9.2.18-1.el7.x86_64.rpm
https://cbs.centos.org/kojifiles/packages/postgresql92/1.1/20.el7/x86_64/postgresql92-runtime-1.1-20.el7.x86_64.rpm
Next I created a symlink for libpq :
ln -s /opt/rh/postgresql92/root/usr/lib64/libpq.so.postgresql92-5 /lib64/libpq.so.postgresql92-5
And added the PATH in the /etc/profile :
# Rajout du PATH pour postgres
PATH=$PATH:/opt/rh/postgresql92/root/usr/bin
Next I created folder for the datas to be saved here :
[root#bdx-re-postgres02 lib64]# ll /app/data/
total 0
drwxr-xr-x. 4 postgres postgres 29 31 mai 15:40 postgres
[root#bdx-re-postgres02 lib64]# ll /app/data/postgres/
total 4
drwx------. 15 postgres postgres 4096 1 juin 11:01 data
drwxr-xr-x. 3 postgres postgres 18 31 mai 16:31 tbs
[root#bdx-re-postgres02 lib64]# ll /app/data/postgres/data/
total 48
drwx------. 5 postgres postgres 41 31 mai 16:42 base
drwx------. 2 postgres postgres 4096 1 juin 11:01 global
drwx------. 2 postgres postgres 18 31 mai 16:42 pg_clog
-rw-------. 1 postgres postgres 4232 31 mai 16:42 pg_hba.conf
-rw-------. 1 postgres postgres 1636 31 mai 16:42 pg_ident.conf
drwx------. 2 postgres postgres 58 1 juin 00:00 pg_log
drwx------. 4 postgres postgres 36 31 mai 16:42 pg_multixact
drwx------. 2 postgres postgres 18 1 juin 11:01 pg_notify
drwx------. 2 postgres postgres 6 31 mai 16:42 pg_serial
drwx------. 2 postgres postgres 6 31 mai 16:42 pg_snapshots
drwx------. 2 postgres postgres 25 1 juin 11:52 pg_stat_tmp
drwx------. 2 postgres postgres 18 31 mai 16:42 pg_subtrans
drwx------. 2 postgres postgres 19 31 mai 16:46 pg_tblspc
drwx------. 2 postgres postgres 6 31 mai 16:42 pg_twophase
-rw-------. 1 postgres postgres 4 31 mai 16:42 PG_VERSION
drwx------. 3 postgres postgres 60 31 mai 16:42 pg_xlog
-rw-------. 1 postgres postgres 19834 31 mai 16:42 postgresql.conf
-rw-------. 1 postgres postgres 86 1 juin 11:01 postmaster.opts
-rw-------. 1 postgres postgres 95 1 juin 11:01 postmaster.pid
[root#bdx-re-postgres02 lib64]# ll /app/data/postgres/tbs/
total 0
drwx------. 3 postgres postgres 30 31 mai 16:46 DV3F
[root#bdx-re-postgres02 lib64]#
And I created the tablespaces with a symink in /app/data/psotgres with the right permissions for postgres user :
[root#bdx-re-postgres02 lib64]# ll /var/lib/pgsql/9.2/
total 0
lrwxrwxrwx. 1 postgres postgres 22 31 mai 16:04 tbs -> /app/data/postgres/tbs
[root#bdx-re-postgres02 lib64]# ll /app/data/postgres/tbs/
total 0
drwx------. 3 postgres postgres 30 31 mai 16:46 DV3F
[root#bdx-re-postgres02 lib64]#
Next I modified the /usr/lib/systemd/system/postgresql92-postgresql.service file to add the database folder for PGDATA :
# Location of database directory
#Environment=PGDATA=/opt/rh/postgresql92/root/var/lib/pgsql/data
Environment=PGDATA=/app/data/postgres/data
And I added to repo my boss told me for installing Postgis :
yum-config-manager --add-repo http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/
yum install postgis
This is where the troubles begin. When I check for postgis files, I have the following :
[root#bdx-re-postgres02 lib64]# ll /usr/share/pgsql/contrib/postgis-2.0
total 5060
-rw-r--r--. 1 root root 1239 2 avril 2016 legacy_gist.sql
-rw-r--r--. 1 root root 2508 2 avril 2016 legacy_minimal.sql
-rw-r--r--. 1 root root 54418 2 avril 2016 legacy.sql
-rw-r--r--. 1 root root 64582 2 avril 2016 postgis_comments.sql
-rwxr-xr-x. 1 root root 146957 2 avril 2016 postgis_restore.pl
-rw-r--r--. 1 root root 149552 2 avril 2016 postgis_upgrade_20_minor.sql
-rw-r--r--. 1 root root 69411 2 avril 2016 raster_comments.sql
-rw-r--r--. 1 root root 5787 2 avril 2016 rtpostgis_legacy.sql
-rw-r--r--. 1 root root 186351 2 avril 2016 rtpostgis.sql
-rw-r--r--. 1 root root 204888 2 avril 2016 rtpostgis_upgrade_20_minor.sql
-rw-r--r--. 1 root root 3593962 2 avril 2016 spatial_ref_sys.sql
-rw-r--r--. 1 root root 13756 2 avril 2016 topology_comments.sql
-rw-r--r--. 1 root root 271709 2 avril 2016 topology.sql
-rw-r--r--. 1 root root 271597 2 avril 2016 topology_upgrade_20_minor.sql
-rw-r--r--. 1 root root 14401 2 avril 2016 uninstall_legacy.sql
-rw-r--r--. 1 root root 35990 2 avril 2016 uninstall_postgis.sql
-rw-r--r--. 1 root root 47073 2 avril 2016 uninstall_rtpostgis.sql
-rw-r--r--. 1 root root 10198 2 avril 2016 uninstall_topology.sql
[root#bdx-re-postgres02 lib64]# find / -name postgis
/usr/share/postgis
[root#bdx-re-postgres02 lib64]# ll /usr/lib64/postgis-2.0/
total 5060
-rw-r--r--. 1 root root 1239 2 avril 2016 legacy_gist.sql
-rw-r--r--. 1 root root 2508 2 avril 2016 legacy_minimal.sql
-rw-r--r--. 1 root root 54418 2 avril 2016 legacy.sql
-rw-r--r--. 1 root root 64582 2 avril 2016 postgis_comments.sql
-rwxr-xr-x. 1 root root 146957 2 avril 2016 postgis_restore.pl
-rw-r--r--. 1 root root 149552 2 avril 2016 postgis_upgrade_20_minor.sql
-rw-r--r--. 1 root root 69411 2 avril 2016 raster_comments.sql
-rw-r--r--. 1 root root 5787 2 avril 2016 rtpostgis_legacy.sql
-rw-r--r--. 1 root root 186351 2 avril 2016 rtpostgis.sql
-rw-r--r--. 1 root root 204888 2 avril 2016 rtpostgis_upgrade_20_minor.sql
-rw-r--r--. 1 root root 3593962 2 avril 2016 spatial_ref_sys.sql
-rw-r--r--. 1 root root 13756 2 avril 2016 topology_comments.sql
-rw-r--r--. 1 root root 271709 2 avril 2016 topology.sql
-rw-r--r--. 1 root root 271597 2 avril 2016 topology_upgrade_20_minor.sql
-rw-r--r--. 1 root root 14401 2 avril 2016 uninstall_legacy.sql
-rw-r--r--. 1 root root 35990 2 avril 2016 uninstall_postgis.sql
-rw-r--r--. 1 root root 47073 2 avril 2016 uninstall_rtpostgis.sql
-rw-r--r--. 1 root root 10198 2 avril 2016 uninstall_topology.sql
[root#bdx-re-postgres02 lib64]# ll /lib64/pgsql/
total 1148
-rwxr-xr-x. 1 root root 659728 2 avril 2016 postgis-2.0.so
-rwxr-xr-x. 1 root root 511528 2 avril 2016 rtpostgis-2.0.so
[root#bdx-re-postgres02 lib64]#
And when I check if postgis is installed in psql, it's the case
But, when I try to activate the extension using CREATE EXTENSION postgis, i get an output like this :
bash-4.2$ psql
psql (9.2.24, serveur 9.2.18)
Saisissez « help » pour l'aide.
postgres=# CREATE EXTENSION postgis;
ERREUR: n'a pas pu accéder au fichier « $libdir/postgis-2.0 » : Aucun fichier ou dossier de ce type
postgres=#
Translated from french : ERROR: could not access file "$libdir/postgis-2.0" : No such file or directory`
I spend the past 2 days to solve this, but none of the solutions I found worked.
Maybe Postgre is unable to find the correct folder ?
If someone can help me it would be very perfect.
Edit :
I found on this link that the $libdir can be changed within the postgresql.conf file. But I don't know what to append to the "dynamic_library_path", maybe one of the output of pg_config --pkglibdir ?

DOCKER container with postgres, WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted

I have a DOCKER container built from a few different images using a .yml, Dockerfile(s), etc. Everything builds and runs fine so far, except for this one issue that I am seeing mentioned in the title:
index-db_1 | 2021-02-22 23:18:33.388 UTC [31] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
That Database Index is mapped to a Folder on the host in the root of the Docker Package, and everything else seems to work fine as far as the database is concerned. I am using a Mac, but if I list permission from CLI for the DB folder I get:
-rw-------# 1 sscotti staff 3 Feb 22 11:01 PG_VERSION
drwx------# 6 sscotti staff 192 Feb 22 11:54 base
drwx------# 60 sscotti staff 1920 Feb 22 16:00 global
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_commit_ts
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_dynshmem
-rw-------# 1 sscotti staff 4782 Feb 22 11:02 pg_hba.conf
-rw-------# 1 sscotti staff 1636 Feb 22 11:01 pg_ident.conf
drwx------# 5 sscotti staff 160 Feb 22 17:46 pg_logical
drwx------# 4 sscotti staff 128 Feb 22 11:01 pg_multixact
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_notify
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_replslot
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_serial
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_snapshots
drwx------# 2 sscotti staff 64 Feb 22 16:00 pg_stat
drwx------# 5 sscotti staff 160 Feb 22 17:50 pg_stat_tmp
drwx------# 3 sscotti staff 96 Feb 22 11:01 pg_subtrans
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_tblspc
drwx------# 2 sscotti staff 64 Feb 22 11:01 pg_twophase
drwx------# 4 sscotti staff 128 Feb 22 11:01 pg_wal
drwx------# 3 sscotti staff 96 Feb 22 11:01 pg_xact
-rw-------# 1 sscotti staff 88 Feb 22 11:01 postgresql.auto.conf
-rw-------# 1 sscotti staff 28073 Feb 22 11:01 postgresql.conf
-rw-------# 1 sscotti staff 36 Feb 22 16:00 postmaster.opts
-rw------- 1 sscotti staff 94 Feb 22 16:00 postmaster.pid
pg_stat folder is actually empty.
and pg_stat_temp has:
-rw------- 1 sscotti staff 1952 Feb 22 17:54 db_0.stat
-rw------- 1 sscotti staff 20360 Feb 22 17:54 db_13395.stat
-rw------- 1 sscotti staff 1151 Feb 22 17:54 global.stat
The .yml file has this:
index-db:
image: postgres
restart: unless-stopped
volumes:
- ./OrthancIndex:/var/lib/postgresql/data
Is that something that can just be ignored given that it is a Docker container.
Adding a comment about the same setup on UBUNTU.
Database Folder:
drwx------ 19 systemd-coredump root 4096 Jun 30 13:12 OrthancIndex
Database:
drwx------ 6 systemd-coredump systemd-coredump 4096 Jun 11 13:00 base
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 30 13:12 global
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_commit_ts
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_dynshmem
-rw------- 1 systemd-coredump systemd-coredump 4782 Mar 12 16:12 pg_hba.conf
-rw------- 1 systemd-coredump systemd-coredump 1636 Mar 12 16:12 pg_ident.conf
drwx------ 4 systemd-coredump systemd-coredump 4096 Jul 1 13:27 pg_logical
drwx------ 4 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_multixact
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_notify
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_replslot
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_serial
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_snapshots
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 30 13:12 pg_stat
drwx------ 2 systemd-coredump systemd-coredump 4096 Jul 1 13:29 pg_stat_tmp
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 24 21:04 pg_subtrans
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_tblspc
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_twophase
-rw------- 1 systemd-coredump systemd-coredump 3 Mar 12 16:12 PG_VERSION
drwx------ 3 systemd-coredump systemd-coredump 4096 Jul 1 12:37 pg_wal
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_xact
-rw------- 1 systemd-coredump systemd-coredump 88 Mar 12 16:12 postgresql.auto.conf
-rw------- 1 systemd-coredump systemd-coredump 28073 Mar 12 16:12 postgresql.conf
-rw------- 1 systemd-coredump systemd-coredump 36 Jun 30 13:12 postmaster.opts
-rw------- 1 systemd-coredump systemd-coredump 94 Jun 30 13:12 postmaster.pid
pg_stat_temp
-rw------- 1 systemd-coredump systemd-coredump 2660 Jul 1 13:30 db_0.stat
-rw------- 1 systemd-coredump systemd-coredump 31157 Jul 1 13:30 db_13395.stat
-rw------- 1 systemd-coredump systemd-coredump 1151 Jul 1 13:30 global.stat
I actually get the same error on UBUNTU:
postgres_index-db_1 | 2021-07-01 18:06:45.140 UTC [266] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db_1 | 2021-07-01 18:13:45.583 UTC [273] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db2_1 | 2021-07-01 18:19:43.716 UTC [282] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db2_1 | 2021-07-01 18:21:43.749 UTC [284] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
Although here the user and group are systemd-coredump.
Simple and dumb
I've tried another way: leaving the temporary file in container, where you need not deal with user permissions - and that worked. I've changed with inline command the Postgresql config in docker-compose.yml:
postgresdb:
image: 'postgres'
command: postgres -c stats_temp_directory=/tmp
.
.
.
This is quick and simple solution, but it does not set multiple postgres config parameters. Through the time I found another solution.
Advanced (added on 22/01/14 09:00PM CET)
The advanced solution consists in these steps:
Prepare your desired postgresql.conf - here you can set whichever postgres server parameters you need. The necessary one for solving problem in this thread is:
stats_temp_directory = '/tmp/stat_temporary'
Create bash file, that you will start using docker-entrypoint-initdb.d in docker-compose.yml with which you will copy your configuration to postgres config directory in docker and create your temporary folder.
If you setup the docker-compose.yml this way:
postgres-db:
image: postgres
container_name: 'dbcontainer'
volumes:
# point to your postgres init scripts (folder or file)
- $PWD/db_init:/docker-entrypoint-initdb.d
# if you need persistent data, point data to local folder
- $PWD/database:/var/lib/postgresql/data
# if you want some data restore, point to your backup
- $PWD/db_backup:/db_backup
# point docker to directory with your config
- $PWD/db_config:/db_config
Then database will init with scripts in db_init directory. (Or you can point directly to one sql or bash file. If you point to directory, init script will run all files in alphabetical order.
Your file with init bash script, that you will place in your db_init folder can look like this and will be started inside docker:
echo starting script...
# create temporary directory for postgres in docker
mkdir /tmp/stat_temporary
# copy your postgresql.conf to postgresql config location in docker
cp /db_config/postgresql.conf var/lib/postgresql/data/postgresql.conf
# alternatively you can run any pg script you need, here I restore backup to new database
pg_restore -U postgres -v -Fc -d analysis /db_backup/analysis_backup.bak
echo finished
After this script is run, the database service on docker is restarted and loads with new parameters you set up.
Writing this down as much for my future self as to answer the question: looking over at the documentation and taking #Fide's solution above, the following seems to work on MacOSX Monterey running a PostGIS image (which is just built on top of the Postgres images)...
Note that this is taken from a shell script to launch a Postgres+PostGIS image with a persistent local store on the host system:
WORK_DIR="$HOME/Documents/git/project"
DOCKER_NM="postgis"
DOCKER_IMG="postgis/postgis"
POSTGRES_PWD="XXX"
PORT_NO="5432"
docker run --name $DOCKER_NM \
-e POSTGRES_PASSWORD=$POSTGRES_PWD \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v "$WORK_DIR/data/postgres":/var/lib/postgresql/data \
-p "$PORT_NO:5432" -d $DOCKER_IMG \
postgres -c stats_temp_directory=/tmp
If you were running from the Terminal directly (i.e. not via zsh/bash) then you'd need to export each of the parameters instead of just specifying them.
With this the global.stat error seems to have gone away... though I should note that I've only just figured this out and have been running the container for less than 60 minutes. The alternative would be to follow the instructions on that page for creating and using a persistent custom conf file (extending #SScotti's comment above) as mounted from the local FS:
-v "$PWD/my-postgres.conf":/etc/postgresql/postgresql.conf
Mounting with a local volume requires user mapping within the postgres container. There is a section in the https://hub.docker.com/_/postgres README titled Arbitrary --user Notes which describes solutions to the problem.
One recommendation listed is to use a docker volume, initialize the contents of volume mounted, shutdown the container image, run a recursive ownership change and then restart the container normally.
$ docker volume create pgdata
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword postgres
The files belonging to this database system will be owned by user "postgres".
...
( once it's finished initializing successfully and is waiting for connections, stop it )
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data bash chown -R 1000:1000 /var/lib/postgresql/data
$ docker run -it --rm --user 1000:1000 -v pgdata:/var/lib/postgresql/data postgres
Not an answer to the original question, but hence the lack of reputation points I can't add my two cents as a comment. So here is a working docker-compose.yml file using the tmpfs solution as an answer (for #SScotti and anyone else, who wants to try this without cluttering the default command or config):
Environment file (.env):
POSTGRES_VERSION=13.6
DATABASE_NAME=dbname
DATABASE_USER=dbuser
DATABASE_PASS=dbpass
Compose file (docker-compose.yml):
version: '3.6'
services:
postgres:
image: postgres:${POSTGRES_VERSION}-alpine
restart: always
container_name: postgres
environment:
POSTGRES_DB: ${DATABASE_NAME}
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASS}
volumes:
- /etc/timezone:/etc/timezone:ro
- .volumes/pgdata:/var/lib/postgresql/data
- type: tmpfs
target: /var/lib/postgresql/data/pg_stat_tmp
tmpfs:
# 256 Mb - beware the default, it's infinity(!)
size: 268435456
Edit: Note on first run
On first run, postgres tries to initialise the database and fails, because of non empty data directory (the existing/mounted tmpfs pg_stats_tmp in the data directory).
To avoid that, you have to run the service at first without the tmpfs section in the compose file, and when postgres finished initialising take the service down and enable the tmpfs section in the compose file before bringen up the service again.
I ran into this same problem - Looked into it in detail and finally found a simple solution.
First some basic background - your pg_stat_temp_directory location is a subdirectory under your data_directory.
show data_directory ;
If it returns the default value for Unix based systems like
/var/lib/postgresql/data
And your command to show stats_temp
show stats_temp_directory ;
Also returns the default value
pg_stat_tmp
Then your full path to stats_temp_directory is /var/lib/postgresql/data/pg_stat_tmp
I was using bind mapping to map the PG container data files to my host so that I can keep the data even after the container is stopped.
docker run -d --name gutlo-postgres -p 5434:5432 -v /data/postgres-docker/14:/var/lib/postgresql/data -e POSTGRES_PASSWORD=<PASSWORD> postgres:latest
Now everytime I start the container, it automatically creates files under stats_temp directory and once that it has a problem with is called global.stat
ls -la global.stat
-rw------- 1 ssengupta admin 3648 May 13 16:24 global.stat
ls -la . | head -2 | tail -1
drwxr-xr-x# 14 ssengupta admin 448 May 13 16:26 .
Now you see, where is the problem. The container is able to create the file global.stat ( its directory file "." has open rwx permissions. But the file itself is created without open permission hence my container cannot access its own created file.
From docker manual, there is a concept of temp mount. So simply create a temp mount point for the stats_temp directory and the docker will use tempfs / RAM - that eliminates permission problem.
--mount type=tmpfs,destination=/var/lib/postgresql/data/pg_stat_tmp
In addition it would improve performance too although you may not detect it.
My attempts...
Attach to the db container:
docker compose run --no-deps -it db bash
and do ls on the data directory:
root#dfc6399e2981:/var/lib/postgresql/data# ls -l
total 60
drwx------ 7 root root 224 Sep 8 23:38 base
drwx------ 60 root root 1920 Sep 8 23:38 global
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_commit_ts
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_dynshmem
-rw------- 1 postgres postgres 4821 Sep 8 23:35 pg_hba.conf
-rw------- 1 postgres postgres 1636 Sep 8 23:35 pg_ident.conf
drwx------ 5 root root 160 Sep 8 23:43 pg_logical
drwx------ 4 postgres postgres 128 Sep 8 23:35 pg_multixact
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_notify
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_replslot
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_serial
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_snapshots
drwx------ 2 root root 64 Sep 8 23:35 pg_stat
drwx------ 6 root root 192 Sep 9 00:20 pg_stat_tmp
drwx------ 3 postgres postgres 96 Sep 8 23:35 pg_subtrans
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_tblspc
drwx------ 2 postgres postgres 64 Sep 8 23:35 pg_twophase
-rw------- 1 postgres postgres 3 Sep 8 23:35 PG_VERSION
drwx------ 4 postgres postgres 128 Sep 8 23:35 pg_wal
drwx------ 3 postgres postgres 96 Sep 8 23:35 pg_xact
-rw------- 1 postgres postgres 88 Sep 8 23:35 postgresql.auto.conf
-rw------- 1 postgres postgres 28835 Sep 8 23:35 postgresql.conf
-rw------- 1 root root 36 Sep 8 23:35 postmaster.opts
-rw------- 1 postgres postgres 94 Sep 8 23:35 postmaster.pid
Obviously, note that some things are owned by root. Also, compare and contrast, from outside the container I see this:
% ls -l db/data
total 120
-rw-------# 1 pedz staff 3 Sep 8 18:35 PG_VERSION
drwx------# 7 pedz staff 224 Sep 8 18:38 base
drwx------# 60 pedz staff 1920 Sep 8 18:38 global
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_commit_ts
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_dynshmem
-rw-------# 1 pedz staff 4821 Sep 8 18:35 pg_hba.conf
-rw-------# 1 pedz staff 1636 Sep 8 18:35 pg_ident.conf
drwx------# 5 pedz staff 160 Sep 8 18:43 pg_logical
drwx------# 4 pedz staff 128 Sep 8 18:35 pg_multixact
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_notify
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_replslot
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_serial
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_snapshots
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_stat
drwx------# 6 pedz staff 192 Sep 8 19:27 pg_stat_tmp
drwx------# 3 pedz staff 96 Sep 8 18:35 pg_subtrans
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_tblspc
drwx------# 2 pedz staff 64 Sep 8 18:35 pg_twophase
drwx------# 4 pedz staff 128 Sep 8 18:35 pg_wal
drwx------# 3 pedz staff 96 Sep 8 18:35 pg_xact
-rw-------# 1 pedz staff 88 Sep 8 18:35 postgresql.auto.conf
-rw-------# 1 pedz staff 28835 Sep 8 18:35 postgresql.conf
-rw-------# 1 pedz staff 36 Sep 8 18:35 postmaster.opts
-rw-------# 1 pedz staff 94 Sep 8 18:35 postmaster.pid
So, while in the db container I did:
chown -R postgres:postgres /var/lib/postgresql/data
I can now see updates into pg_stat_tmp from outside of the container and it has been up for 30 minutes with no Warning messages so I think its "fixed" although I don't know enough about Docker's images to know for sure that the issue won't come back later. Perhaps someone with more Docker knowledge can chime in.
Update: this does NOT fix the issue. Rather than delete this answer I think I will leave it here. It is odd that some files are owned by root. And even after I did chown -R there are still some files owned by root:
root#ec24992481d1:/var/lib/postgresql# find . -user 0 -exec ls -ld {} +
-rw------- 1 root root 8 Sep 9 00:34 ./data/pg_logical/replorigin_checkpoint
-rw------- 1 root root 2225 Sep 9 01:12 ./data/pg_stat_tmp/db_0.stat
-rw------- 1 root root 6665 Sep 9 01:12 ./data/pg_stat_tmp/db_13757.stat
-rw------- 1 root root 7035 Sep 9 01:12 ./data/pg_stat_tmp/db_16384.stat
-rw------- 1 root root 94 Sep 9 00:29 ./data/postmaster.pid
root#ec24992481d1:/var/lib/postgresql#
This might be a clue for others more savvy with Docker.

Chromedriver has stopped working and says Driver info: chromedriver=81.0.4044.69 even though I have 81.0.4044.138 installed

Ignoring uncaught error SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 81
(Driver info: chromedriver=81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044#{#776}),platform=Mac OS X 10.15.4 x86_64)
Inside node_modules/protractor/node_modules/webdriver-manager/selenium/ I have:
-rw-r--r-- 1 account1 staff 94690 5 May 23:12 chrome-response.xml
-rwxr-xr-x 1 account1 staff 14786468 15 Mar 05:40 chromedriver_81.0.4044.138
-rw-r--r-- 1 account1 staff 7019279 5 May 23:12 chromedriver_81.0.4044.138.zip
-rw-r--r-- 1 account1 staff 397989 5 May 23:12 gecko-response.json
-rwxr-xr-x 1 account1 staff 5259056 10 Oct 2019 geckodriver-v0.26.0
-rw-r--r-- 1 account1 staff 2006880 5 May 23:12 geckodriver-v0.26.0.tar.gz
-rw-r--r-- 1 account1 staff 566 5 May 23:12 update-config.json
I have Version 81.0.4044.138 installed as I can see in chrome://settings/help
I've no idea where it's getting 81.0.4044.69 from...

Kafka broker shut down even though the log dirs are present

When I saw this error message:
ERROR Shutdown broker because all log dirs in /tmp/kafka-logs have failed (kafka.log.LogManager)
The first thought is "well the /tmp directory probably got cleared out by the O/S (linux) - so I should update the kafka config to point to something permanent. However the directory is present and has not been wiped:
ll /tmp/kafka-logs/
total 20
drwxrwxr-x 2 ec2-user ec2-user 38 Apr 7 16:56 __consumer_offsets-0
drwxrwxr-x 2 ec2-user ec2-user 38 Apr 7 16:56 __consumer_offsets-7
drwxrwxr-x 2 ec2-user ec2-user 38 Apr 7 16:56 __consumer_offsets-42
..
drwxrwxr-x 2 ec2-user ec2-user 38 Apr 7 16:56 __consumer_offsets-32
drwxrwxr-x 2 ec2-user ec2-user 141 Apr 12 02:49 flights_raw-0
drwxrwxr-x 2 ec2-user ec2-user 178 Apr 12 08:25 air2008-0
drwxrwxr-x 2 ec2-user ec2-user 141 Apr 12 13:38 testtopic-0
-rw-rw-r-- 1 ec2-user ec2-user 1244 Apr 17 22:29 recovery-point-offset-checkpoint
-rw-rw-r-- 1 ec2-user ec2-user 4 Apr 17 22:29 log-start-offset-checkpoint
-rw-rw-r-- 1 ec2-user ec2-user 1248 Apr 17 22:30 replication-offset-checkpoint
So then what does this actually mean, why is it happening and what should be done to correct/avoid the error?
In related question best answer suggests to delete log dir both for Kafka /tmp/kafka-logs and Zookeper /tmp/zookeeper.
Probably it's because of Kafka issue which was resolved in August 2018.
Hope this will help.

Kafka pod fails to come up after pod deletion with NFS

We were trying to run a Kafka cluster on Kubernetes using NFS provisioner. The cluster came up fine. However when we killed one of the Kafka pods, the replacement pod failed to come up.
Persistent volume before pod deletion:
# mount
10.102.32.184:/export/pvc-ce1461b3-1b38-11e8-a88e-005056073f99 on /opt/kafka/data type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.133.40.245,local_lock=none,addr=10.102.32.184)
# ls -al /opt/kafka/data/logs
total 4
drwxr-sr-x 2 99 99 152 Feb 26 21:07 .
drwxrwsrwx 3 99 99 18 Feb 26 21:07 ..
-rw-r--r-- 1 99 99 0 Feb 26 21:07 .lock
-rw-r--r-- 1 99 99 0 Feb 26 21:07 cleaner-offset-checkpoint
-rw-r--r-- 1 99 99 57 Feb 26 21:07 meta.properties
-rw-r--r-- 1 99 99 0 Feb 26 21:07 recovery-point-offset-checkpoint
-rw-r--r-- 1 99 99 0 Feb 26 21:07 replication-offset-checkpoint
# cat /opt/kafka/data/logs /meta.properties
#
#Mon Feb 26 21:07:08 UTC 2018
version=0
broker.id=1003
Deleting the pod:
kubectl delete pod kafka-iced-unicorn-1
The reattached persistent volume in the newly created pod:
# ls -al /opt/kafka/data/logs
total 4
drwxr-sr-x 2 99 99 180 Feb 26 21:10 .
drwxrwsrwx 3 99 99 18 Feb 26 21:07 ..
-rw-r--r-- 1 99 99 0 Feb 26 21:10 .kafka_cleanshutdown
-rw-r--r-- 1 99 99 0 Feb 26 21:07 .lock
-rw-r--r-- 1 99 99 0 Feb 26 21:07 cleaner-offset-checkpoint
-rw-r--r-- 1 99 99 57 Feb 26 21:07 meta.properties
-rw-r--r-- 1 99 99 0 Feb 26 21:07 recovery-point-offset-checkpoint
-rw-r--r-- 1 99 99 0 Feb 26 21:07 replication-offset-checkpoint
#cat /opt/kafka/data/logs/meta.properties
#
#Mon Feb 26 21:07:08 UTC 2018
version=0
broker.id=1003
We see the following error in the Kafka logs:
[2018-02-26 21:26:40,606] INFO [ThrottledRequestReaper-Produce], Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2018-02-26 21:26:40,711] FATAL [Kafka Server 1002], Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
java.io.IOException: Invalid argument
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)
at kafka.utils.FileLock.<init>(FileLock.scala:28)
at kafka.log.LogManager$$anonfun$lockLogDirs$1.apply(LogManager.scala:104)
at kafka.log.LogManager$$anonfun$lockLogDirs$1.apply(LogManager.scala:103)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at kafka.log.LogManager.lockLogDirs(LogManager.scala:103)
at kafka.log.LogManager.<init>(LogManager.scala:65)
at kafka.server.KafkaServer.createLogManager(KafkaServer.scala:648)
at kafka.server.KafkaServer.startup(KafkaServer.scala:208)
at io.confluent.support.metrics.SupportedServerStartable.startup(SupportedServerStartable.java:102)
at io.confluent.support.metrics.SupportedKafka.main(SupportedKafka.java:49)
[2018-02-26 21:26:40,713] INFO [Kafka Server 1002], shutting down (kafka.server.KafkaServer)
[2018-02-26 21:26:40,715] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
The only way around this seems to be to delete the persistent volume claim and force delete the pod again. Or alternatively use another storage provider than NFS (rook is working fine in this scenario).
Has anyone come across this issue with NFS provisioner?