PostgreSQL Stream 模式搭建
PostgreSQL Stream 模式搭建
1、編譯安裝
yum install -y gcc gcc-c++ automake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers bison* glib* flex readline readline-devel apr apr-util apr-develrzsz sysstat e4fsprogs ntp readline-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel flex bison
tar –jxvf postgresql-9.2.1.tar.bz2
cd postgresql-9.2.1
./configure --prefix=/usr/local/pgsql
gmake world
gmake install-world
2、建立使用者,授權
#建立資料庫目錄
mkdir /data
#建立使用者 postgres ,並授權
useradd postgres
chown postgres.postgres /data
3、配置環境變數
#切換到 postgres 使用者
su postgres
#為其配置環境變數:
vim ~postgres/.bash_profile
PGLIB=/usr/local/pgsql/lib
PGDATA=/data
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PGLIB PGDATA PATH MANPATH
export PGDATA=/data
4、初始化資料庫
initdb -D $PGDATA
5、Master 設定檔修改
vim pg_hba.conf
host all all 192.168.2.4/32 trust
host all postgres 192.168.2.4/32 trust
vim postgres.conf
listen_addresses='*'
wal_level = 'hot_standby'
max_wal_senders = 3
wal_keep_segments = 16 # 80 GB required on pg_xlog
cp /usr/local/pgsql/share/recovery.conf.sample /data/recovery.cone
vim reconver.conf
standby_mode = on
primary_conninfo = 'host=master port=5433 user=postgres' #從節點資訊
6、產生備庫執行個體
[postgres@localhost data]$pg_ctl –D $PGDATA -p 5432
傳送資料檔案到slave
在備庫執行
[postgres@localhost data]$pg_basebackup -D $PGDATA -Fp -Xs -v -h master -p 5432 -U postgres
7、Slave 設定檔修改
[postgres@localhost data]$ vim postgresql.conf
注意刪除 "#"
hot_standby = on
vim reconver.conf
standby_mode = on
primary_conninfo = 'host=master port=5432 user=postgres' #主節點資訊
8、啟動主從資料庫
pg_ctl –D $PGDATA
master
[postgres@localhost data]$ ps -ef |grep postgres |grep sender
postgres 12021 10924 0 14:37 ? 00:00:00 postgres: wal sender process postgres 172.16.0.132(33427) streaming 0/3036838
slave
[postgres@localhost data]$ ps -ef |grep postgres |grep recover
postgres 5479 5471 0 17:24 ? 00:00:00 postgres: startup process recovering 00000002000000000000000D
注意:這個時候slave從master同步資料,但是slave 是唯讀。
------------------------------------華麗麗的分割線------------------------------------
CentOS 6.3環境下yum安裝PostgreSQL 9.3
PostgreSQL緩衝詳述
Windows平台編譯 PostgreSQL
Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)環境的配置與安裝
Ubuntu上的phppgAdmin安裝及配置
CentOS平台下安裝PostgreSQL9.3
PostgreSQL配置Streaming Replication叢集
如何在CentOS 7/6.5/6.4 下安裝PostgreSQL 9.3 與 phpPgAdmin
------------------------------------華麗麗的分割線------------------------------------
PostgreSQL 的詳細介紹:請點這裡
PostgreSQL 的:請點這裡
本文永久更新連結地址: