pg_Ctl - 数据目录的所有权错误
pg_Ctl -data directory has wrong ownership
我无法启动 Postgres 服务器,每当我使用 pg_ctl 时,我都会收到以下错误 - 谁能帮我解决这个问题。我使用 CHmod 更改了文件夹权限并尝试了 运行 Sudo -s 但问题仍然存在。
我犯的一个错误是,当服务器为 运行- post 时,我删除了 Postmaster.pid,每当我尝试通过 [=启动服务器时,我都会遇到这个问题=107=] 和我使用 pgadmin 时的另一个错误。
这里的任何建议都会很有帮助-谢谢。
使用 Macos Shell 命令:
'pg_ctl start -D /Library/PostgreSQL/12/data waiting for server to start....2020-05-05 11:40:04.838 IST [1216] FATAL: data directory "/Library/PostgreSQL/12/data" has wrong ownership 2020-05-05 11:40:04.838 IST [1216] HINT: The server must be started by the user that owns the data directory. stopped waiting pg_ctl: could not start server Examine the log output.'
使用pgadmin报错如下:
'could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5434? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5434?'
p.s。 : 我修改了 hba.conf 和 postgres.conf 文件以允许从本地 ip
连接
5 月 5 日收到错误
正在等待服务器启动....2020-05-05 19:54:13.029 IST [7274] 日志:在 x86_64-apple-darwin 上启动 PostgreSQL 12.2,由 Apple LLVM 6.0 版编译(clang -600.0.54)(基于 LLVM 3.5svn),64 位
2020-05-05 19:54:13.030 IST [7274] 日志:侦听 IPv6 地址“::”,端口 5433
2020-05-05 19:54:13.030 IST [7274] 日志:侦听 IPv4 地址“0.0.0.0”,端口 5433
2020-05-05 19:54:13.030 IST [7274] 日志:侦听 Unix 套接字“/tmp/.s.PGSQL.5433”
2020-05-05 19:54:13.039 IST [7274] 日志:将日志输出重定向到日志收集器进程... 2020-05-05 19:54:13.039 IST [7274] 提示:未来的日志输出将出现在目录 "log" 停止等待.. pg_ctl: 无法启动服务器
检查日志输出。
日志文件详细信息
2020-05-05 21:29:30.748 IST [8853] LOG: invalid authentication method "0.0.0.0/0"
2020-05-05 21:29:30.748 IST [8853] CONTEXT: line 80 of configuration file "/Library/PostgreSQL/12/data/pg_hba.conf"
2020-05-05 21:29:30.748 IST [8853] FATAL: could not load pg_hba.conf
2020-05-05 21:29:30.749 IST [8853] LOG: database system is shut down
Details of my pg_HBA conf
# "local" is for Unix domain socket connections only
local all all 0.0.0.0/0 md5
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all md5
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all 0.0.0.0/0 md5
host all all ::/0 md5
最新日志文件
bash-3.2$猫postgresql-2020-05-05_221328.log
2020-05-05 22:13:28.794 IST [9834] 日志:数据库系统中断;最后一次为人所知是在 2020-05-05 22:13:09 IST
2020-05-05 22:13:28.872 IST [9834] 日志:数据库系统未正确关闭;正在进行自动恢复
2020-05-05 22:13:28.874 IST [9834] 日志:重做从 0/17742C8 开始
2020-05-05 22:13:28.874 IST [9834] 日志:0/1774300 处的无效记录长度:想要 24,得到 0
2020-05-05 22:13:28.874 IST [9834] 日志:重做于 0/17742C8
2020-05-05 22:13:28.881 IST [9832] 日志:数据库系统已准备好接受连接
……
我在启动服务器时也发现了这个错误,PID 每次都在变化..
pg_ctl:另一台服务器可能是 运行;仍然尝试启动服务器
等待服务器启动....2020-05-05 22:09:21.941 IST [9746] 致命:锁定文件 "postmaster.pid" 已存在
2020-05-05 22:09:21.941 IST [9746] 提示:数据目录“/Library/PostgreSQL/12/data”中是否有另一个 postmaster (PID 9735) 运行?
停止等待
pg_ctl: 无法启动服务器
检查日志输出。
bash-3.2$杀-9 9735
bash-3.2$pg_ctl开始-D/Library/PostgreSQL/12/data
pg_ctl:另一台服务器可能是 运行;仍然尝试启动服务器
等待服务器启动....2020-05-05 22:09:35.829 IST [9758] 致命:锁定文件 "postmaster.pid" 已存在
2020-05-05 22:09:35.829 IST [9758] 提示:数据目录“/Library/PostgreSQL/12/data”中是否有另一个 postmaster (PID 9747) 运行?
停止等待
pg_ctl: 无法启动服务器
检查日志输出。
502 9833 9832 0 10:13PM ?? 0:00.00 postgres: 记录器
502 9835 9832 0 10:13PM ?? 0:00.00 postgres: 检查指针
502 9836 9832 0 10:13PM ?? 0:00.04 postgres: 背景作者
502 9837 9832 0 10:13PM ?? 0:00.01 postgres: walwriter
502 9838 9832 0 10:13PM ?? 0:00.01 postgres:autovacuum 启动器
502 9839 9832 0 10:13PM ?? 0:00.01 postgres:统计数据收集器
502 9840 9832 0 10:13PM ?? 0:00.00 postgres:逻辑复制启动器
0 9641 9504 0 10:03PM ttys000 0:00.02 sudo -u postgres -s /bin/bash
502 9904 9642 0 10:37PM ttys000 0:00.00 grep postgres
数据目录应该由 postgres 用户拥有并且只有用户访问权限(700 或 u+rwx)
这与您设置的匹配吗?
汤姆·布朗
披露:我是 EnterpriseDB 员工。
试试运行这个代码
pg_ctl -D /usr/local/var/postgres start
我无法启动 Postgres 服务器,每当我使用 pg_ctl 时,我都会收到以下错误 - 谁能帮我解决这个问题。我使用 CHmod 更改了文件夹权限并尝试了 运行 Sudo -s 但问题仍然存在。
我犯的一个错误是,当服务器为 运行- post 时,我删除了 Postmaster.pid,每当我尝试通过 [=启动服务器时,我都会遇到这个问题=107=] 和我使用 pgadmin 时的另一个错误。
这里的任何建议都会很有帮助-谢谢。
使用 Macos Shell 命令:
'pg_ctl start -D /Library/PostgreSQL/12/data waiting for server to start....2020-05-05 11:40:04.838 IST [1216] FATAL: data directory "/Library/PostgreSQL/12/data" has wrong ownership 2020-05-05 11:40:04.838 IST [1216] HINT: The server must be started by the user that owns the data directory. stopped waiting pg_ctl: could not start server Examine the log output.'
使用pgadmin报错如下:
'could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5434? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5434?'
p.s。 : 我修改了 hba.conf 和 postgres.conf 文件以允许从本地 ip
连接5 月 5 日收到错误
正在等待服务器启动....2020-05-05 19:54:13.029 IST [7274] 日志:在 x86_64-apple-darwin 上启动 PostgreSQL 12.2,由 Apple LLVM 6.0 版编译(clang -600.0.54)(基于 LLVM 3.5svn),64 位 2020-05-05 19:54:13.030 IST [7274] 日志:侦听 IPv6 地址“::”,端口 5433 2020-05-05 19:54:13.030 IST [7274] 日志:侦听 IPv4 地址“0.0.0.0”,端口 5433 2020-05-05 19:54:13.030 IST [7274] 日志:侦听 Unix 套接字“/tmp/.s.PGSQL.5433” 2020-05-05 19:54:13.039 IST [7274] 日志:将日志输出重定向到日志收集器进程... 2020-05-05 19:54:13.039 IST [7274] 提示:未来的日志输出将出现在目录 "log" 停止等待.. pg_ctl: 无法启动服务器
检查日志输出。
日志文件详细信息
2020-05-05 21:29:30.748 IST [8853] LOG: invalid authentication method "0.0.0.0/0"
2020-05-05 21:29:30.748 IST [8853] CONTEXT: line 80 of configuration file "/Library/PostgreSQL/12/data/pg_hba.conf"
2020-05-05 21:29:30.748 IST [8853] FATAL: could not load pg_hba.conf
2020-05-05 21:29:30.749 IST [8853] LOG: database system is shut down
Details of my pg_HBA conf
# "local" is for Unix domain socket connections only
local all all 0.0.0.0/0 md5
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all md5
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all 0.0.0.0/0 md5
host all all ::/0 md5
最新日志文件
bash-3.2$猫postgresql-2020-05-05_221328.log 2020-05-05 22:13:28.794 IST [9834] 日志:数据库系统中断;最后一次为人所知是在 2020-05-05 22:13:09 IST 2020-05-05 22:13:28.872 IST [9834] 日志:数据库系统未正确关闭;正在进行自动恢复 2020-05-05 22:13:28.874 IST [9834] 日志:重做从 0/17742C8 开始 2020-05-05 22:13:28.874 IST [9834] 日志:0/1774300 处的无效记录长度:想要 24,得到 0 2020-05-05 22:13:28.874 IST [9834] 日志:重做于 0/17742C8 2020-05-05 22:13:28.881 IST [9832] 日志:数据库系统已准备好接受连接 …… 我在启动服务器时也发现了这个错误,PID 每次都在变化..
pg_ctl:另一台服务器可能是 运行;仍然尝试启动服务器 等待服务器启动....2020-05-05 22:09:21.941 IST [9746] 致命:锁定文件 "postmaster.pid" 已存在 2020-05-05 22:09:21.941 IST [9746] 提示:数据目录“/Library/PostgreSQL/12/data”中是否有另一个 postmaster (PID 9735) 运行? 停止等待 pg_ctl: 无法启动服务器 检查日志输出。 bash-3.2$杀-9 9735 bash-3.2$pg_ctl开始-D/Library/PostgreSQL/12/data pg_ctl:另一台服务器可能是 运行;仍然尝试启动服务器 等待服务器启动....2020-05-05 22:09:35.829 IST [9758] 致命:锁定文件 "postmaster.pid" 已存在 2020-05-05 22:09:35.829 IST [9758] 提示:数据目录“/Library/PostgreSQL/12/data”中是否有另一个 postmaster (PID 9747) 运行? 停止等待 pg_ctl: 无法启动服务器
检查日志输出。
502 9833 9832 0 10:13PM ?? 0:00.00 postgres: 记录器
502 9835 9832 0 10:13PM ?? 0:00.00 postgres: 检查指针
502 9836 9832 0 10:13PM ?? 0:00.04 postgres: 背景作者
502 9837 9832 0 10:13PM ?? 0:00.01 postgres: walwriter
502 9838 9832 0 10:13PM ?? 0:00.01 postgres:autovacuum 启动器
502 9839 9832 0 10:13PM ?? 0:00.01 postgres:统计数据收集器
502 9840 9832 0 10:13PM ?? 0:00.00 postgres:逻辑复制启动器
0 9641 9504 0 10:03PM ttys000 0:00.02 sudo -u postgres -s /bin/bash
502 9904 9642 0 10:37PM ttys000 0:00.00 grep postgres
数据目录应该由 postgres 用户拥有并且只有用户访问权限(700 或 u+rwx)
这与您设置的匹配吗?
汤姆·布朗
披露:我是 EnterpriseDB 员工。
试试运行这个代码
pg_ctl -D /usr/local/var/postgres start