postgresql 9.3.1 编译安装 1 编译、安装 tar -xvf postgresql-9.3.1.tar cd postgresql-9.3.1 ./configure --prefix=/opt/soft/postgresql-9.3.1/ --with-perl --with-python --with-blocksize=32 --with-wal-blocksize=32 --with-wal-segsize=64 make make install 2 创建用户及组 groupadd postgres useradd -g postgres postgres passwd postgres 3 环境设置 mkdir /usr/local/pgsql/data chown postgres:postgres -R /usr/local/pgsql/ su - postgres vi .bash_profile 添加: export PGHOME=/usr/local/pgsql export PGDATA=$PGHOME/data export PATH=$PATH:$HOME/bin:$PGHOME/bin $source .bash_profile 4 初始化数据库 $initdb -D $PGDATA 5 启动postgres数据库 pg_ctl -D /usr/local/pgsql/data start 6 系统服务配置及开机自动启动 cd /opt/soft/postgresql-9.3.1/contrib/start-scripts cp linux /etc/init.d/postgresql #chmod u+x /etc/init.d/postgresql #service postgresql status--(start | stop) 7 修改postgres数据库为归档模式 vi postgresql.conf wal_level = archive # - Archiving - archive_mode = on # allows archiving to be done # (change requires restart) archive_command = 'cp %p /usr/local/pgsql/archive/%f' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' #archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disables # - Archiving - archive_mode = on # allows archiving to be done # (change requires restart) archive_command = 'cp %p /usr/local/pgsql/archive/%f' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' #archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disables ##切换归档 select pg_switch_xlog(); 这个时候我们到归档日志的目录下去查看有没有归档日志生成 [09:39:25 postgres()@kiwi archive]$ ls 000000010000000000000001其中archive_command中%p会自动识别为WAL目录,你不用管,%f你也不用管。这个archive_command在什么时候执行呢,即Postgresql在每次WAL日志16MB段满的时候才执行,即把其拷贝到/home/postgres/archive中.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。