postgresql - Postgresql:如何将它安装在 linux 服务器的不同位置?
问题描述
我想安装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
您也可以尝试符号链接/var/lib/postgresql/9.5/main
到/home/database/postgresql/9.5/main
- 可能更简单。
推荐阅读
- wordpress - 将类添加到 woocomerce div 标签
- python - 无法通过 python 使用 rest 调用获取数据
- python - 如何在初始化 numpy 对象数组时避免额外的浮点对象副本
- python - 具有两个变量的唯一组合的 Python 数据格式
- linux - 创建 runbook 以执行 bash 脚本
- docker - Docker for Windows:无法添加卷
- verilog - 如何检查用verilog编写的7段显示器的输出
- azure - 无法通过昨天在 Azure 上的 .NET Core API 2.1 访问 Key Vault?
- groovy - 如何在 groovy 类中访问管道 DSL(而不是在 Jenkinsfile 中)?
- web-services - Nginx 动态配置