我在Linux Mint 18上运行Postgresql 9.5.
>在安装时,apt会在/var/lib/postgresql/9.5/main中创建一个集群.
>环境设置(postgresql.conf,pg_hba.conf,pg_ident.conf)存储在/etc/postgresql/9.5/main中.
> postgresql.conf将数据目录设置为/var/lib/postgresql/9.5/main.
我有一个故意小的根分区,并希望将我的集群放在更大的数据分区上.我在/ data / pg_data中运行了initdb.我可以使用pg_ctl手动启动和停止此集群.我的问题是,如何在系统启动时使用此群集启动Postgres?
我在Postgres文档中阅读了17.3 Starting the Database Server.该页面描述了(a)设置PGDATA环境变量,或(b)让服务器在启动时启动postgres守护进程.
使用PGDATA
我尝试通过在/ etc / environment中添加以下行来实现此目的:
PGDATA="/data/pg_data"
然后我重新开始了. Postgres已启动,但仍在使用默认数据目录. echo $PGDATA表示已设置环境变量,如果我停止运行集群,则在未指定数据目录的情况下启动pg_ctl会启动所需的集群.但它不是在启动时处理它.
使用init脚本
我无法想出这个.
文档说:
Different systems have different conventions for starting up daemons at boot time. Many systems have a file /etc/rc.local or /etc/rc.d/rc.local. Others use init.d or rc.d directories.
Linux Mint使用init.d文件夹.我在那里找到了一个postgresql文件并将其打开.这是一个60行的bash脚本.前几行是:
# Setting environment variables for the postmaster here does not work; please
# set them in /etc/postgresql/<version>/<cluster>/environment instead.
[ -r /usr/share/postgresql-common/init.d-functions ] || exit 0
. /usr/share/postgresql-common/init.d-functions
所以,首先我查看/etc/postgresql/9.5/main/environment.除了评论之外,该文件是空的.第一行说明了postmaster进程的#环境变量.是否应该在这里指向我想要的数据目录?
该文件包含/usr/share/postgresql-common/init.d-functions.这是一个112行文件,明确指向/ etc / postgresql /<版本号>并尝试启动它在那里找到的所有集群.它还清楚地引用了postgresql.conf.所以这似乎是默认群集的启动方式,但我不清楚这可以或应该被编辑.
解决方法:
您使用的是PGDG支持的官方套餐[1]吗?
你可以做两件事:
>编辑指向新目录的启动脚本文件(或创建一个符号链接).
>编辑/etc/postgresql/[version]/[cluster]/pg_ctl.conf以指向新目录;
请查看debian网站[2]的文档以查看更多详细信息.
编辑:看起来你正在寻找它是pg_createcluster [3]实用程序.
希望能帮助到你!
参考文献:
> http://apt.postgresql.org
> https://wiki.debian.org/PostgreSql
> http://manpages.ubuntu.com/manpages/trusty/en/man8/pg_createcluster.8.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。