giovedì 31 gennaio 2013

PostgreSQL: The database cluster initialization failed

I had the same issue installing 9.1.4 on Windows 7. I managed to find a solution online that worked.
The steps I followed are:
  1. Uninstall PostgreSQL
  2. Delete the postgres user if it still exists.
    net user postgres /delete
  3. Create the postgres user with a password you can remember
  4. Add the postgres user to the Administrators group
  5. Add the postgres user to the Power Users group
  6. Run a command window as the postgres user
    runas /user:postgres cmd.exe
  7. Run the install file from within the command window.
    C:\Download\postgresql-9.1.4-1-windows.exe
    This should run the installation successfully.
  8. Remove the postgres user from the Administrators group.

mercoledì 30 gennaio 2013

Postgres - clustering failed

Posting this because no other posted solutions on this forum worked for me. Might help some others

Relevent specs:
- Win 7 Pro x64 SP1, Avira Antivir, Windows Firewall

Problem:
- Cannot install PostgreSQL via HM2 bundle

Code:
Connection to DB failed: --> could not connect to server: Connection refused "
- Cannot install PostgreSQL 8.3/8.4/9.0/9.1 via official website:
Code:
Ensuring we can write to the data directory (using icacls) to  w0ng:
    Executing batch file 'rad612AE.bat'...
    processed file: C:\PostgreSQL\data
Successfully processed 1 files; Failed processing 0 files

Failed to ensure the data directory is accessible (C:\PostgreSQL\data)
    Executing batch file 'rad612AE.bat'...
    The files belonging to this database system will be owned by user "w0ng".
This user must also own the server process.

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

fixing permissions on existing directory C:/PostgreSQL/data ... ok
creating subdirectories ... ok
selecting default max_connections ... The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
10
selecting default shared_buffers ... The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
400kB
creating configuration files ... ok
creating template1 database in C:/PostgreSQL/data/base/1 ... The system cannot find the path specified.
child process exited with exit code 1
initdb: removing contents of data directory "C:/PostgreSQL/data"

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 cscript //NoLogo "C:\PostgreSQL/installer/server/initcluster.vbs" "postgres" "postgres" "****" "C:\PostgreSQL" "C:\PostgreSQL\data" 5432 "DEFAULT" : Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
 The database cluster initialisation failed.























 ----------------------













Troubleshooting:
- Run install as admin -> same problem
- Disable AV + Firewall + Windows Defender -> same problem
- Edit C:\Windows\System32\drivers\etc\hosts -> reboot -> same problem
- Uninstalled AV -> same problem
- Disabled UAC -> same problem
- services.msc -> restart Secondary Logon Service -> same problem
- Installed to c:\postgresql and c:\pgdata for data directory -> same problem
- create folder C:\pgdata -> Properties -> Security -> Edit... -> Add... -> "postgres" -> OK -> Full Control -> same problem
- manually running initdb -D C:\pgdata -> same problem
- runas /user:postgres cmd.exe -> initdb -D C:\pgdata -> initdb successful, but when trying to "Start Server" -> "The system cannot find the path specified." -> checked services.msc -> no postgresql service was created during installation

Solution:
- Uninstall PostgreSQL
- net user postgres /delete
- Control Panel -> User Accounts -> Configure advanced user profile properties -> delete all "Unknown User" instances that seem to be left from postgres
- compmgmt.msc -> Local Users and Groups -> Users -> New User... -> User name: postgres, Password: postgrespass -> Create
- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Add... -> Administrators -> OK
- copy postgresql-8.4.9-1-windows.exe to C:\
- runas /user:postgres cmd.exe -> cd \ -> postgresql-8.4.9-1-windows.exe -> installed successfully without errors. Checked data folder and confirmed files created successfully.

- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Administrators -> Remove
- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Add... -> Power Users -> OK
- Installed HM2 -> created db successfully
- Restarted computer -> HM2 runs properly (i.e. just to check postgresql service starts automatically)

Kind of annoying that no one else seems to have had this specific problem with postgresql on the HM forums.

Oh, related troubleshooting step that might help others. I had an earlier problem of *.vbs files being associated with vim instead of Windows Scripting Host when trying to install another program. So if youre getting Visual C++ errors even though you've got Visual C++ 2005/2008/2010 redistributables installed, try registering vbscript.dll:

- regsvr32 %systemroot%\system32\vbscript.dll

giovedì 24 gennaio 2013

Installazione hmailserver

Installation and configuration of local Mail server for Windows (hMail Server)

Featured Image
This is not exactly Magento related post, but it might be useful when you are setting up a dev environment on your local machine. There are many good and free mail servers out there which are relatively easy to install on your Windows machine, but the problems may occur when you try to configure all the bits and pieces of your system so you can actually use your local mail server for something other than producing system errors :) .
When I started working with PHP a long time ago, I was (naturally) looking for a mail server that could be used on my local machine. For some reason that is now long forgotten, I have decided to use hMail Server (freeware). Since it never failed me, it stayed in my standard set of must-have tools. In this post I’ll try to present a step-by-step manual on how to install and configure your system to use hMail Server.
Although this post might be a bit lengthy, please, don’t be scared :) . These are all simple steps and if you have any experience as a Windows user, you should be able to skip reading the most of them.
System properties (listed just as a reference)
  • Windows 7 Professional with the latest updates
  • MySQL 5.0.51b
  • Apache 2.2.17
Part 1 – Installation and Database configuration
  • Download hMail Server from their download page. My suggestion is to get the latest production release as it is the most stable one;
  •  Start the installer and pick “Full installation”. That should include Administrative tools which are very useful;
  • When asked, set MySQL as your mail database. You don’t need to create the database manually, installer will do that for you;
  • When you complete the installation wizard, database configuration wizard will appear where you should pick “Create new mail database” option;
  • Copy libmysql.dll to /hMailServer/bin directory;
  • Enter the MySQL server and user info.  You can use localhost as server name and whatever port you used for MySQL (default is 3306);
  • Pick the database service from the dropdown so that hMail server can hook to it. It’s usually listed as “MySQL” but  can be listed as “WAMP Mysql” (or whatever name you used) if you have WAMP installed;
  • Database configuration should be completed now and you can proceed to run the hMail Server Administration tool.
Part 2 – Configuring Windows DNS, port and firewall settings
  • The first thing you need to do is add a couple of entries to the Windows’ hosts file. Click on the Windows Start button and search for Notepad. Right click Notepad.exe and choose “Run as Administrator”. This will ensure that you will be able to save the “hosts” file once you’ve finished adding the changes, since the file is protected by the operating system by default;
  • Open the hosts file in Notepad. It’s located in Windows\System32\drivers\etc\ folder;
  • add the following at the end of the file (you can put anything instead of “localserver”):
1
2
3
4
127.0.0.1   mail.localserver.com
127.0.0.1   localserver.com
127.0.0.1   smtp.mail.localserver.com
127.0.0.1   pop3.mail.localserver.com
  • Open “Windows Firewall” form Control Panel or by searching for it in the Start menu;
  • Go to “Inbound rules” in the left bar and create a new rule for a Port. Type the port numbers for SMTP, POP3 and optionally IMAP protocols in TCP > Selected local ports field. You don’t need to create 3 rules for each port, because you can add all three of them with a comma separator (for example: 25, 110, 143);
  • Enter the name of the rule. Something like “hMail open ports” should do;
  • If you have any custom firewall installed, either stand-alone or as part of your AV software, you might want to look at your software’s documentation and see how to open ports. The ports you need to open are 25, 110 and optionally 143 if you plan to use IMAP.
Part 3 – Configuring hMail server
  • Create a new Domain in the hMail Administrator and put “mail.localserver.com” in the Domain field;
  • Create one administrator mail account by going to “Domains > mail.localserver.com > Accounts > Add” and choosing “Server” in the “Administration level” field. We will use “master@mail.localserver.com” as an example;
  • Go to the “Delivery of e-mail” tab in the “Settings > Protocols > SMTP” and enter  ”mail.localserver.com” in the “Local Host Name” field;
  • Go to “Settings > Advanced > TCP/IP Ports” and configure each of the sub-entries to use 127.0.0.1 as IP address.
That’s it! Your local mail server is now up and running. The only thing you need to do now is to connect your newly created local mail address to some e-mail application. I will post here a quick how-to tips for Thunderbird.
Configuring Thunderbird mail account
  • Go to “Tools > Account settings” in the Thunderbird main menu and create a new account (“Account actions” button, then “Add new account” option);
  • Use “master@mail.localserver.com” e-mail address (the one you have created in the hMail Administration) and set “Outgoing server” to “smtp.mail.localserver.com”;
  • Go to “Server settings” in your newly created mail account branch and use “pop3.mail.localserver.com” as “Server name”. “User name” field on this page should be the full name of your e-mail address, so, it would be “master@mail.localserver.com”
You are now ready to use your local e-mail address for your local Magento installation. If you run into any trouble, you can always use the Diagnostics tool from the Utilities menu  or check for error messages in the Status window of the hMail Administrator. I will also suggest you to explore the Administrator application and set up one of the many useful logging and debugging parameters as well as playing with the options for mail accounts. Of course, you should not forget to take a look at the security options too.