Postgresql

在postgres 12上遇到安裝問題

  • October 26, 2020

我安裝了postgres-12,但是報這個錯誤,我已經執行sudo systemctl restart postgresql-12,然後按照這個在centos 7上安裝postgres12,當我進入第5步時:啟用遠端訪問,並執行sudo systemctl restart postgresql-12它報告錯誤

[root@localhost ~]# systemctl status postgresql-12
● postgresql-12.service - PostgreSQL 12 database server
  Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since Sun 2020-10-25 12:29:05 CST; 11min ago
    Docs: https://www.postgresql.org/docs/12/static/
 Process: 7462 ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA} (code=exited, status=1/FAILURE)
 Process: 7456 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 7462 (code=exited, status=1/FAILURE)

Oct 25 12:29:05 localhost.localdomain systemd[1]: Starting PostgreSQL 12 database server...
Oct 25 12:29:05 localhost.localdomain systemd[1]: postgresql-12.service: main process exited, code=exited, status...LURE
Oct 25 12:29:05 localhost.localdomain systemd[1]: Failed to start PostgreSQL 12 database server.
Oct 25 12:29:05 localhost.localdomain systemd[1]: Unit postgresql-12.service entered failed state.
Oct 25 12:29:05 localhost.localdomain systemd[1]: postgresql-12.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit postgresql-12.service has begun starting up.
Oct 25 12:56:02 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.994 CST [7586] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-gnu, compile
Oct 25 12:56:02 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.995 CST [7586] LOG:  could not bind IPv4 address "172.18.56.1": Cannot assign
Oct 25 12:56:02 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.995 CST [7586] HINT:  Is another postmaster already running on port 5432? If 
Oct 25 12:56:03 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.995 CST [7586] WARNING:  could not create listen socket for "172.18.56.1"
Oct 25 12:56:03 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.995 CST [7586] FATAL:  could not create any TCP/IP sockets
Oct 25 12:56:03 localhost.localdomain postmaster[7586]: 2020-10-25 12:56:02.995 CST [7586] LOG:  database system is shut down
Oct 25 12:56:02 localhost.localdomain systemd[1]: postgresql-12.service: main process exited, code=exited, status=1/FAILURE
Oct 25 12:56:03 localhost.localdomain systemd[1]: Failed to start PostgreSQL 12 database server.
-- Subject: Unit postgresql-12.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit postgresql-12.service has failed.
-- 
-- The result is failed.
Oct 25 12:56:03 localhost.localdomain systemd[1]: Unit postgresql-12.service entered failed state.
Oct 25 12:56:03 localhost.localdomain systemd[1]: postgresql-12.service failed.
Oct 25 12:56:03 localhost.localdomain sudo[7572]: pam_unix(sudo:session): session closed for user root
Oct 25 12:56:03 localhost.localdomain polkitd[3564]: Unregistered Authentication Agent for unix-process:7574:595409 (system bus name :1.50, object path /
lines 2127-2149/2149 (END)

您的日誌行被截斷(當您想要完整輸出時使用--no-pagerwith journalctl),但最相關的完整錯誤消息可能是:

2020-10-25 12:56:02.995 CST

$$ 7586 $$日誌:無法綁定 IPv4 地址“172.18.56.1”:無法分配**$$ truncated here $$**請求的地址

您沒有提及您設置listen_addresses的內容,但對此錯誤的一個合理解釋是它設置為172.18.56.1,並且該地址未分配給主機的網路介面,因此在 中使用它是錯誤的 listen_addresses

使用ifconfigip a list查看主機上的網路地址。

引用自:https://dba.stackexchange.com/questions/278679