postgresql 9.3.1 编译安装

前端之家收集整理的这篇文章主要介绍了postgresql 9.3.1 编译安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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中. 原文链接:https://www.f2er.com/postgresql/194661.html

猜你在找的Postgre SQL相关文章