无法启动 PostgreSQL 12 服务器

发布于 2025-01-13 18:59:39 字数 2599 浏览 4 评论 0原文

我想在 Ubuntu 20.04 上使用 PostGIS 3 设置 PostgreSQL 12,以创建 OSM 平铺服务器。我想要有 2 个不同的集群,一个用于常规 PSQL 数据库,另一个用于 OSM 数据。我似乎无法启动并运行 OSM 数据:

当我运行 pg_lsclusters 时,我得到以下信息:

Ver Cluster     Port Status Owner    Data directory                          Log file
12  main        5433 online postgres /var/lib/postgresql/12/main             /var/log/postgresql/postgresql-12-main.log
12  osm_psql_db 5432 down   postgres /var/lib/postgresql/12/2TB1/osm_psql_db /var/log/postgresql/postgresql-12-osm_psql_db.log

当我运行 journalctl -xe 时,我得到以下内容:

Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: Dependency failed for PostgreSQL Cluster 12-osm_psql_db.
-- Subject: A start job for unit postgresql@12-osm_psql_db.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit postgresql@12-osm_psql_db.service has finished with a failure.
-- 
-- The job identifier is 9566 and the job result is dependency.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: postgresql@12-osm_psql_db.service: Job postgresql@12-osm_psql_db.service/start failed with result 'dependency'.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: var-lib-postgresql-12-osm_psql_db.mount: Job var-lib-postgresql-12-osm_psql_db.mount/start failed with result 'dependency'.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: dev-disk-by\x2dlabel-osm_psql_db.device: Job dev-disk-by\x2dlabel-osm_psql_db.device/start failed with result 'timeout'.
Mar 13 11:47:43 cdil-MS-7B92 PackageKit[27900]: daemon quit
Mar 13 11:47:43 cdil-MS-7B92 systemd[1]: packagekit.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit packagekit.service has successfully entered the 'dead' state.

知道是什么阻碍了我吗?

*** 额外信息以防万一 ***

就我如何设置一切而言,我安装了以下软件包:

sudo apt install postgresql-12 postgresql-contrib postgis postgresql-12-postgis-3

由于 OSM 数据非常大,我想将该特定集群存储在另一个硬盘上。它被称为“2TB1”,并且已安装到 /var/lib/postgresql/12/2TB1 ,因为我意识到 postgres 用户需要访问 data_directory 文件夹以及通向该文件夹的所有父文件夹。

为此,我修改了新硬盘驱动器的权限:

sudo chown -R postgres:postgres /var/lib/postgresql/12/2TB1

接下来,我创建了新的数据库集群实例:

sudo pg_createcluster 12 osm_psql_db -d /var/lib/postgresql/12/2TB1/osm_psql_db -p 5432

我启动新实例:

sudo pg_ctlcluster 12 osm_psql_db start

我收到以下错误:

A dependency job for postgresql@12-osm_psql_db.service failed. See 'journalctl -xe' for details.

I want to setup PostgreSQL 12 with PostGIS 3 on Ubuntu 20.04 for the purpose of creating an OSM Tile Server. I want to have 2 different clusters, one for a regular PSQL database and another for OSM data. I can't seem to get the one for the OSM data up and running:

When I run pg_lsclusters, I get the following:

Ver Cluster     Port Status Owner    Data directory                          Log file
12  main        5433 online postgres /var/lib/postgresql/12/main             /var/log/postgresql/postgresql-12-main.log
12  osm_psql_db 5432 down   postgres /var/lib/postgresql/12/2TB1/osm_psql_db /var/log/postgresql/postgresql-12-osm_psql_db.log

When I run journalctl -xe, I get the following:

Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: Dependency failed for PostgreSQL Cluster 12-osm_psql_db.
-- Subject: A start job for unit postgresql@12-osm_psql_db.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit postgresql@12-osm_psql_db.service has finished with a failure.
-- 
-- The job identifier is 9566 and the job result is dependency.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: postgresql@12-osm_psql_db.service: Job postgresql@12-osm_psql_db.service/start failed with result 'dependency'.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: var-lib-postgresql-12-osm_psql_db.mount: Job var-lib-postgresql-12-osm_psql_db.mount/start failed with result 'dependency'.
Mar 13 11:47:37 cdil-MS-7B92 systemd[1]: dev-disk-by\x2dlabel-osm_psql_db.device: Job dev-disk-by\x2dlabel-osm_psql_db.device/start failed with result 'timeout'.
Mar 13 11:47:43 cdil-MS-7B92 PackageKit[27900]: daemon quit
Mar 13 11:47:43 cdil-MS-7B92 systemd[1]: packagekit.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit packagekit.service has successfully entered the 'dead' state.

Any idea what could be holding me up?

*** EXTRA INFO JUST IN CASE ***

In terms of how I set up everything, I installed the following packages:

sudo apt install postgresql-12 postgresql-contrib postgis postgresql-12-postgis-3

Because the OSM data is quite large, I want to store that particular cluster on another hard disk. It's called "2TB1" and it's been mounted to /var/lib/postgresql/12/2TB1 because I realized that the postgres user needed access to the data_directory folder and all parent folders leading up to it.

To do so I modified the permissions of the new hard drive:

sudo chown -R postgres:postgres /var/lib/postgresql/12/2TB1

Next, I created the new db cluster instance:

sudo pg_createcluster 12 osm_psql_db -d /var/lib/postgresql/12/2TB1/osm_psql_db -p 5432

I start the new instance:

sudo pg_ctlcluster 12 osm_psql_db start

I get the following error:

A dependency job for postgresql@12-osm_psql_db.service failed. See 'journalctl -xe' for details.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩起发的微风 2025-01-20 18:59:40

对于任何偶然发现同样问题的人...我将问题追溯到 *.service 文件引用了数据库集群位置的错误安装点。这就是我所做的:

启用新服务(不确定是否需要这样做,但到底是什么...)

sudo systemctl enable postgresql@12-osm_psql_db

编辑 postgresql@12-osm_psql_db.service

sudo systemctl edit --full postgresql@12-osm_psql_db.service

更改

RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I

RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/12/2TB1/osm_psql_db

作为服务脚本的一部分,%I 扩展为 VERSION/CLUSTER,在我的例子中是 12/osm_psql_db。由于我选择将数据库放置在另一个 SSD 上,并且数据库不能驻留在磁盘的根目录中,因此需要将 *.service 文件中的挂载位置更新为 12/2TB1/osm_psql_db.如果您将所有数据库存储在单个硬盘上,则没有必要这样做。

For anyone that stumbles upon the same issue... I tracked the problem down to the *.service file referencing the wrong mount point for the database cluster location. Here's what I did:

Enable the new service (not sure if this is needed, but what the heck...)

sudo systemctl enable postgresql@12-osm_psql_db

Edit the postgresql@12-osm_psql_db.service

sudo systemctl edit --full postgresql@12-osm_psql_db.service

Change

RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I

To

RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/12/2TB1/osm_psql_db

As part of the service script, %I expands to VERSION/CLUSTER which in my case would have been 12/osm_psql_db. Since I was choosing to place the DB on another SSD and the database can't reside in the root directory of a disk, the mount location in the *.service file needed to be updated to 12/2TB1/osm_psql_db. This would not be necessary if you were storing all your databases on a single hard disk.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文