commitlog broken after standby setup with pg_basebackup I'm trying to replicate a database with pg_basebackup in order to use it as standby server. But when I'm trying to start up PostgreSQL I get the following errors and the server shuts down again:

2016-08-09 15:53:38 CEST [10369]: [1-1] [postgres: [local]] FATAL:  the database system is starting up
2016-08-09 15:53:39 CEST [10372]: [1-1] [postgres: [local]] FATAL:  the database system is starting up
2016-08-09 15:53:39 CEST [10375]: [1-1] [postgres: [local]] FATAL:  the database system is starting up
2016-08-09 15:53:40 CEST [10378]: [1-1] [postgres: [local]] FATAL:  the database system is starting up
2016-08-09 15:53:40 CEST [10361]: [4-1] [: ] LOG:  redo starts at 11/188CBA38
2016-08-09 15:53:40 CEST [10361]: [5-1] [: ] FATAL:  could not access status of transaction 4809883
2016-08-09 15:53:40 CEST [10361]: [6-1] [: ] DETAIL:  Could not read from file "pg_clog/0004" at offset 147456: Success.
2016-08-09 15:53:40 CEST [10361]: [7-1] [: ] CONTEXT:  xlog redo Transaction/COMMIT: 2016-08-09 15:41:25.947996+02
2016-08-09 15:53:40 CEST [10359]: [3-1] [: ] LOG:  startup process (PID 10361) exited with exit code 1


I call pg_basebackup like this 

sudo -u postgres pg_basebackup -h [server] -D [dbdir] -U replicator -v -P


My recovery.conf Looks like this 

standby_mode = 'on'
primary_conninfo = 'host=[host] port=[port] user=replicator password=[password] sslmode=require'
trigger_file = '/tmp/postgresql.trigger'


When I'm trying to follow this solution I'm getting the error message 

ERROR:  requested WAL segment 0000000100000010000000EF has already been removed


how can I avoid the broken clog file in the first place?

i'm using PostgreSQL 9.5.3
This probably happens because the master doesn't keep the wal segements long enough so they are deleted before your base backup completes. You can use the option --xlog-method=stream with pg_basebackup to tell it to also stream the wal while making the backup. This way you will have all the wall segments the backup needs to start succesfully.