Difference between revisions of "Postgresql"

From SME Server
Jump to navigationJump to search
m (ad link to software collection for SME Server 9)
 
(23 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Note box|For SME Server 9.x, we advise you to use [http://wiki.contribs.org/Software_collections Software Collections]}}
+
{{Languages}}
 +
<!-- here we define the contrib name variable -->
 +
<!-- we get the page title, remove suffix for translated version; if needed you can define there with the value you want-->
 +
{{#vardefine:contribname| {{lc: {{#titleparts:  {{BASEPAGENAME}} |1}} }} }}
 +
{{#vardefine:smecontribname| smeserver-{{lc: {{#titleparts:  {{BASEPAGENAME}} |1}} }} }}
 +
<!-- we define the language -->
 +
{{#vardefine:lang| {{lc:  {{#titleparts:    {{PAGENAME}} | | -1}}  }} |en }}
 +
{{Infobox contribs
 +
|name={{#var:contribname}}
 +
|image=Postgresql.png
 +
|description_image= {{#var:contribname}} logo
 +
|maintainer=
 +
|licence= AGPLv3
 +
|url= https://www.postgresql.org/
 +
|category= database
 +
|tags=database,db,pgsql
 +
}}
  
== How to install Postgres 8 ==
+
===Version===
 +
{{#smeversion:smeserver-postgresql}}
  
{{Note box|This howto is created with information extracted from forums. Proceed at your own risk.}}
+
===Install Postgresql 13===
  
 +
yum install smeserver-extrarepositories-pgsql -y
 +
yum --enablerepo=smecontribs,pgsql13 install smeserver-postgresql
  
{{Warning box|The command below will install '''postgres''' and update '''postgres-libs'''. For dependency resolution it will also install '''tcl''' and '''mx''' from the '''base''' repository.
 
If you see other packages, such as '''perl''' or '''php''', '''abort the installation'''. This might occur because you have installed '''perl-CGI-Session''' or '''perl-DBD-Pg'''. These two packages might be on your system because you have installed '''otrs''' or another aplication. You can check if they are still needed:
 
  
  rpm -q --whatrequires perl-CGI-Session perl-DBD-Pg
+
enable repo to allow further updates
 +
  db yum_repositories setprop pgsql13 status enabled
 +
signal-event yum-modify
  
If that answers no packages need ... you can safely remove these packages
+
=== Upgrade ===
 +
yum  update {{#var:smecontribname}} --enablerepo=smecontribs
  
  yum remove perl-CGI-Session perl-DBD-Pg}}
+
=== Uninstall ===
 +
  yum remove {{#var:smecontribname}} {{#var:contribname}}*
  
Enable centosplus repository and install postgres (at the time of writing this is version 8.1.9)
+
=== Manually restore db ===
 +
after you upgraded you server or migrate, here how to restore db
  
yum --enablerepo=centosplus install postgresql postgresql-contrib postgresql-devel postgresql-docs postgresql-pl postgresql-python postgresql-test
+
using psql<syntaxhighlight lang="bash">
After install, ignore the post-upgrade and restart message
+
exec chpst -u postgres /usr/pgsql-13/bin/psql < /home/e-smith/db/pgsql/pgsql.dump
 +
</syntaxhighlight>using pg_restore
  
===Start postgres===
+
<syntaxhighlight lang="bash">
 +
exec chpst -u postgres /usr/pgsql-13/bin/pg_restore < /home/e-smith/db/pgsql/pgsql.dump
 +
</syntaxhighlight>
  
/etc/init.d/postgresql start
+
=== Bugs ===
 +
Please raise bugs under the SME-Contribs section in [http://bugs.contribs.org/enter_bug.cgi bugzilla]
 +
and select the {{#var:smecontribname}} component or use {{BugzillaFileBug|product=SME%20Contribs|component={{#var:smecontribname}}|title=this link}}
  
Then make the necessary custom templates:
+
Below is an overview of the current issues for this contrib:{{#bugzilla:columns=id,product,version,status,summary|sort=id|order=desc|component={{#var:smecontribname}} |noresultsmessage=No open bugs found.}}
  
mkdir -p /etc/e-smith/templates/var/lib/pgsql/data
+
===Changelog===
mkdir -p /etc/e-smith/templates-custom/var/lib/pgsql/data
+
Only released version in smecontrib are listed here.
cp /var/lib/pgsql/data/postgresql.conf /etc/e-smith/templates/var/lib/pgsql/data
 
cp /var/lib/pgsql/data/pg_hba.conf /etc/e-smith/templates/var/lib/pgsql/data
 
cp /var/lib/pgsql/data/postgresql.conf /etc/e-smith/templates-custom/var/lib/pgsql/data
 
cp /var/lib/pgsql/data/pg_hba.conf /etc/e-smith/templates-custom/var/lib/pgsql/data
 
  
Now login as postgres user:
+
{{#smechangelog: {{#var:smecontribname}} }}
  
su postgres
 
  
Then access to superuser database, set a password and exit.
+
===References===
 
+
  <ol><li>[http://forums.contribs.org/index.php?topic=38250.msg173298#msg173298 RE: How do I install postgreSQL 8+] by hedererjs</li><li>
psql -U postgres -d template1
 
alter user postgres with encrypted password 'add_your_pass_here';
 
\q
 
exit
 
 
 
Edit the file '''/etc/e-smith/templates-custom/var/lib/pgsql/data/postgresql.conf''' remove # and change the following settings:
 
 
 
superuser_reserved_connections=2
 
ssl = on
 
password_encryption = on
 
listen_addresses = 'localhost'
 
 
 
Then copy your server SSL keys:
 
 
 
cd /var/lib/pgsql/data
 
cp /etc/httpd/conf/ssl.crt/server.crt .
 
cp /etc/httpd/conf/ssl.key/server.key .
 
chown postgres:postgres server.*
 
 
 
Edit the file '''/etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf''' and change the following settings:
 
 
 
local    all  all                    md5
 
host    all  all    127.0.0.1/32    md5
 
host    all  all    ::1/128        md5
 
 
 
and add at the end:
 
 
 
host    all    all    0.0.0.0 255.255.255.255  reject
 
 
 
 
'''Be sure to add an extra white line at the end.That why you got an extra line on above box!'''
 
 
 
Expand template:
 
 
 
expand-template /var/lib/pgsql/data/pg_hba.conf
 
expand-template /var/lib/pgsql/data/postgresql.conf
 
 
 
Restart with new settings:
 
 
 
/etc/init.d/postgresql stop
 
/etc/init.d/postgresql start
 
 
 
and add the symlinks to start automatically:
 
 
 
ln -s /etc/init.d/postgresql /etc/rc.d/rc7.d/S56postgresql
 
ln -s /etc/init.d/postgresql /etc/rc.d/rc6.d/K03postgresql
 
 
 
To ensure everything is all right:
 
 
 
signal-event post-upgrade
 
signal-event reboot
 
 
 
===Testing your environment===
 
To test if you have set postgres password correctly:
 
 
 
su postgres
 
psql -U postgres -d template1
 
 
 
and enter the password you have set above. If all is correct, you should enter the postgres console. Then exit:
 
 
 
  \q
 
 
 
and exit from postgres user:
 
 
 
exit
 
 
 
 
 
References: <ol></li><li>[http://forums.contribs.org/index.php?topic=38250.msg173298#msg173298 RE: How do I install postgreSQL 8+] by hedererjs</li><li>
 
 
[http://www.issociate.de/board/post/272215/Fwd:_resetting_superuser_password.html Resetting the postgres superuser password]</li></ol>
 
[http://www.issociate.de/board/post/272215/Fwd:_resetting_superuser_password.html Resetting the postgres superuser password]</li></ol>
 
==How to Remove==
 
rpm -e postgresql.i386 postgresql-contrib postgresql-devel postgresql-docs postgresql-pl postgresql-test  postgresql-server postgresqlclient7  postgresql-python
 
 
 
 
----
 
----
[[Category:Howto]]
+
[[Category:Contrib]]
 
[[Category:Administration]]
 
[[Category:Administration]]

Latest revision as of 17:42, 12 December 2022





postgresql
Postgresql.png
postgresql logo
Urlhttps://www.postgresql.org/
LicenceAGPLv3
Category

database

Tags databasedbpgsql


Version

Contrib 10:
smeserver-postgresql
The latest version of smeserver-postgresql is available in the SME repository, click on the version number(s) for more information.


Install Postgresql 13

yum install smeserver-extrarepositories-pgsql -y
yum --enablerepo=smecontribs,pgsql13 install smeserver-postgresql 


enable repo to allow further updates

db yum_repositories setprop pgsql13 status enabled
signal-event yum-modify

Upgrade

yum  update smeserver-postgresql --enablerepo=smecontribs

Uninstall

yum remove smeserver-postgresql  postgresql*

Manually restore db

after you upgraded you server or migrate, here how to restore db

using psql

exec chpst -u postgres /usr/pgsql-13/bin/psql < /home/e-smith/db/pgsql/pgsql.dump

using pg_restore

exec chpst -u postgres /usr/pgsql-13/bin/pg_restore < /home/e-smith/db/pgsql/pgsql.dump

Bugs

Please raise bugs under the SME-Contribs section in bugzilla and select the smeserver-postgresql component or use this link


Below is an overview of the current issues for this contrib:

IDProductVersionStatusSummary (3 tasks)
12366SME Contribs10.0UNCONFIRMEDdatestyle on en_US needs to be mdy, not dmy.
12355SME Contribs10.0UNCONFIRMEDShutdown errors detected and logged during shutdown of Postgres 13.
12083SME Contribs10.0CONFIRMEDNFR rewrite contrib to be able to run multiple pgsql version at once

Changelog

Only released version in smecontrib are listed here.

smeserver-postgresql Changelog: SME 10 (smecontribs)
2022/12/26 Jean-Philippe Pialasse 0.2.0-4.sme
- fix failing pgsql.init service preventing restore [SME: 12290]
2022/12/12 Jean-Philippe Pialasse 0.2.0-3.sme
- fix pre-backup event fails error 256 [SME: 12264]
2022/12/02 Jean-Philippe Pialasse 0.2.0-2.sme
- fix preset OUT missing
2021/11/17 Michel Begue 0.2.0-1
- First import to Sme 10 (postgresql13)

2007/09/11 Charlie Brady 0.0.1-24
- Add support for localhost/private/public access settings to

determine which network interfaces to bind to.


References

  1. RE: How do I install postgreSQL 8+ by hedererjs
  2. Resetting the postgres superuser password