zoukankan      html  css  js  c++  java
  • PostgreSQL 开启归档

    修改postgresql.conf

    archive_mode =on
    %p = path of file to archive
    %f = file name only

    archive_command ='cp %p /u01/pgsql/archive/pg_%f'

    重启postgresql

    pg_ctl stop

    pg_ctl start

    查看归档

    [postgres@redis01 archive]$ ls -lrt
    total 32772
    -rw------- 1 postgres postgres 16777216 Sep 22 18:49 pg_000000010000000000000001
    -rw------- 1 postgres postgres 16777216 Sep 22 18:50 pg_000000010000000000000002
    -rw------- 1 postgres postgres 329 Sep 22 18:50 pg_000000010000000000000002.00000060.backup
    [postgres@redis01 archive]$ pwd
    /u01/pgsql/archive

    command 使用逻辑运算符

    1. 命令1 && 命令2 命令1执行成功后才会执行命令2
    2. 命令1 || 命令2 命令1执行失败后才会执行命令2
      每天生成一个归档目录
    archive_command = 'DIR=/u01/pgsql/archive/`date +%F`; sudo test ! -d $DIR && sudo mkdir $DIR; sudo test ! -f $DIR/%f && sudo cp %p $DIR/%f'
    

    查看归档设置

    postgres=# select name,setting from pg_settings where name like 'archive%' or name = 'wal_level';
          name       |            setting            
    -----------------+--------------------------------
     archive_command | cp %p /u01/pgsql/archive/pg_%f
     archive_mode    | on
     archive_timeout | 0
     wal_level       | replica
    

    转:https://www.cnblogs.com/omsql/p/11568700.html

  • 相关阅读:
    Python--面向对象编程(2)
    Python--面向对象编程(1)
    Python--常用模块
    Python--函数
    Hadoop综合大作业
    hive基本操作与应用
    MapReduce作业
    熟悉HBase基本操作
    熟悉常用的HDFS操作
    爬虫大作业(对电影的爬取)
  • 原文地址:https://www.cnblogs.com/caidingyu/p/12919593.html
Copyright © 2011-2022 走看看