First, the environment
VM virtual machine
NAME = "Ubuntu"
VERSION = "12.04.4 LTS, Precise Pangolin"
Second, the process
1. Install make, now do not install required.
# Apt-get install make
# Make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
This program built for i686-pc-linux-gnu
2. Get the source
But now we have an existing binary installation package, and depending on the method of installation of the system is given. http://www.postgresql.org/download/
Source code on the File Browser, or directly from the version control repository to obtain, is obtained from the git. Operations documentation with source code installed here. http://www.postgresql.org/docs/current/static/installation.html
Open look at the options page ubuntu what some say, http: //www.postgresql.org/download/linux/ubuntu/. A bunch of English probably meant to say Ubuntu already included by default PostgreSQL, now you can use apt-get to install, if pgsql version of Ubuntu you are not on the what you want, you can use PostgreSQL Apt warehouse to integrate the patch, then the following is the basic operation step more Apt related information, see wiki, https: //wiki.postgresql.org/wiki/Apt.
wiki says this team is PGDG support the maintenance of APT repository, they are committed to building PostgreSQL server packages as well as extensions and modules packages on several Debian / Ubuntu releases for all PostgreSQL versions supported. It is to give different distributions released PostgreSQL and related packages. Here is a quick start installation steps, according to wiki better.
Add the source, the update source
# Sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $ (lsb_release -cs) -pgdg main"> /etc/apt/sources.list.d/pgdg.list '
# Apt-get update
PS: This variable can get codenames
# Echo $ (lsb_release -cs)
# Cat /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
After updating good source, you can search for the various versions of postgresql, probably read, there are 8.2, the latest is 9.5
# Apt-cache search postgresql- | grep 'object-relational' | less
postgresql-9.1 - object-relational SQL database, version 9.1 server
postgresql-8.4 - object-relational SQL database, version 8.4 server
postgresql-8.2 - object-relational SQL database, version 8.2 server
postgresql-8.3 - object-relational SQL database, version 8.3 server
postgresql-9.0 - object-relational SQL database, version 9.0 server
postgresql-9.2 - object-relational SQL database, version 9.2 server
postgresql-9.3 - object-relational SQL database, version 9.3 server
postgresql-9.4 - object-relational SQL database, version 9.4 server
postgresql-9.5 - object-relational SQL database, version 9.5 server
Install wget and certificate update
# Sudo apt-get install wget ca-certificates
... Omitted ...
It is preparing to replace the ca-certificates 20111211 (using ... / ca-certificates_20141019ubuntu0.12.04.1_all.deb) ...
Extracting the file will be used for the replacement package ca-certificates ...
It is preparing to replace wget 1.13.4-2ubuntu1 (using ... / wget_1.13.4-2ubuntu1.2_i386.deb) ...
Extracting the package file to be used for replacement of wget ...
Processing triggers for man-db ...
Processing triggers for install-info ...
We are set ca-certificates (20141019ubuntu0.12.04.1) ...
Updating certificates in / etc / ssl / certs ... 38 added, 17 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
We are set wget (1.13.4-2ubuntu1.2) ...
# Wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Install PostgreSQL, being the first to install a 9.2 to practice hand
# Sudo apt-get install postgresql-9.2
Reading package lists ... Done
Building dependency tree package
Reading state information ... Done
The following extra packages will be installed:
libpq5 pgdg-keyring postgresql-client-9.2 postgresql-client-common postgresql-common ssl-cert
Recommendation installed packages:
oidentd ident-server locales-all postgresql-doc-9.2 openssl-blacklist
The following NEW packages will be installed:
libpq5 pgdg-keyring postgresql-9.2 postgresql-client-9.2 postgresql-client-common postgresql-common ssl-cert
0 packages upgraded, 7 newly installed packages, 0 to remove the package, there are 140 packages not upgraded.
4,663 kB need to download packages.
It will consume 22.6 MB additional space after decompression.
...... Omitted download, unzip process
We are set libpq5 (9.4.4-1.pgdg12.4 + 1) ...
We are set pgdg-keyring (2014.1) ...
Removing apt.postgresql.org key from trusted.gpg: OK
Importing apt.postgresql.org key: OK
We are set postgresql-client-common (169.pgdg12.4 + 1) ...
We are set postgresql-client-9.2 (9.2.13-1.pgdg12.4 + 1) ...
update-alternatives: use /usr/share/postgresql/9.2/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz), in automatic mode in.
We are set ssl-cert (1.0.28ubuntu0.1) ...
It is set postgresql-common (169.pgdg12.4 + 1) ...
Adding user postgres to group ssl-cert
Creating config file /etc/postgresql-common/createcluster.conf with new version
Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell / hunspell packages ...
Removing obsolete dictionary files:
* No PostgreSQL clusters exist; see "man pg_createcluster"
Being set postgresql-9.2 (9.2.13-1.pgdg12.4 + 1) ...
Creating new cluster 9.2 / main ...
update-alternatives: use /usr/share/postgresql/9.2/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz), in automatic mode in.
* Starting PostgreSQL 9.2 database server [OK]
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
4. Configure Remote Access
Just installed state after PostgreSQL should be, postgres user password on Ubuntu unknown, postgres password on the database is not set
If using root or allow sudo, you can directly enforce the postgres user login without knowing the password for postgres
root # su postgres
postgres $ psql
Enter "help" to get help.
postgres = #
(Non-root, allows the user to sudo, there is provided a Free secret) $ sudo -u postgres psql
Enter "help" to get help.
postgres = #
Once logged in to set up a password of SQL postgres
postgres # \ password postgres
Exit to find a directory, to modify two files, postgresql.conf and pg_hba.conf
# Find / -name postgresql.conf
# Cd /etc/postgresql/9.2/main/
environment pg_ctl.conf pg_hba.conf pg_ident.conf postgresql.conf start.conf
postgresql.conf monitor all IP, the default port, open the log collection, a new log every day, and many do not understand the parameters can be adjusted.
listen_addresses = '*' # what IP address (es) to listen on;
# Comma-separated list of addresses;
# Defaults to 'localhost'; use '*' for all
# (Change requires restart)
port = 5432 # (change requires restart)
logging_collector = on # Enable capturing of stderr and csvlog
# Into log files. Required to be on for
# (Change requires restart)
log_directory = 'pg_log' # directory where log files are written,
# Can be absolute or relative to PGDATA
log_filename = 'postgresql-% Y-% m-% d_% H% M% S.log' # log file name pattern,
# Can include strftime () escapes
log_truncate_on_rotation = off # If on, an existing log file with the
# Same name as the new log file will be
# Truncated rather than appended to.
# But such truncation only occurs on
# Time-driven rotation, not on restarts
# Or size-driven rotation. Default is
# Off, meaning append to existing files
# In all cases.
log_rotation_age = 1d # Automatic rotation of logfiles will
# Happen after that time. 0 disables.
log_rotation_size = 0 # Automatic rotation of logfiles will
# Happen after that much log output.
# 0 disables.
pg_hba.conf join their address, all 0.0.0.0/0
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.152.1/24 md5
Postgresql restart the service, and then set about pgAdminIII address, port, user name, password, you can successfully connect