Chris Jones
Chris Jones

Reputation: 672

How does one change Postgres' service name when installing on Centos

I am installing Postgres on CentOS 7 boxes, and that part itself is fine. The issue that someone brought up is that they would like for my install script to try and not depend on the service name being postgresql-10, and instead just use postgres or postgresql. Either one would be fine. Well I noticed that there is a flag --servicename that can be used, but I am unsure where to use it in the process. I have tried a few times but it doesn't seem to work.

Note that this is how I am installing postgres

yum -y install $LINK
yum -y install postgresql10
yum -y install postgresql10-server
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10

the $LINK up there is just the path to pull from the Postgres website. Again, the ideal situation would be for me to specify the service name such that I can standardize that and limit script changes when Postgres versions change.

Note that I found out about the --servicename flag in this, link but I am not completely sure how to apply that to the installation above. It does appear that the link is more for installing on windows, but I would assume we could do the same thing in a Linux installation. Any suggestions here would be welcome.

Upvotes: 0

Views: 820

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246568

The link that you found is about EnterpriseDB's installer for Windows, and the service mentioned is a Windows service. That won't help you on CentOS.

The name of the systemd service file is hard-wired into the RPM, but there is nothing that prevents you from creating your own service file in /etc/systemd/system and using that one instead. Then you can choose whatever name you prefer. You can just copy the service file from the RPM as a starting point.

Renaming the file or creating one in /usr/systemd/system is not a good idea, because that will mess with RPMs.

postgresql-10 is a good name for the service, however. If you choose postgres or something else that doesn't contain the version, what will you do once you want to install v11?

To answer your question: There is no way to configure the name of the service when installing it via RPM.

Upvotes: 1

Related Questions