Linux installation configuration postgres and use Dblink

Source: Internet
Author: User
Tags postgresql psql readline

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.