cancel
Showing results for 
Search instead for 
Did you mean: 

PostgreSQL Installer fails at Initializing the database cluster. Help.

EDB Team Member

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

Hi @linkmichon,

 

Looks like you are also facing the issue with post installation steps for installing the postgres on Windows server.

 

The cluster initialization fails at the post-installation steps, this could happen due to below reasons:

 

1) Check whether any anti-virus software or other software such security software is running which could be blocking the execution of the vb script of the post installation step.
2) Use the admin user to install the postgres and make sure you have privileges on the data directory location.

 

Please check above and try the installation again and get back to us in case of any issues/queries.

 

Regards,

Sudhir

Adventurer

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

This seems to be a prevelant issue with many different versions of the database and lots of people providing lots of different answers, however none of them have worked for me. I am trying to install postgresql-12.0-1-windows-x64.exe.  I have tried changing the location of my data folder, I have checked %COMSPEC%, I have disabled AVAST, I have tried manually changing the permissions on my data folder but no luck.  Here is I believe the pertinent section of the log file:

 

[02:44:33] Running the post-installation/upgrade actions:
[02:44:33] Write the base directory to the ini file...
[02:44:33] Write the version number to the ini file...
Initialising the database cluster (this may take a few minutes)...
Executing cscript //NoLogo "C:\Program Files\PostgreSQL\12/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_0339009b14" "C:\Program Files\PostgreSQL\12" "C:\Program Files\PostgreSQL\12\data" 5432 "DEFAULT" 0
Script exit code: 1

Script output:
WScript.Shell Initialized...
Scripting.FileSystemObject initialized...

Called CreateDirectory(C:\Program Files\PostgreSQL\12\data)...
Called CreateDirectory(C:\Program Files\PostgreSQL\12)...
Called ClearAcl (C:\Program Files\PostgreSQL\12\data)...
Executing batch file 'radF5BB8.bat'...
Called Die(Failed to reset the ACL (C:\Program Files\PostgreSQL\12\data))...
Failed to reset the ACL (C:\Program Files\PostgreSQL\12\data)

Script stderr:
Program ended with an error exit code

Error running cscript //NoLogo "C:\Program Files\PostgreSQL\12/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_0339009b14" "C:\Program Files\PostgreSQL\12" "C:\Program Files\PostgreSQL\12\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.
Executing icacls "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_1b52e140ee" /inheritance:r
Script exit code: 0

 

radF5BB8.bat is failing.  The contents of the bat file are:  

 

@ECHO OFF
CHCP 1252
icacls "C:\Program Files\PostgreSQL\12\data > "C:\Users\lehrian\AppData\Local\Temp\rad2ABF0.tmp" 2>&1
EXIT /B %ERRORLEVEL%

 

I notice there is a " missing from after data.  I believe this is causing this script to fail and the rest of initcluster.vbs to die. 

 

The method call in initcluster.vbs that generates this file is DoCmd and I have included it here.  I believe the error is on the bolded line.  The single " should be triple like """.  This will add the closing " to the command.  As this file gets overwritten ever time I run the installer I can't test to see that this actually fixes the issue so I still don't have PostgreSQL installed :-(  Any ideas how to get the installation to complete?  

 

' Execute a command
Function DoCmd(strCmd)
Dim objBatchFile
Set objBatchFile = objTempFolder.CreateTextFile(strBatchFile, True)
objBatchFile.WriteLine "@ECHO OFF"
objBatchFile.WriteLine "CHCP " & objShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP")
objBatchFile.WriteLine strCmd & " > """ & strOutputFile & """ 2>&1"
objBatchFile.WriteLine "EXIT /B %ERRORLEVEL%"
objBatchFile.Close
WScript.Echo " Executing batch file '" & strBatchFile & "'..."
DoCmd = objShell.Run(objTempFolder.Path & "\" & strBatchFile, 0, True)
If objFso.FileExists(objTempFolder.Path & "\" & strBatchFile) = True Then
objFso.DeleteFile objTempFolder.Path & "\" & strBatchFile, True
Else
WScript.Echo " Batch file '" & strBatchFile & "' does not exist..."
End If
If objFso.FileExists(strOutputFile) = True Then
Dim objOutputFile
Set objOutputFile = objFso.OpenTextFile(strOutputFile, ForReading)
WScript.Echo " " & objOutputFile.ReadAll
objOutputFile.Close
objFso.DeleteFile strOutputFile, True
Else
WScript.Echo " Output file does not exists..."
End If
End Function

Adventurer

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

Well that didn't solve my problem.  I was able to replace the initcluster.vbs with my edited version that had the three " in it and the radE53CC.bat file looked better but I still got the failure.  Here is the pertinent section of the log file.

 

Script output:
WScript.Shell Initialized...
Scripting.FileSystemObject initialized...

Called CreateDirectory(C:\Users\lehrian\Documents\PostgresData)...
Called CreateDirectory(C:\Users\lehrian\Documents)...
Called ClearAcl (C:\Users\lehrian\Documents\PostgresData)...
Executing batch file 'radE53CC.bat'...
Called Die(Failed to reset the ACL (C:\Users\lehrian\Documents\PostgresData))...
Failed to reset the ACL (C:\Users\lehrian\Documents\PostgresData)

Script stderr:
Program ended with an error exit code

Error running cscript //NoLogo "C:\Program Files\PostgreSQL\12/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_6836f804fd" "C:\Program Files\PostgreSQL\12" "C:\Users\lehrian\Documents\PostgresData" 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.
Executing icacls "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_420debc0cc" /inheritance:r
Script exit code: 0

 

So I saw another post where you suggested running the command manually.  Here is the command I ran:

 

C:\Users\lehrian\AppData\Local\Temp>"C:\Program Files\PostgreSQL\12/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "123iop" "C:\Users\lehrian\AppData\Local\Temp/postgresql_installer_0339009b14" "C:\Program Files\PostgreSQL\12" "C:\Users\lehrian\Documents\PostgresData" 5432 "DEFAULT" 0

 

I changed the data file to not be under Program Files as I know that can sometimes be dicey.  I don't think I mentioned I'm on Windows 10 and there are no pending updates.  

 

I got the same error as was in the log file:

 

Called Die(Failed to reset the ACL (C:\Users\lehrian\Documents\PostgresData))...

 

So I am now completely stumped.  Any ideas?  

Adventurer

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

Wow.  Well I finally got it to work by manually initializing the database cluster.  I installed PostgreSQL into C:\PostgreSQL and not under Program Files.  I then ran the command:

 

initdb -D c:\PostgreSQL\Data

 

and at first it failed with a Permission denied.  So I manually changed the permission on the C:\PostgreSQL folder to give the Users group Full Control.  Then I ran the command again and it worked!  I then used the command that it told me:

 

pg_ctl -D ^"c^:^\PostgreSql^\Data^" -l logfile start

 

and the server started.  I was able to use pgAdmin 4 and see the cluster and database.  I then shut down pgAdmin 4 server and ran the installation program again and it finally completed successfully.  Though I still don't see a PostgreSQL service so I'm not sure what will happen when I reboot, but at least I have made some progress.  I have to say, this has not been the easiest database server I have installed.  

Highlighted
EDB Team Member

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

Hi dlehrian,

 

Glad that you were able to proceed on this task by changing the permissions and the location.

Earlier you did mentioned about, the change in location for the data directory and the necessary permissions.

So those possibilities were ruled out at that point of instance.

Can you share the bitrock installer logs and the database logs.

Adventurer

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

Yeah, that was odd as that was one of the first suggestions I came across.  It said to give Full Control to Users and then run the installer again.  I tried that and it didn't work.  I also tried putting the data files in my Documents folder and I tried installing everything under C:\PostgreSQL but I didn't get it to work until I ran the cluster initialization manually.  

 

So regarding log files, do you want the log from one of the earlier ones that failed or from the last one that succeeded?  I see the bitrock_installer.log files in the %temp% folder.  Where are the database log files you are looking for?  

Adventurer

Re: PostgreSQL Installer fails at Initializing the database cluster. Help.

We finally gave up, and switched PCs.  Not really an acceptable solution but we had to live with it.  Sorry to hear that it is still a problem with newer releases.

 
JAB