replicator/lib/ruby/pg-wal-plugin.rb
# Generate recovery.conf so we can go online later.
Generate recovery.conf so we can go online later.
Generate recovery . conf so we can go online later .
def generate_recovery_conf(master_host, master_port)
    config = getConfig()
    cprops = getPgWalProperties()
    master_user = config.getProperty("postgresql.master.user")
    trigger = cprops.getProperty("postgresql.pg_standby.trigger")
    pg_archive  = @config.getProperty("postgresql.archive")
    out = File.open(@recovery_conf, "w")
    if is_streaming_replication
      pg_archivecleanup = @config.getProperty("postgresql.pg_archivecleanup")
      out.puts("# Specifies whether to start the server as a standby. In streaming replication,")
      out.puts("# this parameter must to be set to on.")
      out.puts("standby_mode = 'on'")
      out.puts
      out.puts("# Specifies a connection string which is used for the standby server to connect")
      out.puts("# with the primary.")
      out.puts("primary_conninfo = 'host=#{master_host} port=#{master_port} user=#{master_user}'")
      out.puts
      out.puts("# Specifies a trigger file whose presence should cause streaming replication to")
      out.puts("# end (i.e., failover).")
      out.puts("trigger_file = '#{trigger}'")
      out.puts
      out.puts("# In SR, we only move the WAL file to PG, if asked.")
      out.puts("restore_command = 'echo \"Restoring %f\"; mv #{pg_archive}/%f %p'")
      out.puts
      out.puts("# We also need to take care about removing not needed WAL files under SR.") 
      out.puts("archive_cleanup_command = '#{pg_archivecleanup} -d #{pg_archive} %r 2>>cleanup.log'")
    else
      out.puts("restore_command = '#{@pg_wal_restore} %f %p %r'")
    end
    out.close    
  end
def generate_recovery_conf ( master_host , master_port ) config = getConfig ( ) cprops = getPgWalProperties ( ) master_user = config . getProperty ( "postgresql.master.user" ) trigger = cprops . getProperty ( "postgresql.pg_standby.trigger" ) pg_archive = @config . getProperty ( "postgresql.archive" ) out = File . open ( @recovery_conf , "w" ) if is_streaming_replication pg_archivecleanup = @config . getProperty ( "postgresql.pg_archivecleanup" ) out . puts ( "# Specifies whether to start the server as a standby. In streaming replication," ) out . puts ( "# this parameter must to be set to on." ) out . puts ( "standby_mode = 'on'" ) out . puts out . puts ( "# Specifies a connection string which is used for the standby server to connect" ) out . puts ( "# with the primary." ) out . puts ( "primary_conninfo = 'host=#{master_host} port=#{master_port} user=#{master_user}'" ) out . puts out . puts ( "# Specifies a trigger file whose presence should cause streaming replication to" ) out . puts ( "# end (i.e., failover)." ) out . puts ( "trigger_file = '#{trigger}'" ) out . puts out . puts ( "# In SR, we only move the WAL file to PG, if asked." ) out . puts ( "restore_command = 'echo \"Restoring %f\"; mv #{pg_archive}/%f %p'" ) out . puts out . puts ( "# We also need to take care about removing not needed WAL files under SR." ) out . puts ( "archive_cleanup_command = '#{pg_archivecleanup} -d #{pg_archive} %r 2>>cleanup.log'" ) else out . puts ( "restore_command = '#{@pg_wal_restore} %f %p %r'" ) end out . close end
Generate recovery.conf so we can go online later.
Generate recovery . conf so we can go online later .
#out.puts("restore_command = '#{pg_standby} -l -d -s 2 -t #{trigger} #{pg_archive} %f %p %r 2>>standby.log'")  
master_host
master_port