无法启动 PostgreSQL 12 服务器
我想在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于任何偶然发现同样问题的人...我将问题追溯到 *.service 文件引用了数据库集群位置的错误安装点。这就是我所做的:
启用新服务(不确定是否需要这样做,但到底是什么...)
编辑 postgresql@12-osm_psql_db.service
更改
为
作为服务脚本的一部分,
%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...)
Edit the postgresql@12-osm_psql_db.service
Change
To
As part of the service script,
%I
expands toVERSION/CLUSTER
which in my case would have been12/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 to12/2TB1/osm_psql_db
. This would not be necessary if you were storing all your databases on a single hard disk.