標籤:stream linux postgres 複製
650) this.width=650;" alt="postgresql-9.2.1.tar.bz2" class="editor-attachment" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" />
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 worldgmake install-world
2、建立使用者,授權
#建立資料庫目錄 mkdir /data#建立使用者 postgres ,並授權 useradd postgreschown postgres.postgres /data
3、配置環境變數
#切換到 postgres 使用者su postgres #為其配置環境變數:vim ~postgres/.bash_profilePGLIB=/usr/local/pgsql/libPGDATA=/dataPATH=$PATH:/usr/local/pgsql/binMANPATH=$MANPATH:/usr/local/pgsql/manexport PGLIB PGDATA PATH MANPATHexport 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.conflisten_addresses=‘*‘wal_level = ‘hot_standby‘max_wal_senders = 3wal_keep_segments = 16 # 80 GB required on pg_xlogcp /usr/local/pgsql/share/recovery.conf.sample /data/recovery.conevim reconver.confstandby_mode = onprimary_conninfo = ‘host=master port=5433 user=postgres‘ #從節點資訊
6、產生備庫執行個體
[[email protected] data]$pg_ctl –D $PGDATA -p 5432
傳送資料檔案到slave
在備庫執行
[[email protected] data]$pg_basebackup -D $PGDATA -Fp -Xs -v -h master -p 5432 -U postgres
7、Slave 設定檔修改
[[email protected] data]$ vim postgresql.conf
注意刪除 "#"
hot_standby = on vim reconver.confstandby_mode = onprimary_conninfo = ‘host=master port=5432 user=postgres‘ #主節點資訊
8、啟動主從資料庫
pg_ctl –D $PGDATA
master
[[email protected] data]$ ps -ef |grep postgres |grep senderpostgres 12021 10924 0 14:37 ? 00:00:00 postgres: wal sender process postgres 172.16.0.132(33427) streaming 0/3036838
slave
[[email protected] data]$ ps -ef |grep postgres |grep recover postgres 5479 5471 0 17:24 ? 00:00:00 postgres: startup process recovering 00000002000000000000000D
注意:這個時候slave從master同步資料,但是slave 是唯讀。
本文出自 “World” 部落格,請務必保留此出處http://xiajie.blog.51cto.com/6044823/1662222
postgresql stream 模式搭建