加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql 9.3.1 编译安装

发布时间:2020-12-13 17:08:52 所属栏目:百科 来源:网络整理
导读: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=64makemake inst
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中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读