PostgreSQL 13 Almalinux权限问题
我正在尝试获取PostgreSQL 13.x
在almalinux
上运行。软件包管理显示v13.x
可用,我安装PostgreSQL-Server
:
sudo yum install -y postgresql-server postgresql-contrib
我然后尝试初始化第一个DB:
sudo postgresql-setup --initdb
因为我必须重做一些内容,所以此目录为不是空的,然后我遇到了权限问题。我已经尝试将所有权设置为我的帐户,但它也不起作用:
ERROR: Data directory /var/lib/pgsql/data is not empty!
ERROR: Initializing database failed, possibly see /var/lib/pgsql/initdb_postgresql.log
[Wed Jun 29 18:31:40 rich@server1 /var/lib] cd pgsql
-bash: cd: pgsql: Permission denied
[Wed Jun 29 18:31:50 rich@server1 /var/lib] sudo ls -al pgsql/data
total 60
drwx------. 20 postgres postgres 4096 May 26 11:53 .
drwx------. 4 postgres postgres 54 Jun 29 18:27 ..
drwx------. 5 rich rich 41 Jun 29 11:01 base
-rw-------. 1 rich rich 30 Jun 29 15:58 current_logfiles
drwx------. 2 rich rich 4096 Jun 29 11:01 global
drwx------. 2 rich rich 32 Jun 29 11:02 log
drwx------. 2 rich rich 6 Jun 29 11:01 pg_commit_ts
drwx------. 2 rich rich 6 Jun 29 11:01 pg_dynshmem
-rw-------. 1 rich rich 4760 Jun 29 11:01 pg_hba.conf
-rw-------. 1 rich rich 1636 Jun 29 11:01 pg_ident.conf
drwx------. 4 rich rich 68 Jun 29 11:01 pg_logical
drwx------. 4 rich rich 36 Jun 29 11:01 pg_multixact
drwx------. 2 rich rich 6 Jun 29 11:01 pg_notify
drwx------. 2 rich rich 6 Jun 29 11:01 pg_replslot
drwx------. 2 rich rich 6 Jun 29 11:01 pg_serial
drwx------. 2 rich rich 6 Jun 29 11:01 pg_snapshots
drwx------. 2 rich rich 6 Jun 29 11:01 pg_stat
drwx------. 2 rich rich 6 Jun 29 11:01 pg_stat_tmp
drwx------. 2 rich rich 18 Jun 29 11:01 pg_subtrans
drwx------. 2 rich rich 6 Jun 29 11:01 pg_tblspc
drwx------. 2 rich rich 6 Jun 29 11:01 pg_twophase
-rw-------. 1 rich rich 3 Jun 29 11:01 PG_VERSION
drwx------. 3 rich rich 60 Jun 29 11:01 pg_wal
drwx------. 2 rich rich 18 Jun 29 11:01 pg_xact
-rw-------. 1 rich rich 88 Jun 29 11:01 postgresql.auto.conf
-rw-------. 1 rich rich 28098 Jun 29 11:01 postgresql.conf
因此,现在我在初始化新数据库和超越权限
之间被捕。有人知道我怎么能运行吗?
编辑:
这是权限问题背后的报告:
░░ A start job for unit postgresql.service has begun execution.
░░
░░ The job identifier is 2450.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2593]: cat: /var/lib/pgsql/data/PG_VERSION: Permission denied
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: An old version '' of the database format was found.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: You need to dump and reload before using PostgreSQL 13.7.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
Jun 29 21:28:58 server1.project33.ca systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ An ExecStartPre= process belonging to unit postgresql.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jun 29 21:28:58 server1.project33.ca systemd[1]: postgresql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ The unit postgresql.service has entered the 'failed' state with result 'exit-code'.
Jun 29 21:28:58 server1.project33.ca systemd[1]: Failed to start PostgreSQL database server.
░░ Subject: A start job for unit postgresql.service has failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A start job for unit postgresql.service has finished with a failure.
░░
░░ The job identifier is 2450 and the job result is failed.
I'm trying to get postgresql 13.x
running on AlmaLinux
. The package manage shows v13.x
is available and I install postgresql-server
:
sudo yum install -y postgresql-server postgresql-contrib
I then try to initialize the first db:
sudo postgresql-setup --initdb
Because I had to redo some stuff, this directory is not empty, then I run into permissions issues. I've tried setting ownership to my account, but it doesn't work either:
ERROR: Data directory /var/lib/pgsql/data is not empty!
ERROR: Initializing database failed, possibly see /var/lib/pgsql/initdb_postgresql.log
[Wed Jun 29 18:31:40 rich@server1 /var/lib] cd pgsql
-bash: cd: pgsql: Permission denied
[Wed Jun 29 18:31:50 rich@server1 /var/lib] sudo ls -al pgsql/data
total 60
drwx------. 20 postgres postgres 4096 May 26 11:53 .
drwx------. 4 postgres postgres 54 Jun 29 18:27 ..
drwx------. 5 rich rich 41 Jun 29 11:01 base
-rw-------. 1 rich rich 30 Jun 29 15:58 current_logfiles
drwx------. 2 rich rich 4096 Jun 29 11:01 global
drwx------. 2 rich rich 32 Jun 29 11:02 log
drwx------. 2 rich rich 6 Jun 29 11:01 pg_commit_ts
drwx------. 2 rich rich 6 Jun 29 11:01 pg_dynshmem
-rw-------. 1 rich rich 4760 Jun 29 11:01 pg_hba.conf
-rw-------. 1 rich rich 1636 Jun 29 11:01 pg_ident.conf
drwx------. 4 rich rich 68 Jun 29 11:01 pg_logical
drwx------. 4 rich rich 36 Jun 29 11:01 pg_multixact
drwx------. 2 rich rich 6 Jun 29 11:01 pg_notify
drwx------. 2 rich rich 6 Jun 29 11:01 pg_replslot
drwx------. 2 rich rich 6 Jun 29 11:01 pg_serial
drwx------. 2 rich rich 6 Jun 29 11:01 pg_snapshots
drwx------. 2 rich rich 6 Jun 29 11:01 pg_stat
drwx------. 2 rich rich 6 Jun 29 11:01 pg_stat_tmp
drwx------. 2 rich rich 18 Jun 29 11:01 pg_subtrans
drwx------. 2 rich rich 6 Jun 29 11:01 pg_tblspc
drwx------. 2 rich rich 6 Jun 29 11:01 pg_twophase
-rw-------. 1 rich rich 3 Jun 29 11:01 PG_VERSION
drwx------. 3 rich rich 60 Jun 29 11:01 pg_wal
drwx------. 2 rich rich 18 Jun 29 11:01 pg_xact
-rw-------. 1 rich rich 88 Jun 29 11:01 postgresql.auto.conf
-rw-------. 1 rich rich 28098 Jun 29 11:01 postgresql.conf
So now I'm caught between initializing a new database and getting past permissions
. Anybody know how I can get this running?
EDIT: further info
Here is the report behind the permissions issue:
░░ A start job for unit postgresql.service has begun execution.
░░
░░ The job identifier is 2450.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2593]: cat: /var/lib/pgsql/data/PG_VERSION: Permission denied
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: An old version '' of the database format was found.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: You need to dump and reload before using PostgreSQL 13.7.
Jun 29 21:28:58 server1.project33.ca postgresql-check-db-dir[2592]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
Jun 29 21:28:58 server1.project33.ca systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ An ExecStartPre= process belonging to unit postgresql.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jun 29 21:28:58 server1.project33.ca systemd[1]: postgresql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ The unit postgresql.service has entered the 'failed' state with result 'exit-code'.
Jun 29 21:28:58 server1.project33.ca systemd[1]: Failed to start PostgreSQL database server.
░░ Subject: A start job for unit postgresql.service has failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A start job for unit postgresql.service has finished with a failure.
░░
░░ The job identifier is 2450 and the job result is failed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:
sudo Postgresql-setup -initdb
权限>
/var/var/lib/pgsql/data
由PostgreSQL:PostgreSQL:PostgreSQL
拥有。然后使用
postgres
用户登录,从:...创建
postgres
数据库。在内部时,您可以创建角色
和数据库,或退出用户,然后再次使用createb
语法。Solved:
sudo postgresql-setup --initdb
Permissions issue with
/var/lib/pgsql/data
being owned bypostgresql:postgresql
.Then log in using the
postgres
user, start with:...which creates the
postgres
database. While inside, you can createroles
and databases, or exit to your user and use thecreatedb
syntax again.