您的位置:首页 > 其它

postgres修改归档模式

2016-09-08 12:26 260 查看
步骤一:修改postgresql的配置文件(postgresql.conf)
           wal_level=hot_standby
           archive_mode =on 
           archive_command ='DATE=`date +%Y%m%d`;DIR="/home/postgres/arch/$DATE";(test -d $DIR || mkdir -p $DIR)&& cp %p $DIR/%f'
           ps:%p 是指相对路径  %f是指文件名
步骤二:创建归档路径
          mkdir  -p /home/postgres/arch
          chown -R postgres:postgres /home/postgres/arch
步骤三:重启数据库
步骤四:验证归档是否正常
          postgres=# checkpoint;
                            CHECKPOINT
           postgres=# select pg_switch_xlog();
             pg_switch_xlog 
             ----------------
             1/760000E8
             (1 row)
          postgres@ubuntu:~$ cd /home/postgres/data/data_1999/arch/
          postgres@ubuntu:~/data/data_1999/arch$ ls
            20150603
          postgres@ubuntu:~/data/data_1999/arch$ cd 20150603/
           postgres@ubuntu:~/data/data_1999/arch/20150603$ ls
           000000010000000100000074  000000010000000100000075  000000010000000100000076

转自:http://blog.itpub.net/30158401/viewspace-1683636/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: