cancel
Showing results for 
Search instead for 
Did you mean: 

Question installing PostgreSQL in an Apple Mac

Adventurer

Question installing PostgreSQL in an Apple Mac

macOS 10.13.2 High Sierra

PostgreSQL 10.1.1

 

I had installed PostgreSQL a few days before but not really used it yet. I've just this moment upgraded to Apple Mac High Sierra 10.13.2 and I noticed a couple of things. Firstly my Apple Mac booted up with an extra PostgreSQL user, that I haven't investigated yet. Also when I started Firefox, it refreshed a download page with the PostgreSQL installer, and this time (!) I thought I might read the README. It talks about Shared Memory settings and the need to edit a file `/etc/sysctl.conf`. I do not have such a file. I also ran `sysctl -a` whihc gave me a whole host of settings. It quotes a number of settings of which the equivalent on my machine are:

 

 

kern.sysv.shmmax: 4194304
kern.sysv.shmall: 1024
kern.sysv.shmmin: 1
kern.sysv.shmmni: 32
kern.sysv.shmseg: 8
kern.maxprocperuid: 2837
kern.maxproc: 4256


My machine is an ancient Apple Mac Pro which has had the firmware upgraded from 4.1 to 5.1 thus enabling me to upgrade the OS to the latest High Sierra without any hassles. My machine has a generous 32 Gb of RAM on board so  presumably will be able to cope with any demands that PostgreSQL can throw at it.

 

The question is do I need to change any settings to do with memory before I complete the reinstallation?

and do I need to worry about the second user account called PostgreSQL on my machine?

 

Thanks in advance,

Carl Caulkett

 

 

1 REPLY
Moderator

Re: Question installing PostgreSQL in an Apple Mac

Hi Carl,

Hope you are doing good !
Incase if systctl.conf file is not exist then in that case you need to create the file named /etc/sysctl.conf.

 

The recommended method for configuring shared memory in macOS is to create a file named /etc/sysctl.conf, containing variable assignments such as:

kern.sysv.shmmax=4194304

kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.sysv.shmall=1024

You can check below link for more information about setting for MacOs,
https://www.postgresql.org/docs/10/static/kernel-resources.html

Also regarding your questions,

>>> The question is do I need to change any settings to do with memory before I complete the reinstallation?

A fresh postgres installation on a development/testing machine will probably be fine for most apps with default settings. However, when playing with big data, doing heavy aggregations as we do at adjust.io (even in development) can produce completely different performance than on a production server.

Postgres comes with rather conservative/minimal defaults settings on your machine. If you want to get the most out of your local postgres on MacOS you need to tune your postgresql.conf, typically found at,
/usr/local/var/postgres/postgresql.conf           

There are a lot of settings but here are a few of the most important:
maintenance_work_mem
effective_cache_size
work_mem
shared_buffers
wal_buffers
max_connections

 

Please check below link for more information,

https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

>>> and do I need to worry about the second user account called PostgreSQL on my machine?

PostgreSQL will create the default "Postgres" service account. As with any other server daemon that is accessible to the outside world, it is advisable to run PostgreSQL under a separate user account. This user account should only own the data that is managed by the server, and should not be shared with other daemons. (For example, using the user nobody is a bad idea.) It is not advisable to install executables owned by this user because compromised systems could then modify their own binaries.