----------------------------------------------------------------------------------------
cat archive_wal.sh
#!/bin/bash
# Script de copie des WALs en local et vers le serveur esclave
# Usage:
# archive_command = '/var/lib/pgsql/archive_wal.sh %p %f'
FILE=$1
FILE_NAME=$2
INSTANCE=crm03
SLAVE=rtdkm1ply51.hosting.as
DATA=/u01/app/postgres/data/${INSTANCE}
#BARMAN=rtdka1pql69.dktetrix.net
#BARMAN_DIR=/barman/rtdka1pql51_mydkt01/incoming/
#TBY20160316::BARMAN=rtdkm1ply51.hosting.as
BARMAN=rtdkm1pgs51.hosting.as
BARMAN_DIR=/barman/rtdkm1pgs51_${INSTANCE}/incoming/
LOG=/tmp/rsync-archives.log
ARCHDIR=/u01/app/postgres/recovery/archive/${INSTANCE}
ARCHDIRDIST=/u01/app/postgres/recovery/archive/${INSTANCE}
date > $LOG
/usr/bin/rsync -a $DATA/$FILE $ARCHDIR/$FILE_NAME
if [ $? -ne 0 ]
then
echo "Archiving error of the WAL $FILE on the master server" >> $LOG 2>&1
exit 1
fi
/usr/bin/rsync $FILE postgres@$SLAVE:$ARCHDIRDIST/$FILE_NAME
if [ $? -ne 0 ]
then
echo "Archiving error of the WAL $FILE on the slace server" >> $LOG 2>&1
exit 1
fi
/usr/bin/rsync $FILE barman@$BARMAN:$BARMAN_DIR/$FILE_NAME
if [ $? -ne 0 ]
then
echo "Archiving error of the WAL $FILE on the BARMAN server $BARMAN" >> $LOG 2>&1
exit 1
fi
-------------------------------------------------------------------------------------------
pg_switch_xlog
手动强制切换段文件