gpt4 book ai didi

Postgresql:如何将它安装在 linux 服务器的不同位置?

转载 作者:行者123 更新时间:2023-12-04 18:29:46 25 4
gpt4 key购买 nike

我要安装postgresql在linux(ubuntu)服务器中。

如果我执行以下操作:

sudo apt-get install postgresql

它将安装它
/var/lib/postgresql/9.5/main

虽然我想把它放进去
/home/database/postgresql/9.5/main

最佳答案

Postgres 使用 PGDATA环境变量以了解您希望它在哪里工作。编辑初始化脚本(/etc/init.d/postgresql/usr/lib/systemd/postgresql.service )并设置 PGDATA因此。例如:

# Note: changing PGDATA will typically require adjusting SELinux
# configuration as well.

# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-setup.
[Unit]
Description=PostgreSQL database server
After=syslog.target
After=network.target

[Service]
Type=forking

User=postgres
Group=postgres

# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.

# Location of database directory
Environment=PGDATA=/var/sql/pgsql/

# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog

# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000

#ExecStartPre=/usr/local/pgsql/bin/postgresql95-check-db-dir ${PGDATA}
ExecStart=/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -w -t 300
ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

您也可以尝试符号链接(symbolic link) /var/lib/postgresql/9.5/main/home/database/postgresql/9.5/main - 可能更简单。

关于Postgresql:如何将它安装在 linux 服务器的不同位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55499184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com