Обсуждение: troubles with initdb

Поиск
Список
Период
Сортировка

troubles with initdb

От
jlhgis
Дата:
hi all

I am trying to create a second instance of PostgreSQL (8.3) on a
Windows 2003 server with initdb, but am running into an error message
I can't seem to resolve.

Here's what I've done so far:

Created a new local account 'postgres_test' for the 2nd instance to run under.

I stopped the first instance of PostgreSQL and made a copy of the
‘postgresql’ software installation. Copied
"D:\Database_Apps\PostgreSQL_Dev" to
"D:\Database_Apps\PostgreSQL_Test". Deleted the data directory.

Gave the 'postgres_test' account full control of the
D:\Database_Apps\PostgreSQL_Test\directory tree.

Create a new data directory for the 2nd instance of Postgres, located
at "E:\SPDB_Files\PostgreSQL_Test\8.3\data" and gave the
'postgres_test' account full control of everything under
\PostgreSQL_Test

Trying to to run initdb (from D:\Database_Apps\PostgreSQL_Test\8.3\bin
) at the command line with these parameters:


initdb –A md5  –D E:\Spatial_DB_Files\PostgreSQL_Test\8.3\data  -E
UTF8  –-locale=C  -X F:\pgsql_test_logs  –U pgsql_test_su  –W

The error message I get is:

initdb: too many command-line arguments (first is "-D")

I've tried the parameters encased in quotes too, but it makes no
difference. Also tried adding the -d and -n  switches to see if they'd
give me any more detailed error messages, or other clues, but the
result was the same.

Based on the information in
http://www.postgresql.org/docs/8.3/static/app-initdb.html, it looks to
me like I have the correct command line parameters, but something is
still not right. Can someone with a fresh pair of eyes on this suggest
what the problem might be?

Thanks,

Julia

Re: troubles with initdb

От
Raymond O'Donnell
Дата:
On 31/05/2011 16:16, jlhgis wrote:
> Create a new data directory for the 2nd instance of Postgres, located
> at "E:\SPDB_Files\PostgreSQL_Test\8.3\data" and gave the
> 'postgres_test' account full control of everything under
> \PostgreSQL_Test

[...]

> initdb –A md5  –D E:\Spatial_DB_Files\PostgreSQL_Test\8.3\data  -E
> UTF8  –-locale=C  -X F:\pgsql_test_logs  –U pgsql_test_su  –W


The data directory in the initdb command is different from the one you
mention above - is that the case or were you just abbreviating?

Also, looking at the way the command is documented, I wonder if -D needs
to be the last option? - Only a guess.

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: troubles with initdb

От
Craig Ringer
Дата:
On 05/31/2011 11:16 PM, jlhgis wrote:
> I stopped the first instance of PostgreSQL and made a copy of the
> ‘postgresql’ software installation. Copied
> "D:\Database_Apps\PostgreSQL_Dev" to
> "D:\Database_Apps\PostgreSQL_Test".

You don't need to do that. It's fine to use the same binaries and just
have multiple data directories.

It's also unnecessary to create a second user account for the second
instance, though you can if you'd prefer to isolate them. Having
multiple instances running under the 'postgres' account is fine.

I often run test instances under my own local user account rather than
making a user account at all, just because it's easier.

When you run initdb, are you invoking it via runas.exe as postgres_test
? Or logging in as the postgres_test user?

Your command line looks OK to me, so I'm not sure what's going on. With
adjustments for paths it runs fine on my (Linux) system. I'll have a
play on my Windows desktop in a bit.

--
Craig Ringer

Re: troubles with initdb

От
jlhgis
Дата:
>>The data directory in the initdb command is different
>>from the one you mention above - is that the case or
>>were you just abbreviating?

Yes, I had intended them to be different. My D drive is a small
internal hard drive where I install all my application software, but I
wanted to put the database files on the E drive and the logs on the F
drive, both of which are on the SAN and have plenty of disk space
available.


>> Also, looking at the way the command is documented,
>>I wonder if -D needs to be the last option? - Only a guess.

I tried rearranging the order of the command line arguments several
different ways. Doesn't  seem to matter. Whichever is the second one
gets flagged as the error. I got rid of the -A argument, and it just
shifted the error down to the next parameter.



>> You don't need to do that. It's fine to use the same
>> binaries and just have multiple data directories.
>> It's also unnecessary to create a second user account
>> for the second instance, though you can if you'd prefer
>> to isolate them.

I was hoping to completely isolate them from each other, including the
binaries. Some day we'll be able to upgrade the database to 9, but
we'll want to do that only on the dev instance at first - keeping the
test instance at 8.3 until we are sure we've got everything working OK
in 9. The IT folks are very stingy with dev & test servers, so I am
forced to run both instances on the same virtual server.

> When you run initdb, are you invoking it via runas.exe as
> postgres_test ? Or logging in as the postgres_test user?

I am doing this logged in as the 'postgres_test' account. I tried to
run it logged in as myself using "runas", but the command prompt
window disappears as soon as I enter the password for the
'postgres_test' account. I'm running this via a terminal server
window, in console mode. The server is in a datacenter across town.


This is driving me nuts.  Does anyone know if there are any other
methods of creating a 2nd instance of Postgres (on Windows) besides
running initdb?

Re: troubles with initdb

От
Craig Ringer
Дата:
On 31/05/2011 11:16 PM, jlhgis wrote:

> initdb –A md5  –D E:\Spatial_DB_Files\PostgreSQL_Test\8.3\data  -E
> UTF8  –-locale=C  -X F:\pgsql_test_logs  –U pgsql_test_su  –W

Aaaah... your typeface just gave me a clue. It's impossible for me to
tell if the issue above is just your mail client being "helpful" or if
it was present in the original command line, but look at the hyphens
before "locale=C".

I bet you wrote your original command line in a word processor like MS
Word, or copied and pasted it via there at some point. Maybe even
Outlook does it. Either way, that program was "helping" you. It's
converted your hyphens into proper long dashes. See how the first one is
a long dash (en dash, unicode 0x2013,
http://www.fileformat.info/info/unicode/char/2013/index.htm) and the
second is a minus sign (unicode 0x002d,
http://www.fileformat.info/info/unicode/char/002d/index.htm) ?

Unfortunately, the command line processor has no idea what unicode
0x2013 means, so it doesn't know how to process the arguments and fails.

The reason it fails on the SECOND argument is that initdb accepts the
datadir as the first argument, so it thinks you're specifying the
datadir "–A" then wonders what the rest of those non-option arguments
are for.

If I hand-write your command line then it works on my Windows test
machine, adjusted for paths. If I copy and paste it, it fails because of
the converted dashes.

--
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/

Re: troubles with initdb

От
jlhgis
Дата:
Great eyes!

It was copied & pasted out of some running notes & screenshots of the
process I was keeping in an OO file. You're a lot more "helpful" than
it was :)  Thanks so much for taking the time to look at this.

Now, on to the next hurdle - getting pg_ctl to run as an automated service...


> Aaaah... your typeface just gave me a clue.
> It's impossible for me to tell if the issue above
> is just your mail client being "helpful" or if it was
> present in the original command line, but look at
> the hyphens before "locale=C".
>
> I bet you wrote your original command line in a word
> processor like MS Word, or copied and pasted it via
> there at some point. Maybe even Outlook does it.
> Either way, that program was "helping" you.