Thread: initdb fails
This is running on a Solaris 8 machine. I installed V 7.4.7 to use with OpenACS. lcd[34]% /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data ... selecting default max_connections... 10 selecting default shared_buffers... 50 creating configuration files... ok creating template1 database in /usr/local/pgsql/data/base/1... FATAL: could not create shared memory segment: Invalid argument DETAIL: Failed system call was shmget(key=1, size=1081344, 03600). ... lcd[36]% sysdef -i | grep SHMMAX 1048576 max shared memory segment size (SHMMAX) ----------- So the shared memory request is greater than the SHMMAX in the kernel. If I just wanted to use a smaller number of shared_buffers (24), I tried editing /usr/local/pgsql/data/pgsql.conf. But initdb -D /usr/local/pgsql/data finds that the directory is not empty and will not create the databases. I have also tried setenv PGOPTIONS="shared_buffers = 24" and tried initdb, but initdb uses the default number. Could you tell me how to set shared_buffers from the default so that a smaller shared memory segment will be requested? If you could also tell me how to set the max_connections to a value different from the default, that would be great. Any advice appreciated. Anne Hammond, University of Colorado at Boulder
Hi, The following link will help you http://www.powerpostgresql.com/Downloads/annotated_conf_80.html On 12/7/05, Anne M. Hammond <hammond@solarz.colorado.edu> wrote: > This is running on a Solaris 8 machine. > > I installed V 7.4.7 to use with OpenACS. > > lcd[34]% /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data > ... > selecting default max_connections... 10 > selecting default shared_buffers... 50 > creating configuration files... ok > creating template1 database in /usr/local/pgsql/data/base/1... FATAL: > could not create shared memory segment: Invalid argument > DETAIL: Failed system call was shmget(key=1, size=1081344, 03600). > ... > > lcd[36]% sysdef -i | grep SHMMAX > 1048576 max shared memory segment size (SHMMAX) > > ----------- > So the shared memory request is greater than the SHMMAX in > the kernel. If I just wanted to use a smaller number of shared_buffers > (24), I tried editing /usr/local/pgsql/data/pgsql.conf. > > But initdb -D /usr/local/pgsql/data > finds that the directory is not empty and will not create the databases. > I have also tried > setenv PGOPTIONS="shared_buffers = 24" > and tried initdb, but initdb uses the default number. > > Could you tell me how to set shared_buffers from the default so > that a smaller shared memory segment will be requested? > > If you could also tell me how to set the max_connections to a value > different from the default, that would be great. > > Any advice appreciated. > > Anne Hammond, University of Colorado at Boulder > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > -- Regards Pandu
"Anne M. Hammond" <hammond@lcd.Colorado.EDU> writes: > So the shared memory request is greater than the SHMMAX in > the kernel. If I just wanted to use a smaller number of shared_buffers > (24), I tried editing /usr/local/pgsql/data/pgsql.conf. You're going to have to increase SHMMAX anyway, so you might as well just do that, rather than trying to outflank initdb. PG's performance with any less than several hundred shared buffers is just too awful to consider using. I haven't done this on Solaris personally, but according to our docs http://www.postgresql.org/docs/7.4/static/kernel-resources.html it's just a matter of editing /etc/system and rebooting. regards, tom lane
Summary: I used a workstation where /usr/local/pgsql was mounted, and which had a larger SHMMAX. initdb worked there. Then I returned to the server, edited /usr/local/pgsql/data/pgsql.conf for smaller sizes than the default shared_buffers and max_connections. Thanks to Pandu and Tom Lane for the following links which describe in detail the various configuration options: http://www.powerpostgresql.com/Downloads/annotated_conf_80.html http://www.postgresql.org/docs/7.4/static/kernel-resources.html However, when the server SHMMAX is smaller than the size required by the defaults for shared_buffers and max_connections, I have not been able to find a way (other than the above), to tell initdb to use a nondefault values. If this is possible, it should be documented. The conf file is in the data directory--initdb will not init if there are existing files in that directory. I am doing this for a class where there initially will be only one connection; and it's not possible to reboot the server at this time. So I realize my solution is a suboptimal configuration, but would like to get it up and working. If there is another way to do this, such as command line options or environmental values for initdb, I haven't found it. Thanks for the help and suggestions. Anne On 12/7/05, Anne M. Hammond <hammond@solarz.colorado.edu> wrote: > This is running on a Solaris 8 machine. > > I installed V 7.4.7 to use with OpenACS. > > lcd[34]% /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data > ... > selecting default max_connections... 10 > selecting default shared_buffers... 50 > creating configuration files... ok > creating template1 database in /usr/local/pgsql/data/base/1... FATAL: > could not create shared memory segment: Invalid argument > DETAIL: Failed system call was shmget(key=1, size=1081344, 03600). > ... > > lcd[36]% sysdef -i | grep SHMMAX > 1048576 max shared memory segment size (SHMMAX) > > ----------- > So the shared memory request is greater than the SHMMAX in > the kernel. If I just wanted to use a smaller number of shared_buffers > (24), I tried editing /usr/local/pgsql/data/pgsql.conf. > > But initdb -D /usr/local/pgsql/data > finds that the directory is not empty and will not create the databases. > I have also tried > setenv PGOPTIONS="shared_buffers = 24" > and tried initdb, but initdb uses the default number. > > Could you tell me how to set shared_buffers from the default so > that a smaller shared memory segment will be requested? > > If you could also tell me how to set the max_connections to a value > different from the default, that would be great. > > Any advice appreciated. > > Anne Hammond, University of Colorado at Boulder >
"Anne M. Hammond" <hammond@lcd.Colorado.EDU> writes: > However, when the server SHMMAX is smaller than the size required > by the defaults for shared_buffers and max_connections, I have > not been able to find a way (other than the above), to tell > initdb to use a nondefault values. Well, initdb is just a shell script in 7.4, so it's not that hard to edit it to try even-smaller values for max_connections and/or shared_buffers. I stand by my comment that performance is going to suck though, and you may even run into "out of buffers" failures. regards, tom lane
On Wed, 2005-12-07 at 11:04 -0700, Anne M. Hammond wrote: > If there is another way to do this, such as command line options > or environmental values for initdb, I haven't found it. There's no need to run initdb on the smaller machine. Run the initdb on the larger machine, then *while postmaster is shutdown* copy the entire data directory across to the smaller machine. From there you can edit the postgresql.conf and startup. Best Regards, Simon Riggs