PostgreSQL在Ubuntu中更改数据目录 [英] Postgresql changing data directory in ubuntu

查看:191
本文介绍了PostgreSQL在Ubuntu中更改数据目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Postgresql无法启动

这个问题一直让我发疯,似乎没有任何效果。我需要更改postgresql存储数据库的位置。对于在终端中使用命令,我是一个完全的新手,使用逐步正确的命令逐步说明将非常有帮助。我在网上搜索了所有内容,但所有说明都假定您对终端命令有一些先验知识。我确实通过在主数据文件夹中创建到所需位置的符号链接来尝试一种方法。这给了我一个错误,要求我检查日志文件。但是,我不知道日志文件在哪里。很多人似乎都遇到了这个问题,逐步解决方案肯定会有所帮助。我的Psql版本是8.4。 Ubuntu 10.10

This problem has been driving me crazy and nothing seems to be working. I need to change the location where postgresql stores the data base. I am a complete novice when it comes to using commands in the terminal and step by step instructions with the proper commands would really help. I searched all over the web but all instructions assume some prior good knowledge to terminal commands. I did try one approach by creating a symbolic link in the main data folder to my required location. This gives me an error that asks me to check the log file. However, I have no idea where the log file is. A lot of people seem to have this problem and a step by step solution would surely help. My Psql version is 8.4. Ubuntu 10.10

推荐答案

最新日志文件的完整路径为 /var/log/postgresql/postgresql-8.4 -main.log ,但是符号链接并不是更改数据位置的更集成/更简便的方法。

The latest log file full path is /var/log/postgresql/postgresql-8.4-main.log but the symbolic link is not the more integrated/easy way to change the data location.

我建议这样做通过使用随附的 pg_createcluster 命令,将整个集群创建到所需位置

I'd suggest to do it by creating the entire cluster to the desired location, with the pg_createcluster command that comes with the debian/ubuntu postgres packages.

1-如果当前集群不包含任何先前数据,则删除当前集群:

1- delete your current cluster, if it does not contain any prior data:


$ sudo pg_dropcluster --stop 8.4 main


2-在新位置创建新集群

2- create a new cluster at the new location


$ sudo pg_createcluster -d /path/to/new/location 8.4 main


3-重新启动PostgreSQL

3- restart postgresql


$ sudo /etc/init.d/postgresql start


这篇关于PostgreSQL在Ubuntu中更改数据目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆