Postgresql 在 ubuntu 中更改数据目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11608482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgresql changing data directory in ubuntu
提问by Amitash
Possible Duplicate:
Postgresql failed to start
可能重复:
Postgresql 无法启动
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
这个问题一直让我发疯,似乎没有任何效果。我需要更改 postgresql 存储数据库的位置。在终端中使用命令时,我是一个完整的新手,使用正确命令的分步说明真的很有帮助。我在整个网络上进行了搜索,但所有说明都假定对终端命令有一些先验知识。我确实尝试了一种方法,在主数据文件夹中创建一个指向我所需位置的符号链接。这给了我一个错误,要求我检查日志文件。但是,我不知道日志文件在哪里。很多人似乎都有这个问题,一步一步的解决方案肯定会有所帮助。我的 Psql 版本是 8.4。Ubuntu 10.10
回答by Daniel Vérité
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.
最新的日志文件完整路径是/var/log/postgresql/postgresql-8.4-main.log
但符号链接不是更改数据位置的更集成/更简单的方法。
I'd suggest to do it by creating the entire cluster to the desired location, with the pg_createclustercommand that comes with the debian/ubuntu postgres packages.
我建议通过使用 debian/ubuntu postgres 软件包附带的pg_createcluster命令将整个集群创建到所需位置来实现。
1- delete your current cluster, if it does not contain any prior data:
1- 删除您当前的集群,如果它不包含任何先前的数据:
$ sudo pg_dropcluster --stop 8.4 main
$ sudo pg_dropcluster --stop 8.4 main
2- create a new cluster at the new location
2- 在新位置创建一个新集群
$ sudo pg_createcluster -d /path/to/new/location 8.4 main
$ sudo pg_createcluster -d /path/to/new/location 8.4 main
3- restart postgresql
3-重新启动postgresql
$ sudo /etc/init.d/postgresql start
$ sudo /etc/init.d/postgresql start