The message "The database system is starting up." does not indicate an error. The reason it is at the FATAL level is so that it will always make it to the log, regardless of the setting of log_min_messages
:
http://www.postgresql.org/docs/9.1/interactive/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHEN
After the rsync, did you really run what you show?:
pgsql -c "select pg_stop_backup();";
Since there is, so far as I know, no pgsql
executable, that would leave the backup uncompleted, and the slave would never come out of recovery mode. On the other hand, maybe you really did run psql
, because otherwise I don't see how the slave would have logged such success messages as:
Log: consistent recovery state reached at 0/BF0000B0
and:
Log: streaming replication successfully connected to primary
Did you try connecting to the slave at this point? What happened?
The "Success. You can now start..." message you mention is generated by initdb
, which shouldn't be run as part of setting up a slave; so I think you may be confused about something there. I'm also concerned about these apparently conflicting statements:
The only ways I have restarted Postgres is through the service
postgresql-9.1 restart or /etc/init.d/postgresql-9.1 restart commands.
After I receive this error, I kill all processes and again try to
restart the database...
Did you try to stop the service through the service script? What happened? It might help in understanding the logs if you prefixed lines with more information. We use:
log_line_prefix = '[%m] %p %q<%u %d %r> '
The recovery.conf
script looks odd. Are you copying from the master's pg_xlog directory, the slave's active pg_xlog directory, or an archive directory?
Your first problem is that Putty/PSCP want to store the host key for each user for security reasons (stop Fred from storing a fake host key that can be used to con George into trusting a fake server). The -batch
option won't override that as it's seen as a flaw in the security process.
So it's fine when you run it interactively, as you can accept the key for your account. When you run it via SQL Agent, then it wants to store it for the user running the SQL Agent service.
If you are running SQL Agent under a 'normal' user account, then one way around this is to log in interactively with that account, run the pscp
command and accept the host key. This will then be stored for future runs.
The other option is to look at using another tool for the SCP functionality. Personally I'm a fan of winscp ( http://winscp.net/ ) for this. WinSCP allows you to specify the host key as part of the connection string (here is a PowerShell example - http://winscp.net/eng/docs/library#powershell ).
Best Answer
You invoke
psql
twice here. The first enters interctive mode as no stdin was supplied, no-f
filename parameter was supplied, and there's no-c
command string.So the script never gets to the second
psql
invocation. Put the parameters on one line.Additionally:
WITH (CSV, HEADER)
notCSV DELIMITER ','
{'SELECT * FROM myTable';}
is complete nonsense. Simply useCOPY mytable TO ...
or if you need a subquery, useCOPY (SELECT * FROM mytable) TO ...
\copy
notCOPY
(I'm assuming that
--%
stops Powershell from looking for Powershell flags and options in the rest of the command; I haven't seen it before).I think you're looking for something more like: