pg_ctl.exe не запускается с пользовательским postgresql .conf - PullRequest
1 голос
/ 20 июня 2020

Я пытаюсь настроить сценарий PS1 на автоматическую установку PostgreSQL.

  1. Стоп PostgreSQL .\pg_ctl.exe -D "$PostgresInstallPath\data" stop
  2. Заменить файл conf Copy-Item -Path "$PSScriptRoot\postgresql.conf" -Destination "$PostgresInstallPath\data\postgresql.conf" -Force
  3. Старт PostgreSQL .\pg_ctl.exe -D "$PostgresInstallPath\data" start

Это всегда не работает с моим настраиваемым файлом conf, но всегда работает с файлом conf по умолчанию. Файл не выглядит некорректно при открытии в текстовом редакторе, поэтому понятия не имею, почему он не работает.

Кто-нибудь видел что-нибудь подобное или какие-либо мысли о том, где я могу go заставить его работать?

Журнал ошибок не помогает, больше, чем ссылка на ошибку в каждой строке .

2020-06-20 03:43:09.133 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 1, near e
nd of line
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 2, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 3, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 4, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 5, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 6, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 7, near token ""
2020-06-20 03:43:09.134 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 8, near token ""
2020-06-20 03:43:09.135 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 9, near token ""
2020-06-20 03:43:09.136 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 10, near token ""
2020-06-20 03:43:09.136 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 11, near token ""
2020-06-20 03:43:09.137 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 12, near token ""
2020-06-20 03:43:09.138 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 13, near token ""
2020-06-20 03:43:09.139 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 14, near token ""
2020-06-20 03:43:09.139 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 15, near token ""
2020-06-20 03:43:09.139 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 16, near token ""
2020-06-20 03:43:09.139 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 17, near token ""
2020-06-20 03:43:09.141 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 18, near token ""
2020-06-20 03:43:09.142 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 19, near token ""
2020-06-20 03:43:09.142 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 20, near token ""
2020-06-20 03:43:09.142 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 21, near token ""
2020-06-20 03:43:09.142 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 22, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 23, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 24, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 25, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 26, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 27, near token ""
2020-06-20 03:43:09.143 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 28, near token ""
2020-06-20 03:43:09.144 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 29, near token ""
2020-06-20 03:43:09.144 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 30, near token ""
2020-06-20 03:43:09.144 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 31, near token ""
2020-06-20 03:43:09.144 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 32, near token ""
2020-06-20 03:43:09.145 GMT [2104] LOG:  syntax error in file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" line 33, near token ""
2020-06-20 03:43:09.145 GMT [2104] FATAL:  configuration file "C:/Program Files/PostgreSQL/11/Data/postgresql.conf" contains errors

postgresql .conf:

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
listen_addresses = '*'      # what IP address(es) to listen on;
port = 5432             # (change requires restart)
max_connections = 100           # (change requires restart)
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
dynamic_shared_memory_type = windows    # the default is the first option
#------------------------------------------------------------------------------
# WRITE-AHEAD LOG
#------------------------------------------------------------------------------
max_wal_size = 1GB
min_wal_size = 80MB
#------------------------------------------------------------------------------
# REPORTING AND LOGGING
#------------------------------------------------------------------------------
log_destination = 'stderr'      # Valid values are combinations of
logging_collector = on      # Enable capturing of stderr and csvlog
log_file_mode = 0640            # creation mode for log files,
log_timezone = 'CET'
#------------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#------------------------------------------------------------------------------
datestyle = 'iso, mdy'
timezone = 'CET'
lc_messages = 'English_United States.1252'          # locale for system error message
lc_monetary = 'English_United States.1252'          # locale for monetary formatting
lc_numeric = 'English_United States.1252'           # locale for number formatting
lc_time = 'English_United States.1252'              # locale for time formatting
default_text_search_config = 'pg_catalog.english'

1 Ответ

0 голосов
/ 20 июня 2020

Глядя на файл, созданный командой: Get-Content .\postgresql.conf -Encoding Byte | Select-Object -First 10, которая генерирует дамп файла,
вы можете видеть, что файл находится в спецификации UTF-16 кодировке:

255 254 35 0 45 0 45 0 45 0

, потому что он начинается с 255–254 символов (шестнадцатеричное: FF-FE - заголовок спецификации UTF-16 в порядке байтов с прямым порядком байтов).
Также видно, что символ # состоит из двух байтов 35 + 0 и все остальные символы - также состоят из двух байтов 45 + 0, поэтому один символ занимает 16 бит и это наверняка кодировка UTF-16.

PostgreSql скорее всего ожидает postgresql.conf file должен быть обычным файлом ASCII, а не UTF-16 ,
, поэтому, пожалуйста, измените его кодировку на ASCII (или UTF-8), и это должно решить проблему.

...