Postgresql更改数据目录和套接字错误

Postgresql更改数据目录和套接字错误

当我在

/etc/postgresql/9.5/main/postgresql.conf

表单默认路径

/var/lib/postgresql/9.5/main

按照我的习惯

/home/用户/postgresql/9.5/main

使用本手册https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-16-04

我有错误:

psql:无法连接到服务器:没有此文件或目录服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?

当我错了?

UPD1

ubuntu@rails-serv-1:~$ sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor prese
Active: active (exited) since Wed 2016-10-19 08:52:12 UTC; 4min 52s ago
Process: 854 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 854 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service

Oct 19 08:52:12 rails-serv-1 systemd[1]: Starting PostgreSQL RDBMS...
Oct 19 08:52:12 rails-serv-1 systemd[1]: Started PostgreSQL RDBMS.

UPD2

ubuntu@rails-serv-1:~$ sudo ps auxww | grep [p]ostgresql
ubuntu@rails-serv-1:~$

是空的

ubuntu@rails-serv-1:~$  sudo ls -al /var/run/postgresql
total 0
drwxrwsr-x  2 postgres postgres  40 Oct 19 21:28 .
drwxr-xr-x 24 root     root     900 Oct 19 21:32 ..

UPD3

日志

"2016-10-21 07:25:54 UTC [3493-1] FATAL: data directory "/var/lib/postgresql-new/9.5/main" has group or world access 2016-10-21 07:25:54 UTC [3493-2] DETAIL: Permissions should be u=rwx (0700)."

文件夹权限

root@rails-serv-1:~# cd /var/lib/postgresql-new/
root@rails-serv-1:/var/lib/postgresql-new# ls -lh
total 4.0K
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 9.5
root@rails-serv-1:/var/lib/postgresql-new# cd 9.5/
root@rails-serv-1:/var/lib/postgresql-new/9.5# ls -lh
total 4.0K
drwx------ 1 postgres postgres 4.0K Oct 18 23:01 main
root@rails-serv-1:/var/lib/postgresql-new/9.5# cd main/
root@rails-serv-1:/var/lib/postgresql-new/9.5/main# ls -lh
total 80K
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 base
drwx------ 1 postgres postgres 4.0K Oct 18 23:01 global
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_clog
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_commit_ts
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_dynshmem
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_logical
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_multixact
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_notify
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_replslot
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_serial
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_snapshots
drwx------ 1 postgres postgres 4.0K Oct 18 23:01 pg_stat
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_stat_tmp
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_subtrans
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_tblspc
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_twophase
-rw------- 1 postgres postgres    4 Oct 18 23:00 PG_VERSION
drwx------ 1 postgres postgres 4.0K Oct 18 23:00 pg_xlog
-rw------- 1 postgres postgres   88 Oct 18 23:00 postgresql.auto.conf
-rw------- 1 postgres postgres  133 Oct 18 23:00 postmaster.opts

相关内容