</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>coordUserDefinedBackupSettings</option></term>
+ <listitem>
+ <para>
+ Specify whether the system should use user-defined backup/recovery
+ settings. If <literal>y</literal> is specified then
+ <application>pgxc_ctl</application> will not overwrite the
+ <literal>archive_command</literal>, <literal>restore_command</literal>,
+ <literal>max_wal_senders</literal> etc while adding or removing a coordinator
+ standby. This can be useful when users want to setup their own backup
+ and recovery mechanism.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>coordSpecificExtraConfig</option></term>
<listitem>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>datanodeUserDefinedBackupSettings</option></term>
+ <listitem>
+ <para>
+ Specify whether the system should use user-defined backup/recovery
+ settings. If <literal>y</literal> is specified then
+ <application>pgxc_ctl</application> will not overwrite the
+ <literal>archive_command</literal>, <literal>restore_command</literal>,
+ <literal>max_wal_senders</literal> etc while adding or removing a datanode
+ standby. This can be useful when users want to setup their own backup
+ and recovery mechanism.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>datanodeSpecificExtraConfig</option></term>
<listitem>
/* Log Shipping */
- if (isVarYes(VAR_coordSlave) && !is_none(aval(VAR_coordSlaveServers)[jj]))
+ if (isVarYes(VAR_coordSlave) &&
+ !isVarYes(VAR_coordUserDefinedBackupSettings) &&
+ !is_none(aval(VAR_coordSlaveServers)[jj]))
{
/* Build WAL archive target directory */
appendCmdEl(cmdInitdb, (cmdWalArchDir = initCmd(aval(VAR_coordSlaveServers)[jj])));
snprintf(newCommand(cmdWalArchDir), MAXLINE,
"rm -rf %s;mkdir -p %s; chmod 0700 %s",
- aval(VAR_coordArchLogDirs)[jj], aval(VAR_coordArchLogDirs)[jj],
+ aval(VAR_coordArchLogDirs)[jj], aval(VAR_coordArchLogDirs)[jj],
aval(VAR_coordArchLogDirs)[jj]);
/* Build master's postgresql.conf */
appendCmdEl(cmdInitdb, (cmdWalArch = initCmd(aval(VAR_coordMasterServers)[jj])));
cleanCmd(cmd);
return(NULL);
}
- fprintf(f,
+ fprintf(f,
"#========================================\n"
"# Addition for log shipping, %s\n"
"wal_level = replica\n"
cleanCmd(cmd);
return(NULL);
}
- fprintf(f,
+ fprintf(f,
"#=================================================\n"
"# Addition at initialization, %s\n",
timeStampString(timestamp, MAXTOKEN));
"#==========================================\n"
"# Added to initialize the slave, %s\n"
"standby_mode = on\n"
- "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n"
- "restore_command = 'cp %s/%%f %%p'\n"
- "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n"
- "# End of addition\n",
+ "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n",
timeStampString(timestamp, MAXTOKEN), aval(VAR_coordMasterServers)[idx], aval(VAR_coordPorts)[idx],
- sval(VAR_pgxcOwner), aval(VAR_coordNames)[idx],
- aval(VAR_coordArchLogDirs)[idx], aval(VAR_coordArchLogDirs)[idx]);
+ sval(VAR_pgxcOwner), aval(VAR_coordNames)[idx]);
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "restore_command = 'cp %s/%%f %%p'\n"
+ "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n",
+ aval(VAR_coordArchLogDirs)[idx], aval(VAR_coordArchLogDirs)[idx]);
+ }
+ fprintf(f, "# End of addition\n");
fclose(f);
+
cmdRecoveryConf->localStdin = Strdup(localStdin);
snprintf(newCommand(cmdRecoveryConf), MAXLINE,
"cat >> %s/recovery.conf\n", aval(VAR_coordSlaveDirs)[idx]);
"# Added to initialize the slave, %s\n"
"hot_standby = on\n"
"port = %s\n"
- "pooler_port = %s\n"
- "wal_level = replica\n"
- "archive_mode = off\n"
- "archive_command = ''\n"
- "max_wal_senders = 0\n"
- "# End of Addition\n",
+ "pooler_port = %s\n",
timeStampString(timestamp, MAXTOKEN),
aval(VAR_coordSlavePorts)[idx],
aval(VAR_coordSlavePoolerPorts)[idx]);
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = replica\n"
+ "archive_mode = off\n"
+ "archive_command = ''\n"
+ "max_wal_senders = 0\n");
+ }
+ fprintf(f, "# End of Addition\n");
fclose(f);
+
cmdPgConf->localStdin = Strdup(localStdin);
snprintf(newCommand(cmdPgConf), MAXLINE,
"cat >> %s/postgresql.conf", aval(VAR_coordSlaveDirs)[idx]);
snprintf(port_s, MAXTOKEN, "%d", port);
snprintf(pooler_s, MAXTOKEN, "%d", pooler_port);
- /* Prepare the resources (directories) */
- doImmediate(host, NULL, "mkdir -p %s;chmod 0700 %s", dir, dir);
- doImmediate(host, NULL, "rm -rf %s; mkdir -p %s;chmod 0700 %s", archDir, archDir, archDir);
- /* Reconfigure the master with WAL archive */
- /* Update the configuration and backup the configuration file */
- if ((f = pgxc_popen_w(aval(VAR_coordMasterServers)[idx], "cat >> %s/postgresql.conf", aval(VAR_coordMasterDirs)[idx])) == NULL)
- {
- elog(ERROR, "ERROR: Cannot open coordinator master's configuration file, %s/postgresql.conf, %s\n",
- aval(VAR_coordMasterDirs)[idx], strerror(errno));
- return 1;
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ /* Prepare the resources (directories) */
+ doImmediate(host, NULL, "mkdir -p %s;chmod 0700 %s", dir, dir);
+ doImmediate(host, NULL, "rm -rf %s; mkdir -p %s;chmod 0700 %s", archDir, archDir, archDir);
+ /* Reconfigure the master with WAL archive */
+ /* Update the configuration and backup the configuration file */
+ if ((f = pgxc_popen_w(aval(VAR_coordMasterServers)[idx], "cat >> %s/postgresql.conf", aval(VAR_coordMasterDirs)[idx])) == NULL)
+ {
+ elog(ERROR, "ERROR: Cannot open coordinator master's configuration file, %s/postgresql.conf, %s\n",
+ aval(VAR_coordMasterDirs)[idx], strerror(errno));
+ return 1;
+ }
+ fprintf(f,
+ "#========================================\n"
+ "# Addition for log shipping, %s\n"
+ "wal_level = replica\n"
+ "archive_mode = on\n"
+ "archive_command = 'rsync %%p %s@%s:%s/%%f'\n"
+ "max_wal_senders = %d\n"
+ "# End of Addition\n",
+ timeStampString(date, MAXPATH),
+ sval(VAR_pgxcUser), host, archDir,
+ getDefaultWalSender(TRUE));
+ pclose(f);
}
- fprintf(f,
- "#========================================\n"
- "# Addition for log shipping, %s\n"
- "wal_level = replica\n"
- "archive_mode = on\n"
- "archive_command = 'rsync %%p %s@%s:%s/%%f'\n"
- "max_wal_senders = %d\n"
- "# End of Addition\n",
- timeStampString(date, MAXPATH),
- sval(VAR_pgxcUser), host, archDir,
- getDefaultWalSender(TRUE));
- pclose(f);
+
/* pg_hba.conf for replication */
if ((f = pgxc_popen_w(aval(VAR_coordMasterServers)[idx], "cat >> %s/pg_hba.conf", aval(VAR_coordMasterDirs)[idx])) == NULL)
{
"# Added to initialize the slave, %s\n"
"hot_standby = on\n"
"port = %d\n"
- "pooler_port = %d\n"
- "wal_level = replica\n"
- "archive_mode = off\n" /* No archive mode */
- "archive_command = ''\n" /* No archive mode */
- "max_wal_senders = 0\n" /* Minimum WAL senders */
- "# End of Addition\n",
+ "pooler_port = %d\n",
timeStampString(date, MAXTOKEN),
atoi(aval(VAR_coordSlavePorts)[idx]),
atoi(aval(VAR_coordSlavePoolerPorts)[idx]));
+
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = replica\n"
+ "archive_mode = off\n" /* No archive mode */
+ "archive_command = ''\n" /* No archive mode */
+ "max_wal_senders = 0\n"); /* Minimum WAL senders */
+ }
+
+ fprintf(f, "# End of Addition\n");
pclose(f);
/* Update the slave recovery.conf */
if ((f = pgxc_popen_w(host, "cat >> %s/recovery.conf", dir)) == NULL)
"#==========================================\n"
"# Added to add the slave, %s\n"
"standby_mode = on\n"
- "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n"
- "restore_command = 'cp %s/%%f %%p'\n"
- "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n"
- "# End of addition\n",
+ "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n",
timeStampString(date, MAXTOKEN), aval(VAR_coordMasterServers)[idx], aval(VAR_coordPorts)[idx],
- sval(VAR_pgxcOwner), aval(VAR_coordNames)[idx],
- aval(VAR_coordArchLogDirs)[idx], aval(VAR_coordArchLogDirs)[idx]);
+ sval(VAR_pgxcOwner), aval(VAR_coordNames)[idx]);
+
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "restore_command = 'cp %s/%%f %%p'\n"
+ "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n",
+ aval(VAR_coordArchLogDirs)[idx], aval(VAR_coordArchLogDirs)[idx]);
+ }
+ fprintf(f, "# End of addition\n");
pclose(f);
/* Start the slave */
fprintf(f,
"#=======================================\n"
"# Updated to remove the slave %s\n"
- "archive_mode = off\n"
- "synchronous_standby_names = ''\n"
- "archive_command = ''\n"
- "max_wal_senders = 0\n"
- "wal_level = minimal\n"
- "# End of the update\n",
+ "synchronous_standby_names = ''\n",
timeStampString(date, MAXTOKEN));
+
+ if (!isVarYes(VAR_coordUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = minimal\n"
+ "archive_mode = off\n"
+ "archive_command = ''\n"
+ "max_wal_senders = 0\n");
+ }
+
+ fprintf(f, "# End of the update\n");
pclose(f);
}
doImmediate(aval(VAR_coordMasterServers)[idx], NULL, "pg_ctl restart -Z coordinator -D %s", aval(VAR_coordMasterDirs)[idx]);
fclose(f);
/* Additional Initialization for log_shipping */
- if (isVarYes(VAR_datanodeSlave) && !is_none(aval(VAR_datanodeSlaveServers)[idx]))
+ if (isVarYes(VAR_datanodeSlave) &&
+ !isVarYes(VAR_datanodeUserDefinedBackupSettings) &&
+ !is_none(aval(VAR_datanodeSlaveServers)[idx]))
{
cmd_t *cmd_cleanDir, *cmd_PgConf;
/* This datanode has a slave */
"#==========================================\n"
"# Added to initialize the slave, %s\n"
"standby_mode = on\n"
- "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n"
- "restore_command = 'cp %s/%%f %%p'\n"
- "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n",
+ "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n",
timeStampString(timestamp, MAXTOKEN),
- aval(VAR_datanodeMasterServers)[idx], aval(VAR_datanodePorts)[idx],
- sval(VAR_pgxcOwner), aval(VAR_datanodeNames)[idx],
- aval(VAR_datanodeArchLogDirs)[idx],
- aval(VAR_datanodeArchLogDirs)[idx]);
+ aval(VAR_datanodeMasterServers)[idx], aval(VAR_datanodePorts)[idx],
+ sval(VAR_pgxcOwner), aval(VAR_datanodeNames)[idx]);
+
+ if (!isVarYes(VAR_datanodeUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "restore_command = 'cp %s/%%f %%p'\n"
+ "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n",
+ aval(VAR_datanodeArchLogDirs)[idx],
+ aval(VAR_datanodeArchLogDirs)[idx]);
+ }
fclose(f);
/* Configure slave's postgresql.conf */
fprintf(f,
"#========================================\n"
"# Addition for log shipping, %s\n"
- "wal_level = replica\n"
- "archive_mode = on\n"
- "archive_command = 'rsync %%p %s@%s:%s/%%f'\n"
- "max_wal_senders = %d\n"
"synchronous_commit = on\n"
- "synchronous_standby_names = '%s'\n"
- "# End of Addition\n",
- timeStampString(date, MAXPATH),
- sval(VAR_pgxcUser), host, archDir,
- getDefaultWalSender(FALSE),
- name);
+ "synchronous_standby_names = '%s'\n",
+ timeStampString(date, MAXPATH), name);
+
+ if (!isVarYes(VAR_datanodeUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = replica\n"
+ "archive_mode = on\n"
+ "archive_command = 'rsync %%p %s@%s:%s/%%f'\n"
+ "max_wal_senders = %d\n",
+ sval(VAR_pgxcUser), host, archDir,
+ getDefaultWalSender(FALSE));
+ }
+ fprintf(f, "# End of Addition\n");
pclose(f);
/* pg_hba.conf for replication */
if ((f = pgxc_popen_w(aval(VAR_datanodeMasterServers)[idx], "cat >> %s/pg_hba.conf", aval(VAR_datanodeMasterDirs)[idx])) == NULL)
"# Added to initialize the slave, %s\n"
"hot_standby = on\n"
"port = %s\n"
- "pooler_port = %s\n"
- "wal_level = replica\n"
- "archive_mode = off\n" /* No archive mode */
- "archive_command = ''\n" /* No archive mode */
- "max_wal_senders = 0\n" /* Minimum WAL senders */
- "# End of Addition\n",
+ "pooler_port = %s\n",
timeStampString(date, MAXTOKEN), aval(VAR_datanodeSlavePorts)[idx], aval(VAR_datanodeSlavePoolerPorts)[idx]);
+ if (!isVarYes(VAR_datanodeUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = replica\n"
+ "archive_mode = off\n" /* No archive mode */
+ "archive_command = ''\n" /* No archive mode */
+ "max_wal_senders = 0\n"); /* Minimum WAL senders */
+ }
+ fprintf(f, "# End of Addition\n");
pclose(f);
/* Update the slave recovery.conf */
if ((f = pgxc_popen_w(host, "cat >> %s/recovery.conf", dir)) == NULL)
"#==========================================\n"
"# Added to add the slave, %s\n"
"standby_mode = on\n"
- "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n"
- "restore_command = 'cp %s/%%f %%p'\n"
- "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n"
- "# End of addition\n",
+ "primary_conninfo = 'host = %s port = %s user = %s application_name = %s'\n",
timeStampString(date, MAXTOKEN), aval(VAR_datanodeMasterServers)[idx], aval(VAR_datanodePorts)[idx],
- sval(VAR_pgxcOwner), aval(VAR_datanodeNames)[idx],
- aval(VAR_datanodeArchLogDirs)[idx], aval(VAR_datanodeArchLogDirs)[idx]);
+ sval(VAR_pgxcOwner), aval(VAR_datanodeNames)[idx]);
+ if (!isVarYes(VAR_datanodeUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "restore_command = 'cp %s/%%f %%p'\n"
+ "archive_cleanup_command = 'pg_archivecleanup %s %%r'\n",
+ aval(VAR_datanodeArchLogDirs)[idx], aval(VAR_datanodeArchLogDirs)[idx]);
+ }
+ fprintf(f, "# End of addition\n");
pclose(f);
/* Start the slave */
doImmediate(host, NULL, "pg_ctl start -w -Z datanode -D %s", dir);
fprintf(f,
"#=======================================\n"
"# Updated to remove the slave %s\n"
- "archive_mode = off\n"
- "synchronous_standby_names = ''\n"
- "archive_command = ''\n"
- "max_wal_senders = 0\n"
- "wal_level = minimal\n"
- "# End of the update\n",
+ "synchronous_standby_names = ''\n",
timeStampString(date, MAXTOKEN));
+
+ if (!isVarYes(VAR_datanodeUserDefinedBackupSettings))
+ {
+ fprintf(f,
+ "wal_level = minimal\n"
+ "archive_mode = off\n"
+ "archive_command = ''\n"
+ "max_wal_senders = 0\n");
+ }
+
+ fprintf(f, "# End of the update\n");
pclose(f);
}
doImmediate(aval(VAR_datanodeMasterServers)[idx], NULL, "pg_ctl restart -Z datanode -D %s", aval(VAR_datanodeMasterDirs)[idx]);
print_array coordMasterServers
print_array coordMasterDirs
print_array coordMaxWALSenders
+ echo coordUserDefinedBackupSettings $coordUserDefinedBackupSettings
# Coordinators slave
echo coordSlave $coordSlave
print_array datanodePoolerPorts
#endif
print_array datanodePgHbaEntries
+ echo datanodeUserDefinedBackupSettings $datanodeUserDefinedBackupSettings
# Datanodes masters
print_array datanodeMasterServers
# then coordSlave value will be set to n and all the following values will be set to
# empty values.
coordSlaveSync=n # Specify to connect with synchronized mode.
+
+coordUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+ # settings during standby addition/removal.
+
coordSlaveServers=() # none means this slave is not available
coordSlavePorts=() # coordinator slave listening ports
coordSlavePoolerPorts=() # coordinator slave pooler ports
# If no effective server names are found (that is, every servers are specified as none),
# then datanodeSlave value will be set to n and all the following values will be set to
# empty values.
+
+datanodeUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+ # settings during standby addition/removal.
+ #
datanodeSlaveServers=() # value none means this slave is not available
datanodeSlavePorts=() # Master and slave use the same port!
datanodeSlavePoolerPorts=() # Master and slave use the same port!
# If no effective server names are found (that is, every servers are specified as none),
# then coordSlave value will be set to n and all the following values will be set to
# empty values.
+
+coordUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+ # settings during standby addition/removal.
+
coordSlaveSync=y # Specify to connect with synchronized mode.
coordSlaveServers=(node07 node08 node09 node06) # none means this slave is not available
coordSlavePorts=(20004 20005 20004 20005) # Master ports
# If no effective server names are found (that is, every servers are specified as none),
# then datanodeSlave value will be set to n and all the following values will be set to
# empty values.
+
+datanodeUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+ # settings during standby addition/removal.
+
datanodeSlaveServers=(node07 node08 node09 node06) # value none means this slave is not available
datanodeSlavePorts=(20008 20009 20008 20009) # value none means this slave is not available
datanodeSlavePoolerPorts=(20012 20013 20012 20013) # value none means this slave is not available
# then coordSlave value will be set to n and all the following values will be set to
# empty values.
coordSlaveSync=y # Specify to connect with synchronized mode.
+
+#coordUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+# # settings during standby addition/removal.
+
coordSlaveServers=(localhost localhost) # none means this slave is not available
coordSlavePorts=(30101 30102) # coordinator slave listening ports
coordSlavePoolerPorts=(30111 30112) # coordinator slave pooler ports
# If no effective server names are found (that is, every servers are specified as none),
# then datanodeSlave value will be set to n and all the following values will be set to
# empty values.
+#
+#datanodeUserDefinedBackupSettings=n # Specify whether to update backup/recovery
+# # settings during standby addition/removal.
+
#datanodeSlaveServers=(localhost localhost) # value none means this slave is not available
#datanodeSlavePorts=(40101 40102) # Master and slave use the same port!
#datanodeSlavePoolerPorts=(40111 40112) # Master and slave use the same port!
#define VAR_coordPorts "coordPorts"
#define VAR_poolerPorts "poolerPorts"
#define VAR_coordPgHbaEntries "coordPgHbaEntries"
+#define VAR_coordUserDefinedBackupSettings "coordUserDefinedBackupSettings"
/* Coordinators master */
#define VAR_coordMasterServers "coordMasterServers"
#define VAR_datanodePoolerPorts "datanodePoolerPorts"
#define VAR_datanodePgHbaEntries "datanodePgHbaEntries"
#define VAR_primaryDatanode "primaryDatanode"
+#define VAR_datanodeUserDefinedBackupSettings "datanodeUserDefinedBackupSettings"
/* Datanode masters */
#define VAR_datanodeMasterServers "datanodeMasterServers"