postgresql数据库改变data目录

来源:互联网 发布:加湿器推荐 知乎 编辑:程序博客网 时间:2024/06/06 04:08

原来的默认数据目录/var/lib/postgresql/9.3/data/空间不够大,改变数据目录


1. 修改配置文件/etc/postgresql/9.3/main/postgresql.conf

   data_directory = '/home/pgdata'

2.  修改data_directory的所有者

    chown -R postgres:postgres /home/pgdata

3.  这时候启动会报error

 * The PostgreSQL server failed to start. Please check the log output:
2014-11-25 09:55:02 CST FATAL:  data directory "/home/pgdata" has group or world access
2014-11-25 09:55:02 CST DETAIL:  Permissions should be u=rwx (0700).


 根据提示修改数据目录权限

    chmod 700 /home/pgdata

4. 启动依然会报错

 * The PostgreSQL server failed to start. Please check the log output:
2014-11-25 09:56:17 CST FATAL:  "/home/pgdata" is not a valid data directory
2014-11-25 09:56:17 CST DETAIL:  File "/home/pgdata/PG_VERSION" is missing.

   把默认数据目录的东西拷贝过来

    cp -r /var/lib/postgresql/9.3/main/* /home/pgdata/


5. 启动 service postgresql start

0 0