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. Compile and install
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. New user, authorized
#创建数据库目录 mkdir/data# Create a user postgres and authorize Useradd Postgreschown Postgres.postgres/data
3. Configure Environment variables
#切换到 postgres user 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. Initialize the database
Initdb-d $PGDATA
5, Master configuration file modification
Vim pg_hba.conf
Host 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 = +-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. Create a Standby instance
[[email protected] data] $pg _ctl–d $PGDATA-P 5432
Transferring data files to slave
In the Standby library execution
[[email protected] data] $PG _basebackup-d $PGDATA-fp-xs-v-H master-p 5432-u Postgres
7. Slave Configuration File Modification
[Email protected] data]$ vim postgresql.conf
Note Delete "#"
Hot_standby = on vim Reconver.confstandby_mode = Onprimary_conninfo = ' host=master port=5432 user=postgres ' #主节点信息
8. Start the master-slave database
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
Note: This time slave synchronizes data from master, but slave is read-only.
This article is from the "World" blog, make sure to keep this source http://xiajie.blog.51cto.com/6044823/1662222
PostgreSQL Stream Mode Setup