Thread: 9.5 CentOS 7 setting PGDATA for systemctl
Evening, morning, or afternoon, So I'm trying to go back to a stock rpm package (vs my full custom, builds). This is a learning curve, not only because it's all "whacked pathing (in my eyes:)) but rhel7 is a #$%$# with all the things they changed. Sooo I've got servers built and I've got the correct data path initialized and postgres can start the db " /usr/pgsql-9.5/bin/pg_ctl -D /pgsql/9.5/data -l logfile start" But obviously systemctl start postgresql-9.5.server loses it's head because it has no idea where my Data directory is and setting , PGDATA as a variable, doesn't seem to work. So how do I kick CentOS 7 in the teeth and make it change it's attitude regarding where I have put things? /var/lib/pgsql (really?) I don't want to do symlinks. I've got it installed and running, but postgres can't be the only place to start/stop the server. I need systemctl to handle these tasks as well. The init program is all kinds of weirdness. Any pointers, as I'm starting to lose sleep over this! :) Thanks Tory PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` and # this parsing technique fails for PGDATA pathnames containing spaces, # but there's not much I can do about it given systemctl's output format... PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" | sed 's/^Environment=//' | tr ' ' '\n' | sed -n 's/^PGDATA=//p' | tail -n 1` if [ x"$PGDATA" = x ]; then echo "failed to find PGDATA setting in ${SERVICE_NAME}.service" exit 1 fi
On 05/21/2016 10:27 PM, Tory M Blue wrote: > Evening, morning, or afternoon, > > So I'm trying to go back to a stock rpm package (vs my full custom, > builds). This is a learning curve, not only because it's all "whacked > pathing (in my eyes:)) but rhel7 is a #$%$# with all the things they > changed. So where did you get the 'stock' RPM's from, CentOS or the Postgres repos? > > Sooo > > I've got servers built and I've got the correct data path initialized > and postgres can start the db " /usr/pgsql-9.5/bin/pg_ctl -D > /pgsql/9.5/data -l logfile start" > > But obviously systemctl start postgresql-9.5.server loses it's head > because it has no idea where my Data directory is and setting , PGDATA > as a variable, doesn't seem to work. > > So how do I kick CentOS 7 in the teeth and make it change it's > attitude regarding where I have put things? /var/lib/pgsql (really?) > I don't want to do symlinks. > > I've got it installed and running, but postgres can't be the only > place to start/stop the server. I need systemctl to handle these tasks > as well. > > The init program is all kinds of weirdness. This would be the init program included with the RPM? Is it written for traditional init or systemd? > > Any pointers, as I'm starting to lose sleep over this! :) > > Thanks > Tory > > PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` > > and > > # this parsing technique fails for PGDATA pathnames containing spaces, > > # but there's not much I can do about it given systemctl's output format... > > PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" | > > sed 's/^Environment=//' | tr ' ' '\n' | > > sed -n 's/^PGDATA=//p' | tail -n 1` > > if [ x"$PGDATA" = x ]; then > > echo "failed to find PGDATA setting in ${SERVICE_NAME}.service" > > exit 1 > > fi > > -- Adrian Klaver adrian.klaver@aklaver.com
> On May 22, 2016, at 07:50, Adrian Klaver <adrian.klaver@aklaver.com> wrote: > >> On 05/21/2016 10:27 PM, Tory M Blue wrote: >> Evening, morning, or afternoon, >> >> So I'm trying to go back to a stock rpm package (vs my full custom, >> builds). This is a learning curve, not only because it's all "whacked >> pathing (in my eyes:)) but rhel7 is a #$%$# with all the things they >> changed. > > So where did you get the 'stock' RPM's from, CentOS or the Postgres repos? Postgres yum repos (I like this btw) > >> >> Sooo >> >> I've got servers built and I've got the correct data path initialized >> and postgres can start the db " /usr/pgsql-9.5/bin/pg_ctl -D >> /pgsql/9.5/data -l logfile start" >> >> But obviously systemctl start postgresql-9.5.server loses it's head >> because it has no idea where my Data directory is and setting , PGDATA >> as a variable, doesn't seem to work. >> >> So how do I kick CentOS 7 in the teeth and make it change it's >> attitude regarding where I have put things? /var/lib/pgsql (really?) >> I don't want to do symlinks. >> >> I've got it installed and running, but postgres can't be the only >> place to start/stop the server. I need systemctl to handle these tasks >> as well. >> >> The init program is all kinds of weirdness. > > This would be the init program included with the RPM? > > Is it written for traditional init or systemd? Systemd , systemctl . Thanks Tory > > >> >> Any pointers, as I'm starting to lose sleep over this! :) >> >> Thanks >> Tory >> >> PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` >> >> and >> >> # this parsing technique fails for PGDATA pathnames containing spaces, >> >> # but there's not much I can do about it given systemctl's output format... >> >> PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" | >> >> sed 's/^Environment=//' | tr ' ' '\n' | >> >> sed -n 's/^PGDATA=//p' | tail -n 1` >> >> if [ x"$PGDATA" = x ]; then >> >> echo "failed to find PGDATA setting in ${SERVICE_NAME}.service" >> >> exit 1 >> >> fi > > > -- > Adrian Klaver > adrian.klaver@aklaver.com
On 05/22/2016 09:06 AM, Tory M Blue wrote: > > > >> On May 22, 2016, at 07:50, Adrian Klaver <adrian.klaver@aklaver.com> wrote: >> >> >> So where did you get the 'stock' RPM's from, CentOS or the Postgres repos? > > Postgres yum repos (I like this btw) I do not use CentOS myself, so I will point you at this: http://people.planetpostgresql.org/devrim/index.php?/archives/80-Installing-and-configuring-PostgreSQL-9.3-and-9.4-on-RHEL-7.html >>> >>> The init program is all kinds of weirdness. >> >> This would be the init program included with the RPM? >> >> Is it written for traditional init or systemd? > > > Systemd , systemctl . > > Thanks > Tory > >> >> >>> -- Adrian Klaver adrian.klaver@aklaver.com
On Sun, May 22, 2016 at 9:10 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote: > On 05/22/2016 09:06 AM, Tory M Blue wrote: >> >> >> >> >>> On May 22, 2016, at 07:50, Adrian Klaver <adrian.klaver@aklaver.com> >>> wrote: >>> > >>> >>> So where did you get the 'stock' RPM's from, CentOS or the Postgres >>> repos? >> >> >> Postgres yum repos (I like this btw) > > > > I do not use CentOS myself, so I will point you at this: > > http://people.planetpostgresql.org/devrim/index.php?/archives/80-Installing-and-configuring-PostgreSQL-9.3-and-9.4-on-RHEL-7.html > > Thanks Adrian, had not seen that page, so I modified my image , moving some files around, having them modified and it's working as I expected.. w0w convoluted, but this works. "As of RHEL 7, as done in the Fedora packages for two years, the unit files are located under /lib/systemd/system/ directory. Please do not edit these files directly. Instead, if you want to make any changes, create a copy of them under /etc/systemd/system/ , and edit those files. Run" # Location of database directory Environment=PGDATA=/pgsql/9.5/data Thanks again! Tory