2009-07-14

PostgreSQL one click installer fails - SOLVED

I finally got around to upgrading my PostgreSQL 8.0 to latest, which is PostgreSQL 8.4 as of writing. I had used a fink (Debian APT version) of PostgreSQL before, but now I wanted it upgraded.

I found that EnterpriseDB - the commercial branch of PostgreSQL has got a "One Click Installer". Oh JOLLY, I merrily thought. I figured that I'll push it in and then I'll figure out how I'll deprecate my old install and transfer the DBs over (haven't done that as of writing).

Not totally surprising I ran into problems. The error message I got in the installer was:
Failed to initialise the database cluster with initdb

Hmmmm.... That's quite serious. I headed over to the support forum. Not long before I found the thread named "Error Installing Postgresql on OSx (Macbook Pro latest) using one click installation". It seems that the problem is that the previously installed postgres user is an "anonymous" one. I.e it doesn't have a shell nor a home directory. Until this oversight is fixed in the PostgreSQL/8.4/installer/server/createuser.sh script, you can do the following kung-fu-grips.
First, check that your postgres user really is screwed (command ran as root, if you're not using root, prefix the command with sudo as usual). Run this and see if you get something like this.
bash-3.2# dscl . read /users/postgres
AppleMetaNodeLocation: /Local/Default
Change: 0
Expire: 0
GeneratedUID: 00818549-E7C6-60A498CE64B5
NFSHomeDirectory: /dev/null
Password: *
PrimaryGroupID: 252
RealName:
PostgreSQL Database Server
RecordName: postgres
RecordType: dsRecTypeNative:users
UniqueID: 252
UserShell: /dev/null

You notice that NFSHomeDirectory has the value of /dev/null and that UserShell has got the value of /dev/null too. Run these commands to fix it:
dscl . -create /Users/postgres NFSHomeDirectory /Library/PostgreSQL/8.4
dscl . -create /Users/postgres UserShell /bin/bash

Note that if you're using another version than 8.4 you'll have to change the path. If you re-run the first command it should now look like this:
bash-3.2# dscl . read /users/postgres
AppleMetaNodeLocation: /Local/Default
Change: 0
Expire: 0
GeneratedUID: 00818549-B53E-60A498CE64B5
NFSHomeDirectory: /Library/PostgreSQL/8.4
Password: *
PrimaryGroupID: 252
RealName:
PostgreSQL Database Server
RecordName: postgres
RecordType: dsRecTypeNative:users
UniqueID: 252
UserShell: /bin/bash

Note that both NFSHomeDirectory and UserShell has got "proper values". You can now log in (from root shell) to postgres user (su postgres). If your previous attempt didn't work, delete the /Library/PostgreSQL/8.4 directory (folder) and you can now install PostgreSQL 8.4 with the one click installer from EnterpriseDB.

Hope that's of any use to anybody out there.

Oh, and one more thing:
PostgreSQL > MySQL > *

2009-07-03

My iPhone iSSH set up

Since my Psion Revo I've had terminal (later SSH) applications on my phones, just so I can access any server I might need to from anywhere. It's a very comforting thing to have, knowing that if there's a problem you can fix it.
I'm happy to say that the iPhone experience is better than any other mobile SSH solution I've ever used. This is thanks to the iPhone's UI and Dean Beeler of Zingersoft and the iSSH application. I've not tried other SSH apps for the iPhone as I'm very happy with Dean's efforts. He's also very active on the Google Group for iSSH. He's also (slightly reluctantly) dishing out AdHoc releases when the approval process of the AppStore is slow. Excellent!
This post pertains to iSSH 3.1, and I know it will probably be short-lived as Dean has already submitted 3.5 to Apple AppStore as I type this. It also is only about how to set up your connections, I'm not very versed in the advanced use (yet?).
Let's get started.
I wanted easy connection to my servers, and my passwords are tedious things, so typing them, even on a normal keyboard, is no fun, let alone the iPhone's keyboard. iSSH has got the option to store the password, and I think that's a good idea, but I find it safer to use the RSA key functionality. The reason for this is quite simple; Should I lose my iPhone I can log onto the servers and delete the keys from anywhere. I can't blank the passwords remotely. To add a bit of protection onto this "blanket log in", I use the "Passcode Lock" feature. This is simply a 4 digit PIN (personal identification number). If you don't know the PIN, you're locked out of the app.
Short config is thus;
  • Passcode (PIN) lock
  • RSA key pair for login
  • Never log in as root (Super User)
Simple enough!
Here's how to do it.
  1. Turn on "Passcode Lock" - Go into "General Settings". Flick on the "Passcode Lock" switch.
  2. Generate your key, RSA key in my case, by clicking the "Generate" under "RSA Key Functions".
  3. Create a new connection by clicking "Add Configuration".
  4. Enter your details as you would with these notes.
  5. This is optional; Use "screen -DRRS iphone" in the Command setting. This starts a screen session automatically or reconnects to an existing one. This enables you to shut down your iSSH application without losing anything from the terminal. Thanks to a lot of guys on the Google Group, and Jared Earle in particular for his "SSH on the iPhone at last" post.
  6. Then enter your password in as usual.
  7. Click "Save" at the top of the screen. This step shouldn't be necessary, but I found the app giving some error messages once. I'm sure Dean will fix it.
  8. Go back into your newly created connection and then click "Transfer Public RSA Key". This will copy the public key into your ~/.ssh/authorized_keys file. If you don't have the file, you need to create it; mkdir ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R 700 ~/.ssh before you transfer the key.
  9. Once the key is successfully transferred, flick the "Use RSA Key" switch on. This switches from using your password to using the key.
  10. Click "Save" at the top of the screen.
  11. Test your new setting. You will be asked to confirm the host's certificate. (Note that you'll need to confirm the certificate every time you change the setting - I was almost getting annoyed with this until I figured it out).
What should happen when you connect is that you shouldn't have to enter a password, but you should be logged straight into the server and swished straight into a screen session.
Separately these steps aren't difficult, but figuring out the sequence took a bit of time for me, so hope this saves you a bit of time.
I've now got all my important connections on the phone. The useability of the iPhone iSSH application is just astonishing for such a small device. Screen swiping, pinch zoom, gestures, horizontal mode, etc, etc all make it surprisingly easy to control your server.