أنا أعمل في بيئة متعددة المواقع مع تكوين حاويتين (فقط قوالب postgres.10 و redis في حاوية البيانات). إصدار PostgreSQL الحالي هو 10 وأود الترقية إلى الإصدار 13. إليك الخطأ الذي يظهر عند إعادة بناء حاوية data:
fixing permissions on existing directory /shared/postgres_data_new ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
/usr/lib/postgresql/13/bin/pg_ctl -D /shared/postgres_data_new -l logfile start
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Hit:2 http://deb.debian.org/debian buster InRelease
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease [104 kB]
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [291 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 Packages [231 kB]
Hit:7 https://deb.nodesource.com/node_15.x buster InRelease
Fetched 743 kB in 1s (944 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
postgresql-client-10
Suggested packages:
postgresql-doc-10
The following NEW packages will be installed:
postgresql-10 postgresql-client-10
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,441 kB of archives.
After this Operation, 30.6 MB of additional disk space will be used.
Get:1 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 postgresql-client-10 amd64 10.17-1.pgdg100+1 [1,439 kB]
Get:2 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 postgresql-10 amd64 10.17-1.pgdg100+1 [5,002 kB]
Fetched 6,441 kB in 0s (34.9 MB/s)
Selecting previously unselected package postgresql-client-10.
(Reading database ... 43021 files and directories currently installed.)
Preparing to unpack .../postgresql-client-10_10.17-1.pgdg100+1_amd64.deb ...
Unpacking postgresql-client-10 (10.17-1.pgdg100+1) ...
Selecting previously unselected package postgresql-10.
Preparing to unpack .../postgresql-10_10.17-1.pgdg100+1_amd64.deb ...
Unpacking postgresql-10 (10.17-1.pgdg100+1) ...
Setting up postgresql-client-10 (10.17-1.pgdg100+1) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/13/man/man1/psql.1.gz because link group psql.1.gz is broken
Setting up postgresql-10 (10.17-1.pgdg100+1) ...
Creating new PostgreSQL cluster 10/main ...
/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/10/main --auth-local peer --auth-host md5
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/10/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Etc/UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctlcluster 10 main start
Ver Cluster Port Status Owner Data directory Log file
10 main 5433 down postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/13/man/man1/postmaster.1.gz because link group postmaster.1.gz is broken
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for postgresql-common (226.pgdg100+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Stopping PostgreSQL 10 database server: main.
Stopping PostgreSQL 13 database server: main.
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
The source cluster was not shut down cleanly.
Failure, exiting
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES FAILED
Please visit https://meta.discourse.org/t/postgresql-13-update/172563 for support.
You can run ./launcher start app to restart your app in the meanwhile
FAILED
--------------------
Pups::ExecError: /root/upgrade_postgres failed with return #<Process::Status: pid 49 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "/root/upgrade_postgres"
1f253827e5700e1861c4e586213aaffa8994e452e43b9336301dcd02072e00f4
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
إذا قمت بتعيين قالب postgres.10 مرة أخرى، فكل شيء يعمل بشكل صحيح.
هل تعرف ما يمكنني فعله للترقية إلى PostgreSQL 13؟
هذا ما أحصل عليه عند تشغيل أمر tail -f shared/data/log/var-log/postgres/current بعد إيقاف الحاويتين:
2021-06-06 16:38:37.411 UTC [113] HINT: The server must be started by the user that owns the data directory.
2021-06-06 16:38:38.424 GMT [114] LOG: skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2021-06-06 16:38:38.424 UTC [114] FATAL: data directory "/shared/postgres_data" has wrong ownership
2021-06-06 16:38:38.424 UTC [114] HINT: The server must be started by the user that owns the data directory.
2021-06-06 16:38:39.439 GMT [115] LOG: skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2021-06-06 16:38:39.439 UTC [115] FATAL: data directory "/shared/postgres_data" has wrong ownership
2021-06-06 16:38:39.439 UTC [115] HINT: The server must be started by the user that owns the data directory.
2021-06-06 16:38:40.461 GMT [116] LOG: skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2021-06-06 16:38:40.461 UTC [116] FATAL: data directory "/shared/postgres_data" has wrong ownership
2021-06-06 16:38:40.461 UTC [116] HINT: The server must be started by the user that owns the data directory.
هذا على الأرجح مصدر المشكلة. كيف يمكنني إصلاح ذلك؟
لإعدادي (حاويتان، postgres 13)، المجموعة الخاصة بـ postgres_* هي render وليس netdev، والحقوق الصحيحة لمجموعة postgres_run هي x وليس setgid. لكنني لا أعرف حقًا ما الذي يستتبعه ذلك
هل يمكنك تشغيل الأمر نفسه باستخدام ls -lan؟ سيساعد ذلك في تحديد الملكية (-n يحول اسم المستخدم إلى معرف المستخدم UID واسم المجموعة إلى معرف المجموعة GID). إليك مثال على موقعي الخاص مع إعداد حاويتين:
[root@/var/discourse/shared/data]$ ls -lan
total 28
drwxr-xr-x. 7 0 0 4096 Jun 7 22:15 .
drwxr-xr-x. 5 0 0 4096 Jun 7 22:28 ..
drwxr-xr-x. 3 0 0 4096 Jun 7 22:15 log
drwxr-xr-x. 2 105 109 4096 Jun 7 22:15 postgres_backup
drwx------. 19 105 109 4096 Jun 7 22:27 postgres_data
drwxrwxr-x. 3 105 109 4096 Jun 7 22:27 postgres_run
drwxr-xr-x. 2 106 110 4096 Jun 8 00:17 redis_data
نحن في نفس الموقف، لكننا نعمل على إعداد مستقل. لا يظهر المسار shared/standalone/log/var-log/ أي ملفات على الإطلاق، ومع ذلك، بعد الدخول إلى الحاوية، نرى نتائج مماثلة:
root@pulp-discourse-iptools:/var/www/discourse# tail -n 3 /var/log/postgres/current
2021-10-13 18:33:04.027 GMT [917] LOG: skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2021-10-13 18:33:04.028 UTC [917] FATAL: data directory "/shared/postgres_data" has wrong ownership
2021-10-13 18:33:04.028 UTC [917] HINT: The server must be started by the user that owns the data directory.
من أجل أن نكون أكثر حذرًا، عدنا إلى استخدام "templates/postgres.10.template.yml" في ملف app.yml، وهدفنا الحالي هو فقط إعادة تشغيل النسخة القديمة.
ربما من المنطقي أن نذكر أننا بالفعل على أحدث إصدار من https://github.com/discourse/discourse_docker.git بعد التبديل إلى الفرع main. ومع ذلك، نظرًا لأن إعادة البناء لم تنجح، فمن المرجح أن هذا لا يؤثر على تشغيل الصورة السابقة، أليس كذلك؟
إذا كان لدى أي شخص فكرة حول كيفية حل هذه المشكلة، فسنكون ممتنين جدًا. وإلا، فقد نعود بتقارير إضافية.
محاولة مرة أخرى، باستخدام "templates/postgres.template.yml" مرة أخرى، سار كل شيء بسلاسة تامة وتمت ترقية PostgreSQL 10 إلى PostgreSQL 13 بنجاح. شكرًا مرة أخرى لفريق Discourse بأكمله على عملهم الرائع في هذا البرنامج.