使用docker安装的pg9.5容器,突然云主机升级直接停机后pg数据库容器启动不了后查看容器日志提示以下内容,
解决:按提示将容器的配置文件复制出来后修改后再复制到容器中
sudo docker cp pg_hba.conf 4d62f4628665:/var/lib/postgresql/data/pg_hba.conf //将本地配置文件复制到容器中
sudo docker cp 4d62f4628665:/var/lib/postgresql/data/pg_hba.conf . //将容器配置文件复制到当前目录中
LOG: syntax error in file "/var/lib/postgresql/data/postgresql.conf" line 1, near token "*"
FATAL: configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors
listen_addresses =¡¯*¡¯ 改为 listen_addresses = "*"后报以下错误:
LOG: syntax error in file "/var/lib/postgresql/data/postgresql.conf" line 1, near token """
FATAL: configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors
listen_addresses = "*"改为 listen_addresses = '*'后启动正常
LOG: invalid connection type "*host"
CONTEXT: line 6 of configuration file "/var/lib/postgresql/data/pg_hba.conf"
FATAL: could not load pg_hba.conf
PostgreSQL Database directory appears to contain a database; Skipping initialization
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
*host all all 0.0.0.1/0 md5*
# IPv6 local connections:
host all all ::1/128 trust
LOG: invalid authentication method "md5*"
CONTEXT: line 6 of configuration file "/var/lib/postgresql/data/pg_hba.conf"
*host all all 0.0.0.1/0 md5* 将这行的*都去掉就可以了