Unable to start postgresql.service?
OP seems to be using RHEL7 or CentOS7, as indicated by the systemctl commands. If so, the service . restart commands won’t work.
Finally, I figured this one out. There was already a file present
/usr/lib/systemd/system/postgresql-9.6.service
So, may be due to the presence of this file, I was not able to start postgresql.service. Then I tried to start postgresql-9.6.service as follows:
[code_master5@BitBox ~]$ sudo systemctl start postgresql-9.6.service Failed to start postgresql-9.6.service: Unit postgresql-9.6.service not found.
And, as you can see the output, again it failed.
I simply deleted the file using sudo as I thought may be postgresql.service file is not being created by relevant program due to the presence of this file. Then I restarted the system. It’s working fine since then, as you can see the output below:
[code_master5@BitBox ~]$ sudo systemctl status postgresql.service [sudo] password for code_master5: ● postgresql.service - PostgreSQL database server Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor p Active: active (running) since Sat 2017-01-28 09:31:30 IST; 7h ago Main PID: 342 (postgres) Tasks: 6 (limit: 4915) CGroup: /system.slice/postgresql.service ├─342 /usr/bin/postgres -D /var/lib/postgres/data ├─358 postgres: checkpointer process ├─359 postgres: writer process ├─360 postgres: wal writer process ├─361 postgres: autovacuum launcher process └─362 postgres: stats collector process Jan 28 09:31:26 BitBox systemd[1]: Starting PostgreSQL database server. Jan 28 09:31:28 BitBox postgres[340]: FATAL: the database system is starting up Jan 28 09:31:28 BitBox postgres[340]: LOG: database system was shut down at 201 Jan 28 09:31:29 BitBox postgres[340]: FATAL: the database system is starting up Jan 28 09:31:29 BitBox postgres[340]: LOG: MultiXact member wraparound protecti Jan 28 09:31:29 BitBox postgres[340]: LOG: database system is ready to accept c Jan 28 09:31:29 BitBox postgres[340]: LOG: autovacuum launcher started Jan 28 09:31:30 BitBox systemd[1]: Started PostgreSQL database server.
I would surely like to warn all those having same problem. Please do whatever I did at your own risk. Since these are system files. Messing with these can spoil your weekend!
I am still a bit confused on this though. Explanations are welcome!
postgres запускается, но не запускается
Знаю, что уже замылили эту тему, но все, что я нашел не помогло или не соответствует моей ситуации, так что прошу помощи знатоков.
на что получаю сообщение, что все ok
# sudo -u postgres psql template1 psql: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
ладушки. гугл в помощь. но не тут то было..
# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 717/nginx -g daemon tcp 0 0 0.0.0.0:8069 0.0.0.0:* LISTEN 514/python tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 717/nginx -g daemon tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 665/sshd tcp6 0 0 . 80 . * LISTEN 717/nginx -g daemon tcp6 0 0 . 22 . * LISTEN 665/sshd
# uname -a Linux 82608.local 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux root@82608:/var/run/postgresql#
при запуске ошибок не выдает но и не запускается.. как так? при этом
# /etc/init.d/postgresql status ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2017-11-08 10:32:43 MSK; 26min ago Process: 11432 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 11432 (code=exited, status=0/SUCCESS) CGroup: /system.slice/postgresql.service Nov 08 10:32:43 82608.local systemd[1]: Starting PostgreSQL RDBMS. Nov 08 10:32:43 82608.local systemd[1]: Started PostgreSQL RDBMS. Nov 08 10:43:03 82608.local systemd[1]: Started PostgreSQL RDBMS.
Active: active (exited) since Wed 2017-11-08 10:32:43 MSK; 26min ago
could not connect to server: Connection refused
Dron ★★★★★ ( 08.11.17 11:19:16 MSK )
Последнее исправление: Dron 08.11.17 11:25:24 MSK (всего исправлений: 1)
Что тебе нужно подробнее? здесь и так все ясно написано
ну, видимо, мне не ясно, раз я спрашиваю. Логично же.
# psql psql: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
я не понимаю, что ему нужно от меня?
postgresql.service — запускает все настроенные инстансы постгреса в убунте, для того чтобы запустить нужный нужно стартовать postgresql-.service.
Deleted ( 08.11.17 11:34:13 MSK )
Последнее исправление: MyLittleLoli 08.11.17 11:36:15 MSK (всего исправлений: 1)
createuser —interactive сделай, добавь пользователя дай ему нужную роль, зайди от него.
В соединении отказано, всё работает, просто у тебя нет доступа
ну, видимо, мне не ясно, раз я спрашиваю. Логично же.
Ну, кроме вчитаться в текст я тебе больше ничего предложить не могу
В соединении отказано, всё работает, просто у тебя нет доступа
Это не значит, что нет доступа, это значит, что там попросту некому это соединение принимать.
вот жесть-то, и советчики такие же.
Ты бы внимательно прочитал на что отвечаешь.
Там не то, что ролей, там и самого процесса постгресса нет
# psql psql: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Тьфу блин, ай нуу, пойду кофе пить и просыпаться 😀
Значит есть /var/lib/postgresql/версия/pg_log/*.log
Покажи systemctl list-units|grep postgres
Там должен быть сервис вида postgresql@9.5-main.service. Вот его и запускаешь, systemctl start postgresql@9.5-main.service.
Если нет, то смотришь в /var/lib/postgres, есть ли там что-нибудь. Если там пусто, значит у тебя нет базы, и ее нужно создать.
Точно нет? Показывай /etc/init.d/postgresql — посмотрим, что там в убунтушном инит-скрипте накручено.
Какой инит-скрипт, у него systemd.
# cd /var/lib/postgresql/9.5; ls main /var/lib/postgresql/9.5/main# ls base pg_clog pg_dynshmem pg_multixact pg_replslot pg_snapshots pg_stat_tmp pg_tblspc PG_VERSION postgresql.auto.conf global pg_commit_ts pg_logical pg_notify pg_serial pg_stat pg_subtrans pg_twophase pg_xlog postmaster.opts
# systemctl list-units|grep postgres postgresql.service loaded active exited PostgreSQL RDBMS ● postgresql@9.5-main.service loaded failed failed PostgreSQL Cluster 9.5-main system-postgresql.slice loaded active active system-postgresql.slice # systemctl start postgresql@9.5-main.service Job for postgresql@9.5-main.service failed because the control process exited with error code. See "systemctl status postgresql@9.5-main.service" and "journalctl -xe" for details.
#!/bin/sh set -e ### BEGIN INIT INFO # Provides: postgresql # Required-Start: $local_fs $remote_fs $network $time # Required-Stop: $local_fs $remote_fs $network $time # Should-Start: $syslog # Should-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: PostgreSQL RDBMS server ### END INIT INFO # Setting environment variables for the postmaster here does not work; please # set them in /etc/postgresql///environment instead. [ -r /usr/share/postgresql-common/init.d-functions ] || exit 0 . /usr/share/postgresql-common/init.d-functions # versions can be specified explicitly if [ -n "$2" ]; then versions="$2 $3 $4 $5 $6 $7 $8 $9" else get_versions fi case "$1" in start|stop|restart|reload) if [ "$1" = "start" ]; then create_socket_directory fi if [ -z "`pg_lsclusters -h`" ]; then log_warning_msg 'No PostgreSQL clusters exist; see "man pg_createcluster"' exit 0 fi for v in $versions; do $1 $v || EXIT=$? done exit $ ;; status) LS=`pg_lsclusters -h` # no clusters -> unknown status [ -n "$LS" ] || exit 4 echo "$LS" | awk 'BEGIN ; END ' ;; force-reload) for v in $versions; do reload $v done ;; *) echo "Usage: $0 [version ..]" exit 1 ;; esac exit 0
У убунты логи постгреса в /var/log/postgresql. Смотри почему он фейлится. Ну и можешь journalctl -e -u postgresql@9.5-main.service глянуть.
Deleted ( 08.11.17 12:44:08 MSK )
Последнее исправление: MyLittleLoli 08.11.17 12:45:16 MSK (всего исправлений: 1)
смотри во время запуска/перезапуска сервиса
tail -F /var/log/syslog
Unable to start postgresql service on CentOS 7
Unable to start postgresql-9.5 on CentOS 7. I followed this page — https://wiki.postgresql.org/wiki/YUM_Installation — for installing the database server on CentOS. I tried the same after setting setenforce 0 , and that did not help either. I am doing all operations as root .
systemctl start postgresql-9.5.service Job for postgresql-9.5.service failed because the control process exited with error code. See "systemctl status postgresql-9.5.service" and "journalctl -xe" for details.
Redirecting to /bin/systemctl status postgresql-9.5.service ● postgresql-9.5.service - PostgreSQL 9.5 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2016-02-18 15:20:30 EST; 2min 28s ago Process: 15041 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir $ (code=exited, status=1/FAILURE) Feb 18 15:20:30 myserver systemd[1]: Starting PostgreSQL 9.5 database server. Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1 Feb 18 15:20:30 myserver systemd[1]: Failed to start PostgreSQL 9.5 database server. Feb 18 15:20:30 myserver systemd[1]: Unit postgresql-9.5.service entered failed state. Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service failed.
[root@myserver /]# cat /etc/ld.so.conf.d/postgresql-pgdg-libs.conf /usr/pgsql-9.5/lib/ [root@myserver /]# cat /usr/lib/tmpfiles.d/postgresql-9.5.conf d /var/run/postgresql 0755 postgres postgres - [root@myserver /]# cat /usr/pgsql-9.5/share/postgresql-9.5-libs.conf /usr/pgsql-9.5/lib/ [root@myserver /]# cat /etc/alternatives/pgsql-ld-conf /usr/pgsql-9.5/lib/ [root@myserver /]# cat /var/lib/alternatives/pgsql-ld-conf auto /etc/ld.so.conf.d/postgresql-pgdg-libs.conf /usr/pgsql-9.5/share/postgresql-9.5-libs.conf 950
Googled for the error that I am seeing. A number of folks have seen the same error, and the underlying cause is different in each case. Reading through those posts, it is not clear that I am seeing any of the already reported causes.
Failed to start PostgreSQL database server
After some attempts to change permissions to access pqsql and data in /var/lib/pgsql/data/ my postgres-server failed. Postgresql status is:
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Ср 2020-02-05 12:46:48 MSK; 2min 19s ago Process: 572 ExecStart=/usr/bin/pg_ctl start -D $ -s -o -p $ -w -t 300 (code=exited, status=1/FAILURE) Process: 564 ExecStartPre=/usr/bin/postgresql-check-db-dir $ (code=exited, status=0/SUCCESS) plesk.iline.pro systemd[1]: Starting PostgreSQL database server. plesk.iline.pro pg_ctl[572]: FATAL: data directory "/var/lib/pgsql/data" has wrong ownership plesk.iline.pro pg_ctl[572]: HINT: The server must be started by the user that owns the data directory. plesk.iline.pro pg_ctl[572]: pg_ctl: could not start server plesk.iline.pro pg_ctl[572]: Examine the log output. plesk.iline.pro systemd[1]: postgresql.service: control process exited, code=exited status=1 plesk.iline.pro systemd[1]: Failed to start PostgreSQL database server. plesk.iline.pro systemd[1]: Unit postgresql.service entered failed state. plesk.iline.pro systemd[1]: postgresql.service failed.
input_userauth_request: invalid user isp [preauth] plesk.iline.pro sshd[17416]: pam_unix(sshd:auth): check pass; user unknown plesk.iline.pro sshd[17416]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.25.105.121 plesk.iline.pro dreamwhiteApi[4034]: 2020/02/05 12:15:02 Requesting: GET https://online.moysklad.ru/api/remap/1.1/entity/employee/? plesk.iline.pro postfix/postdrop[1048]: warning: mail_queue_enter: create file maildrop/663461.1048: Permission denied plesk.iline.pro postfix/postdrop[25484]: warning: mail_queue_enter: create file maildrop/739287.25484: Permission denied
drwxr-xr-x 4 postgres postgres 4096 pgsql drwxr-xr-x 15 polkitd postgres 4096 data
But the problem remains. Postgresql-vertion is 9.2 (I can’t change this version for some reasons in my server).