postgresql-Installation 9.2

Source: Internet
Author: User
Tags postgresql psql



First, the environment



VM Virtual Machines


NAME="Ubuntu"
VERSION="12.04.4 LTS, Precise Pangolin"


Second, the process



1. Install make and do not load now.


 
# 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
PARTICULAR PURPOSE.

This program built for i686-pc-linux-gnu

2. Get the source code



But now there is a ready-made binary installation package, and the installation method is given according to different systems. http://www.postgresql.org/download/



Source code on file browser, or directly from the version control repository, is obtained from Git. The operating documentation for the source installation is here. Http://www.postgresql.org/docs/current/static/installation.html



Open the page that looks at the Ubuntu options and say something, http://www.postgresql.org/download/linux/ubuntu/. A bunch of English probably means that Ubuntu already contains PostgreSQL by default and can now be installed with Apt-get, if your Ubuntu pgsql version is not what you want, you can use the PostgreSQL Apt repository to integrate patches, Then here is the basic procedure, more Apt related information see wiki,https://wiki.postgresql.org/wiki/apt.



Wiki is said to be PGDG this group in support of maintaining apt repository, they are committed building PostgreSQL server packages as well as extensions and modules packages on Several Debian/ubuntu releases for all PostgreSQL versions supported. is to release PostgreSQL and its associated packages to different distributions. Here's a quick start installation step, just click on the wiki.



3. Installation



Add source, 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 the version code
# echo $(lsb_release -cs)
Precis
# cat /etc/apt/sources.list.d/pgdg.list
Deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main


After updating the source, you can search for each version of PostgreSQL, probably looked at the next, 8.2 also have, 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 update wget and certificates


 # sudoApt-getInstall wgetca-Certificates
... Omitted...
Preparing to replace Ca-certificates 20111211 (using .../ca-certificates_20141019ubuntu0.12.04.1_all.deb) ...
Unpacking the package file that will be used for replacement ca-certificates ...
Preparing to replace wget 1.13.4-2ubuntu1 (using .../wget_1.13.4-2ubuntu1.2_i386.deb) ...
Unpacking the package file that will be used for replacement wget ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Setting Ca-certificates (20141019ubuntu0.12.04.1) ...
Updating Certificates In/etc/ssl/certs ... added, removed; Done.
Running Hooks In/etc/ca-certificates/update.d....done.
Setting wget (1.13.4-2ubuntu1.2) ... # wget--quiet-o-https://WWW.POSTGRESQL.ORG/MEDIA/KEYS/ACCC4CF8.ASC | sudo apt-key add- Ok 


Install PostgreSQL for the moment and put a 9.2来 practiced hand


# sudo apt-get install postgresql-9.2
Reading list of packages... done
Analyzing the dependency tree of the package
Reading status information... done
The following additional packages will be installed:
  Libpq5 pgdg-keyring postgresql-client-9.2 postgresql-client-common postgresql-common ssl-cert
Recommended packages to install:
  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
Upgraded 0 packages, 7 new packages installed, 0 packages to uninstall, and 140 packages not upgraded.
Need to download the 4,663 kB package.
After decompressing, it consumes 22.6 MB of extra space.
...
...omit download, decompression process
...
Setting up libpq5 (9.4.4-1.pgdg12.4+1) ...
Setting up pgdg-keyring (2014.1) ...
Removing apt.postgresql.org key from trusted.gpg: OK
Importing apt.postgresql.org key: OK
Setting postgresql-client-common (169.pgdg12.4+1) ...
Setting 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.
Setting up ssl-cert (1.0.28ubuntu0.1) ...
Setting 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...
  En_us
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting postgresql-9.2 (9.2.13-1.pgdg12.4+1)...
Creating new cluster 9.2/main ...
  Config /etc/postgresql/9.2/main
  Data /var/lib/postgresql/9.2/main
  Locale zh_CN.UTF-8
  Port 5432
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



PostgreSQL just installed after the status should be, Ubuntu postgres user password is unknown, the postgres password on the database is not set



If you use root or allow sudo, you can directly force the Postgres user to log in without needing to know the Postgres password


Root # su postgres
Postgres $ psql
Psql (9.2.13)
Type "help" to get help information.

Postgres=#
(non-root, allowing sudo users, here is a secret) $ sudo -u postgres psql
Psql (9.2.13)
Type "help" to get help information.

Postgres=# 


After logging in, set a password for SQL Postgres


Postgres#\password Postgres


Exit to find a directory, to modify two files,postgresql.conf and pg_hba.conf


 
# find / -name postgresql.conf
/etc/postgresql/9.2/main/postgresql.conf
# cd /etc/postgresql/9.2/main/
# l
environment  pg_ctl.conf  pg_hba.conf  pg_ident.conf  postgresql.conf  start.conf


Postgresql.conf listen to all IP, default port, open log collection, a new log every day, there are many 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
                                        # csvlogs.
                                        # (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 add their own 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


Restart the PostgreSQL service, and then use PGADMINIII to set the address, port, user name, password, you can successfully connect






postgresql-Installation 9.2


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.