Long time do not write things, have been looking at some open source things, the following paste on Linux installation configuration postgres and use Dblink operation reference for readers and their future reference:
1. Download Source: postgresql-9.3.2.tar.gz
2. Create Postgres cluster groups and users:
Groupadd Postgres
Useradd postgres-d/home/postgres-g Postgres
Mkdir-p/usr/local/pgsql
Mkdir-p/use/local/pgsql/data
Chown-r Postgres.postgres/usr/local/pgsql
passwd Postgres
Su-postgres
Cd
VI Bash_profile
Export Pghome=/usr/local/pgsql
Export Pgdata=/usr/local/pgsql/data
Export path= $PATH:/usr/local/pgsql/bin
. . bash_profile
3. Transfer the source file to the database server:
/usr/local/pgsql/postgresql-9.3.2.tar.gz
Cd/usr/local/pgsql
Tar zxf postgresql-9.3.2.tar.gz
4. Configure and install the database:
cd/usr/local/plsql/postgresql-9.3.2
Configure
Or
Configure--prefix=/usr/local/pgsql--with-perl--with-python
--Note:
1) Configure process, such as error: Configure:error:readline library not found, is actually readline-devel not installed, yum-y install Readline-devel can be installed.
2) Configure process, such as error: Configure:error:zlib not installed, in fact, Zlib-delvel is not installed, yum-y install Zlib-delvel installation can be.
3) Configure process, such as error: Configure:error:header file <python.h>is required, in fact, Pyhton-delvel is not installed, yum-y install Python-delvel can be installed.
Make
Su-
Make install
5. Initialize the database:
/usr/local/pgsql/bin/initdb-d/usr/local/pgsql/data
6. Configuration parameter file:
Cd/usr/local/pgsql/data
VI postgresql.conf
--Listening and port
7. Configure login Security rules:
VI pg_hba.conf
8. Login Postgres and Change Password:
Psql Postgres Postgres
Alter user postgres password ' test ';
9, Configuration Dblink:
Cd/usr/local/pgsql/postgresql-9.3.2/contrib/dblink
Make
Su
Make install
Psql Postgres Postgres
Create extension Dblink;
SELECT * from Pg_extension;
10. Create and use Dblink
Psql test test
Select Dblink_connect (' Test_dblink ', ' dbname=postgres host=192.168.109.10 port=1921 user=postgres password=test ');
SELECT * from Dblink (' Test_dblink ', ' Select c1,c3 from TTT ') as T1 (C1 integer,c2 varchar);
Select Dblink_disconnect (' Test_dblink ');
Select dblink_get_connections ();
Linux installation configuration postgres and using Dblink