User Tools

Site Tools


postgresqlnotes

PostgreSQL Notes

<toc><ul><li><link topicref=“2”>Compile from source</link></li><li><link topicref=“3”>Client-only installation:</link></li><li><link topicref=“4”>Create user and database</link></li><li><link topicref=“5”>Create a certificate and install</link></li><li><link topicref=“6”>Values to change in ~postgres/postgresql.conf</link></li><li><link topicref=“7”>Set table owners:</link></li></ul></toc>

Compile from source

./configure --with-perl --with-openssl
make -j6
su nobody -c &quot;make check&quot;
make install

/usr/sbin/useradd -u 400 -d /usr/local/pgsql/data -c &quot;PostgreSQL&quot; -m -k /dev/null postgres

su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

<list><ul><li>Edit <tt>~postgres/postgresql.conf</tt>, then add to startup</li></ul></list>

echo &quot;Starting pgSQL&quot;
su - postgres -c &quot;/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start &gt;&gt;logfile 2&gt;&amp;1&quot;

<list><ul><li><tt>crontab -e -u postgres</tt></li></ul></list>

0 12 * * * /usr/local/pgsql/bin/vacuumdb --all --analyze &gt; /dev/null
0 0 * * * LOGFILE=/usr/local/pgsql/data/serverlog; bzip2 -c $LOGFILE &gt; $LOGFILE.old.bz2 &amp;&amp; cat /dev/null &gt; $LOGFILE

Client-only installation:

./configure --with-perl --with-openssl

make -C src/bin install
make -C src/include install
make -C src/interfaces install
make -C doc install

Create user and database

../bin/createuser -D -A -P -E -U postgres username
../bin/createdb -U postgres -O username dbname

Create a certificate and install

<list><ul><li><link idref=“15”></link></li><li><tt>~postgres/server.key</tt> and <tt>~postgres/server.crt</tt></li></ul></list>

Values to change in ~postgres/postgresql.conf

tcpip_socket = true
virtual_host = 'localhost'
shared_buffers = 48000       # (Number of buffers * 8k each)  48000 * 8k = 384 MB ram for postgres
sort_mem = 32768             # (kb)
ssl = true

Set table owners:

UPDATE pg_database SET datdba = (SELECT usesysid FROM pg_user WHERE usename='newownername') WHERE datname='dbname';
postgresqlnotes.txt · Last modified: 2020/02/13 22:55 (external edit)

free spam filter