Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL installer does not work over a WinRM session. #150

Closed
Resident-Alien opened this issue Sep 4, 2024 · 24 comments
Closed

PostgreSQL installer does not work over a WinRM session. #150

Resident-Alien opened this issue Sep 4, 2024 · 24 comments

Comments

@Resident-Alien
Copy link

With both PSRemoting and or Invoke-Command the PostgreSQL installer fails at the same place every time:


The database cluster will be initialized with locale "English_United States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.
initdb: error: could not open file "C:\Users%username%\AppData\Local\Temp/postgresql_installer_db2b356bbd\rad92FA3.tmp" for reading: Permission denied

Called Die(Failed to initialise the database cluster with initdb)...
Failed to initialise the database cluster with initdb

Script stderr:
Program ended with an error exit code

Error running C:\Windows\System32\cscript //NoLogo "C:\Program Files\PostgreSQL\16/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users%username%\AppData\Local\Temp/postgresql_installer_db2b356bbd" "C:\Program Files\PostgreSQL\16" "C:\Program Files\PostgreSQL\16\data" 5432 "DEFAULT" 1: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.
Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.
Setting variable whoami from C:\Windows\System32\whoami
Script exit code: 0


I thought this was a permissions issue, but when you remote into a windows server via WinRM your security context is set at your users highest level. I am a domain admin thus when I remote in my user is a domain admin, no need to elevate. The command works fine if you are local on the server and run in an elevated command prompt.

This affects both winget and just running the installer manually in the ps remote session. Is the installer just not able to be pushed to remote servers? Oddly enough Chocolately does seem to work without issue but they are always way behind and you can't rely on them if you need constant updates.

@sandeep-edb
Copy link
Contributor

Hi,
are you installing on a domain controller? Can you specify the installer version? Also if you can please share the installation log (created in TEMP)?

@Cylindric
Copy link

I'm seeing the same thing too, although it's made a bit more complex by being redistributable 15.8-1-windows via the Veeam silent installer, so I can't supply any alternative CLI arguments.

I am installing via Windows DSC, so the command is running in a PowerShell "Start-Process" as a domain administrator user.

Exactly same log output as @Resident-Alien.

@Resident-Alien
Copy link
Author

My apologies for not responding sooner.
I was installing postgres 16.4.1.
This was not on a domain controller.
To reproduce all you need to do is use WinRM (I used WinRMs) to connect to a remote server and then run the winget install command:
winget install "PostgreSql 16"

Or download the installer for 16.4.1, put it on the remote server, and then use either WinRM to access the server or Invoke-Command to attempt to execute the installer on the remote system. They all fail at the same place.

As for the install log, I shared the part where it failed. If I install locally the log is identical up until the point where it fails for the remote session.

initcluster.vbs is the failure point.

@Cylindric
Copy link

Cylindric commented Sep 26, 2024

Here's my experience, I've just reproduced directly with the Postgresql installer:

$installer = "C:\VeeamInstaller\Redistr\x64\PostgreSQL\15.8-1\postgresql-15.8-1-windows-x64.exe"

$args = @(
    "--mode unattended",
    "--unattendedmodeui none",
    "--datadir D:\data",
    "--serverport 5432",
    "--superaccount `"the_username`"",
    "--superpassword `"the_password`""
)
Start-Process -Wait -FilePath $installer -ArgumentList $args

Which ends up being something like this:

C:\VeeamInstaller\Redistr\x64\PostgreSQL\15.8-1\postgresql-15.8-1-windows-x64.exe --mode unattended -–unattendedmodeui none -–datadir D:\data -–serverport 5432 --superaccount "the_user" -–superpassword "the_password"

The pertinent part of the log is


Data page checksums are disabled.
initdb: error: could not open file "C:\Users\Administrator\AppData\Local\Temp/postgresql_installer_3292d5d9ac\radF55AB.tmp" for reading: Permission denied

Called Die(Failed to initialise the database cluster with initdb)...
Failed to initialise the database cluster with initdb

Script stderr:
 Program ended with an error exit code

Error running C:\Windows\System32\cscript //NoLogo "C:\Program Files\PostgreSQL\15/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "the_username" "****" "C:\Users\Administrator\AppData\Local\Temp/postgresql_installer_3292d5d9ac" "C:\Program Files\PostgreSQL\15" "D:\data" 5432 "DEFAULT" 0: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
 The database cluster initialisation failed.
Problem running post-install step. Installation may not complete correctly
 The database cluster initialisation failed.
Setting variable whoami from C:\Windows\System32\whoami 
Script exit code: 0

I am running as domain admin. If I run the command manually in a shell it works fine. Kind of defeats the whole point of a "silent install" if I have to do it manually though...

Edited to add, that temp file it's talking about "opening for read", doesn't exist. The folder does, but that file does not.

C:\Users\Administrator\AppData\Local\Temp/postgresql_installer_3292d5d9ac\ exists
C:\Users\Administrator\AppData\Local\Temp/postgresql_installer_3292d5d9ac\radF55AB.tmp does not

@WhileLoop
Copy link

@Resident-Alien @Cylindric Were you able to find a workaround?

@Resident-Alien
Copy link
Author

No work around found yet. As I noted in the problem the Chocolatey installer does indeed work. So to deploy to numerous servers in an automated way I am having to resort to Chocolatey with a local package cache so I can control the version. Winget and or command line installer options do not work remotely.

@WhileLoop
Copy link

@sandeep-edb Is EDB team aware of this issue? I can confirm that this is reproducible. We were able to remotely install v12 but updating to v16 installer fails with above error.

@maitrikpatelBH
Copy link

I also facing same silent remote installation issues using remote powershell .. Any update on this issue?

@Cylindric
Copy link

@Resident-Alien @Cylindric Were you able to find a workaround?

Alas, no workaround has been found so far, we've resorted to a manual process like it's 1997.

@moerwald
Copy link

I also facing same silent remote installation issues using remote powershell .. Any update on this issue?

@moerwald
Copy link

moerwald commented Nov 3, 2024

@Cylindric i switched to this powershell script -> https://github.com/darianmiller/install-postgres-on-windows. It runs in a PowerShell remoting session, and does most of the job.

@maitrikpatelBH
Copy link

Hi, are you installing on a domain controller? Can you specify the installer version? Also if you can please share the installation log (created in TEMP)?

Hi Sandeep, any update on this issue? As this is show stopper issue for us , and does not allow automating installation using poweshell script

@HAldermo-Magnet
Copy link

We are experiencing the same issue on PostgreSQL versions 16, 15, 14, 13 and 12.
Installing using choco and Azure Image Builder (uses packer).

@prafsh
Copy link

prafsh commented Nov 27, 2024

@EDB / @sandeep-edb removal of icacls commands from installer has resulted into this issue. We have seen at least 2 installers released after reporting of this issue. Is EDB planning to fix it or we have to just live with it.

Line# 134 & 140 in below commit :

be9a18f3#diff-9dba0556fbd266ae0027adef444866ef186d7a4c6de8d3e10ca184332a013711L134

@JacobGudbjerg
Copy link

I am experiencing the same issue with version 17

@sandeep-edb
Copy link
Contributor

@prafsh I'll check that and fix it. Thanks for the pointer.

@sandeep-edb
Copy link
Contributor

I've uploaded a test installer with a fix at https://get.enterprisedb.com/test-installers/postgresql-16.6-0.0snapshot12194602453.1003.1.64d4c34.2-windows-x64.exe Could someone install and confirm the behaviour please? If it works then I'll push the fix and generate the release builds.

@JacobGudbjerg
Copy link

JacobGudbjerg commented Dec 6, 2024

I still get this:

I don't know if it is relevant but the slash right after "Temp" is / instead of \ in the path it complains about .

...
processed file: C:\Platinum\PostgreSQL\17\share\tsearch_data\xsyn_sample.rules
Successfully processed 25394 files; Failed processing 0 files

Ensuring we can write to the data directory (using icacls) to MFD-250\wAdmin:
Executing batch file 'radC47A3.bat'...
processed file: C:\ANC2010\Data\PostgreSQL\17
Successfully processed 1 files; Failed processing 0 files

Granting full access to (NT AUTHORITY\NetworkService) on (C:\ANC2010\Data\PostgreSQL\17)
Executing batch file 'radC47A3.bat'...
processed file: C:\ANC2010\Data\PostgreSQL\17
Successfully processed 1 files; Failed processing 0 files

Granting full access to CREATOR OWNER on (C:\ANC2010\Data\PostgreSQL\17)
Executing batch file 'radC47A3.bat'...
processed file: C:\ANC2010\Data\PostgreSQL\17
Successfully processed 1 files; Failed processing 0 files

Granting full access to SYSTEM on (C:\ANC2010\Data\PostgreSQL\17)
Executing batch file 'radC47A3.bat'...
processed file: C:\ANC2010\Data\PostgreSQL\17
Successfully processed 1 files; Failed processing 0 files

Granting full access to Administrators on (C:\ANC2010\Data\PostgreSQL\17)
Executing batch file 'radC47A3.bat'...
processed file: C:\ANC2010\Data\PostgreSQL\17
Successfully processed 1 files; Failed processing 0 files

Executing batch file 'radC47A3.bat'...
The files belonging to this database system will be owned by user "wAdmin".

This user must also own the server process.

The database cluster will be initialized with locale "English_United States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.
initdb: error: could not open file "C:\Users\wAdmin\AppData\Local\Temp/postgresql_installer_22a62ec5cd\rad4E73F.tmp" for reading: Permission denied

Called Die(Failed to initialise the database cluster with initdb)...
Failed to initialise the database cluster with initdb

Script stderr:
Program ended with an error exit code

Error running C:\WINDOWS\System32\cscript //NoLogo "C:\Platinum\PostgreSQL\17/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\wAdmin\AppData\Local\Temp/postgresql_installer_22a62ec5cd" "C:\Platinum\PostgreSQL\17" "C:\ANC2010\Data\PostgreSQL\17" 5432 "DEFAULT" 1: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
...

@sandeep-edb
Copy link
Contributor

No, it's not related to slash. Can you try with the v16 test installer that I shared above?

@JacobGudbjerg
Copy link

That's the one I tried with. I just didn't change the folder names in my script hence the 17 instead of 16.

@prafsh
Copy link

prafsh commented Dec 9, 2024

I've uploaded a test installer with a fix at https://get.enterprisedb.com/test-installers/postgresql-16.6-0.0snapshot12194602453.1003.1.64d4c34.2-windows-x64.exe Could someone install and confirm the behaviour please? If it works then I'll push the fix and generate the release builds.

@sandeep-edb I have tested this installer and behavior is still same. It fails while performing remote installation, one windows server to another windows server over the WinRM.

@NarsingaBH
Copy link

I've uploaded a test installer with a fix at https://get.enterprisedb.com/test-installers/postgresql-16.6-0.0snapshot12194602453.1003.1.64d4c34.2-windows-x64.exe Could someone install and confirm the behaviour please? If it works then I'll push the fix and generate the release builds.

@sandeep-edb We have tested this and does not work. Please can you take this on priority and fix.

@sandeep-edb
Copy link
Contributor

installers for 13 to 17 (with -3 package revision) are now available which includes the fix for remote installation issue. Please give it a try

@prafsh
Copy link

prafsh commented Dec 19, 2024

Thanks @sandeep-edb for the update. I have tested the new installers and issue is resolved for me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants