Настройка systemd для запуска PostgreSQL от 1С
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5432 online postgres /var/lib/postgresql/10/main pg_log/postgresql-%a.log
#$ sudo pg_dropcluster --stop 10 main
$ sudo pg_ctlcluster 10 main stop
$ sudo su - postgres
$ /usr/lib/postgresql/10/bin/initdb --locale=ru_RU.utf8 /var/lib/postgresql/10/data
$ exit
$ sudo nano /etc/systemd/system/postgres.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres
Environment=PGROOT=/var/lib/postgresql/10
SyslogIdentifier=postgres
PIDFile=${PGROOT}/data/postmaster.pid
RuntimeDirectory=postgresql
RuntimeDirectoryMode=755
ExecStartPre= /usr/lib/postgresql/10/bin/pg_controldata ${PGROOT}/data
ExecStart= /usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop= /usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200
# Additional security-related features
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
Сохранить.
$ sudo systemctl start postgres.service
После проверики
Удалить кластер main (займет порт 5432) Удалит с Вашими данными!!!
$ sudo pg_dropcluster --stop 10 main
$ sudo systemctl enable postgres.service
Команды:
$ sudo systemctl daemon-reload # запускать после изменений файла
$ sudo systemctl start postgres.service
$ sudo systemctl stop postgres.service
$ sudo systemctl restart postgres.service
$ sudo systemctl status postgres.service
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5432 online postgres /var/lib/postgresql/10/main pg_log/postgresql-%a.log
#$ sudo pg_dropcluster --stop 10 main
$ sudo pg_ctlcluster 10 main stop
$ sudo su - postgres
$ /usr/lib/postgresql/10/bin/initdb --locale=ru_RU.utf8 /var/lib/postgresql/10/data
$ exit
$ sudo nano /etc/systemd/system/postgres.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres
Environment=PGROOT=/var/lib/postgresql/10
SyslogIdentifier=postgres
PIDFile=${PGROOT}/data/postmaster.pid
RuntimeDirectory=postgresql
RuntimeDirectoryMode=755
ExecStartPre= /usr/lib/postgresql/10/bin/pg_controldata ${PGROOT}/data
ExecStart= /usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop= /usr/lib/postgresql/10/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200
# Additional security-related features
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
Сохранить.
$ sudo systemctl start postgres.service
После проверики
Удалить кластер main (займет порт 5432) Удалит с Вашими данными!!!
$ sudo pg_dropcluster --stop 10 main
$ sudo systemctl enable postgres.service
Команды:
$ sudo systemctl daemon-reload # запускать после изменений файла
$ sudo systemctl start postgres.service
$ sudo systemctl stop postgres.service
$ sudo systemctl restart postgres.service
$ sudo systemctl status postgres.service
Комментариев нет:
Отправить комментарий