如何防止 postgresql-9.4 创建默认集群(主集群)?我有 Ubuntu 14.04,使用 aptitude 和 postresql 官方存储库。我正在使用 ansible 来控制多台服务器,并想创建自己的集群。
答案1
负责自动创建主集群的是 postgresql-commons 包。这个包的目的是允许在同一台机器上运行多个 PostgreSQL 版本的多个集群。您可以同时安装不同版本的 PostgreSQL。每个版本都可以管理多个集群。
Postgresql-commons 的配置文件位于/etc/postgresql-常见/。特别有趣的是创建集群配置文件。其内容如下:
# Default values for pg_createcluster(8)
# Occurrences of '%v' are replaced by the major version number,
# and '%c' by the cluster name. Use '%%' for a literal '%'.
# Create a "main" cluster when a new postgresql-x.y server package is installed
#create_main_cluster = true
# Default start.conf value, must be one of "auto", "manual", and "disabled".
# See pg_createcluster(8) for more documentation.
#start_conf = 'auto'
# Default data directory.
#data_directory = '/var/lib/postgresql/%v/%c'
# Default directory for transaction logs
# Unset by default, i.e. pg_xlog remains in the data directory.
#xlogdir = '/var/lib/postgresql/xlog/%v/%c/pg_xlog'
# Options to pass to initdb.
#initdb_options = ''
# The following options are copied into the new cluster's postgresql.conf:
# Enable SSL by default (using the "snakeoil" certificates installed by the
# ssl-cert package, unless configured otherwise here)
ssl = on
# Put stats_temp_directory on tmpfs
stats_temp_directory = '/var/run/postgresql/%v-%c.pg_stat_tmp'
# Add prefix to log lines
log_line_prefix = '%%t [%%p-%%l] %%q%%u@%%d '
为了防止它创建主集群,你必须安装 postgresql-commons,取消注释行创建主集群,将其设置为错误的然后安装所需版本的 PostgreSQL。