Postgresql installation and common error handling

Source: Internet
Author: User
Tags postgresql version
Postgresql installation and common error handling I. Installation instructions recently, due to business needs, I abandoned the mysql database that I have been using and started to switch to the postgresql database. Why should I choose postgresql? It must be that postgresql is more powerful than mysql. For the advantages of postgresql, we will not go into details here. You can go to google. In this example

Postgresql installation and common error handling I. Installation instructions recently, due to business needs, I abandoned the mysql database that I have been using and started to switch to the postgresql database. Why should I choose postgresql? It must be that postgresql is more powerful than mysql. For the advantages of postgresql, we will not go into details here. You can go to google. In this example

Postgresql installation and common error handling I. Installation instructions

Recently, due to business needs, I abandoned the mysql database that I have been using and started to switch to the postgresql database. Why should I choose postgresql? It must be that postgresql is more powerful than mysql. For the advantages of postgresql, we will not go into details here. You can go to google.

The postgresql version installed in this example is 9.3.2 and the installation environment is a Centos-6.4-x64_64.

Ii. Installation

1. Download postgresql:

The installation method in this example is source code installation. You can download it at the official website: http://www.postgresql.org/ftp/source/v9.3.2/

2. decompress the file:

Tar-zxvf postgresql-9.3.2.tar.gz

3. Enter the extract directory and configure Parameters

Go to the unzip Directory: cd postgresql-9.3.2

Create installation directory: sudo mkdir/opt/postgresql-9.3.2 (depending on your habits)

Configure the installation parameters:./configure -- prefix =/opt/postgresql-9.3.2

4. Compile:

Make

Note: In this step, I believe many students may encounter some errors. If so, please refer to the section "3. Common Errors" below to solve them.

5. installation:

Sudo make install

6. create user groups and users:

Create user group: sudo group add postgresql

Create user: sudo useradd-gpostgresql postgresql

To facilitate management, you have created a postgresql user group and postgresql users. You can use postgresql users to manage postgresql databases in the future.

7. Create a database file storage directory and grant permissions to postgresql users:

Go to the database installation directory: [postgres @ zhu postgresql-9.3.2] $ cd/opt/postgresql-9.3.2

Create data directory: [postgres @ zhu postgresql-9.3.2] $ sudo mkdir data

Grant permissions to postgresql users: sudo chown postgresql. postgresql data

8. Add environment variables:

9. initialize the database directory:

First, switch to the user: su postgresql

Initialize data: [postgres @ zhu postgresql-9.3.2] bin/initdb-D data

10. Start the database:

Start via postmaster Script: postgresql installation and common error handling

[Postgres @ zhu postgresql-9.3.2] bin/postmaster-D/usr/local/pgsql/data

After the startup is successful, you can see the following prompt:


You can re-open a port and test it as a postgresql user.

However, the database can only be accessed locally at the current location. If other users are running the database, you need to continue with the following Configuration:

10. Configure the listening address and port:

[Postgres @ zhu postgresql-9.3.2] vi data/postgresql. conf
Modify the configuration as follows:
Listen_addresses = '*'
Port = 5432

That is, remove the Comment Number "#" And change "127.0.0.1" "*"
11. Allow Remote Host connection:
[Postgres @ zhu postgresql-9.3.2] vi data/pg_hba.conf
Tianjia configures host all 0.0.0.0/0 trust as follows. For details, refer:


Note:

(1 ). "trust" and "password" are used for postgresql database login verification. "trust" indicates trust, that is, you do not need to enter a password (even if you have a password ), "password" indicates that a password is required. (2 ). host all 127.0.0.1/31 trust indicates that you do not need to enter a password to connect to the local database. (3 ). host all 0.0.0.0/0 all hosts need to enter a password (if any) to connect to the database (4 ). of course, the result of these two combinations is: trust in the Local Link (no password is required), and enter the password 12 for non-local connections. modify the firewall and open port 5432:

Sudo vim/etc/sysconfig/iptables

-A input-p tcp-m tcp -- dport 5432-j ACCEPT

Restart firewall: sudo service iptables restart

12. In the postgresql database, add a password for the previously created postgresql User:

Run the psql command to go To the postgresql database console and run:

Alter user postgres PASSWORD 'password ';

13. Close the postgresql database and restart it to make the changed configuration take effect:

The following operations are performed using postgresql's pg_ctl tool:

Close postgresql database: pg_ctl stop-m fast

Start postgresql database: pg_ctl start

In this case, you can log on to the system through a remote host.

So far, a complete postgresql database has been installed. you can log on to postgresql through a remote host and enter the password as a postgresql user!

Postgresql installation and common error handling

Iii. Common Errors:

1. Common installation errors:

(1 ).

Configure: error: readline library notfound
If you have readline already installed, see config. log for detailson
Failure. It is possible the compiler isnt lookingin the proper directory.
Use -- without-readline to disable readlinesupport.

If the preceding error occurs, your system lacks the readline library. Enter:

Rpm-qa | grep readline

If the prompt is: readline-6.0-4.el6.x86_64

If your computer lacks the readline-devel library, you just need to install readline-devel:
Yum-y install readline-devel
Again rpm-qa | grep readline
Tip:
Readline-devel-6.0-4.el6.x86_64
Readline-6.0-4.el6.x86_64
This indicates that readline-devel is successfully installed.

(2 ).

Checking for inflate in-lz... no configure: error: zlib library not found If you have zlib already installed, see config. log for details on the failure. it is possible the compiler isn't looking in the proper directory. use -- without-zlib to disable zlib support.
This error indicates that your system lacks the zlib library, input: rpm-qa | grep zlib, if the following prompt appears: zlib-1.2.3-29.el6.x86_64 zlib-1.2.3-29.el6.i686 jzlib-1.0.7-7.5.el6.x86_64 is described, your computer lacks the zlib-devel library, install it: yum install zlib-devel; then, then rpm-aq | grep zlib zlib-1.2.3-29.el6.x86_64 zlib-1.2.3-29.el6.i686 jzlib-1.0.7-7.5.el6.x86_64 zlib-devel-1.2.3-29.el6.x86_64 description zlib-devel installation successful. If your system and above libraries are missing, install them all.

2. Common Database Connection errors:

(1 ).

Cocould not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "95.110.201.74" and accepting
TCP/IP connections on port 5300? "

If the above error message appears, it usually occurs when the remote host is connected. Cause of error 5432: the port number is rejected or the postgresql database does not listen to connection requests from hosts other than the current host. In this case, check whether the operations in the following two steps are correct:

A. Enable the firewall to open port 5432:

Sudo vim/etc/sysconfig/iptables

-A input-p tcp-m tcp -- dport 5432-j ACCEPT

Restart firewall: sudo service iptables restart

B. modify the configuration file $ POSTGRESQL_HOME/data/postgresql. conf:

Modify the configuration as follows:
Listen_addresses = '*'
Port = 5432

(2) If you access the database locally, the following prompt appears:

FATAL: no pg-hba.conf entry for host "xxxxxxxx", user "xxx" database "xxxxx "......

It means that local access is set to a non-trust mode, check whether the $ export SQL _home/data/pg-hba.conf configuration file has the following configuration information:

Host all 127.0.0.1/32 trust

For details about the configuration, refer to Section 2. 11.

Postgresql installation and common error handling

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.