Linux installs the PostgreSQL 9.4 database and starts the database

Source: Internet
Author: User
Tags http request postgresql centos


PostgreSQL is an object-relational database management system (ORDBMS) based on POSTGRES, Version 4.2, developed by the University of California, Berkeley computer department. Many of the concepts pioneered by Postgres appear in the commercial database for a long time. PostgreSQL is an open source successor to the original Berkeley code. It supports most of the SQL standards and offers many other modern features:
Complex queries
FOREIGN key
Trigger
Updatable views
Transactional integrity
Multi-version concurrency control

In addition, PostgreSQL can be extended in a number of ways, such as by adding new:
Data type
Function
Operator
Aggregate functions
Indexing method
Process language
In a personal view, PostgreSQL is the closest to Oracle in an Open-source database, and Oracle compatibility is good, and if you go to IoE, the database is a good choice

Operating system version
[Root@web103 ~]# More/etc/issue
CentOS release 5.9 (Final)
Kernel \ r \m
[Root@web103 ~]# Uname-a
Linux web103 2.6.18-348.el5 #1 SMP Tue 8 17:53:53 EST 2013 x86_64 x86_64 x86_64 gnu/linux
Download corresponding PostgreSQL corresponding RPM package
Because the operating system version is CentOS 5.9 of 64-bit Linux, so download the corresponding version of the PRM package, mainly download server,client,contrib,libs four packages
[root@web103 ~]# mkdir PG
[root@web103 ~]# CD PG
[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm
--2015-06-16 20:44:52--http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm
Resolving yum.postgresql.org ... 174.143.35.196, 2001:4800:1501:1::196
Connecting to yum.postgresql.org|174.143.35.196|:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:1807607 (1.7M) [Application/x-redhat-package-manager]
Saving to: ' postgresql94-9.4.4-1pgdg.rhel5.x86_64.rpm '

100%[========================================================================================================== =========&GT] 1,807,607 73.6k/s in 30s

2015-06-16 20:45:24 (58.1 kb/s)-' postgresql94-9.4.4-1pgdg.rhel5.x86_64.rpm ' saved [1807607/1807607]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm
--2015-06-16 20:45:35--http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/ postgresql94-server-9.4.4-1pgdg.rhel5.x86_64.rpm
Resolving yum.postgresql.org ... 174.143.35.196, 2001:4800:1501:1::196
Connecting to yum.postgresql.org|174.143.35.196|:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:6175991 (5.9M) [Application/x-redhat-package-manager]
Saving to: ' postgresql94-server-9.4.4-1pgdg.rhel5.x86_64.rpm '

100%[========================================================================================================== =========&GT] 6,175,991 58.5k/s in 2m 4s

2015-06-16 20:47:42 (48.6 kb/s)-' postgresql94-server-9.4.4-1pgdg.rhel5.x86_64.rpm ' saved [6175991/6175991]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/ postgresql94-contrib-9.4.4-1pgdg.rhel5.x86_64.rpm
--2015-06-16 20:47:51--http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/ postgresql94-contrib-9.4.4-1pgdg.rhel5.x86_64.rpm
Resolving yum.postgresql.org ... 174.143.35.196, 2001:4800:1501:1::196
Connecting to yum.postgresql.org|174.143.35.196|:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:664051 (648K) [Application/x-redhat-package-manager]
Saving to: ' postgresql94-contrib-9.4.4-1pgdg.rhel5.x86_64.rpm '

100%[========================================================================================================== =========&GT] 664,051 28.1k/s in 53s

2015-06-16 20:48:46 (12.3 kb/s)-' postgresql94-contrib-9.4.4-1pgdg.rhel5.x86_64.rpm ' saved [664051/664051]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm
--2015-06-16 20:51:10--http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm
Resolving yum.postgresql.org ... 174.143.35.196, 2001:4800:1501:1::196
Connecting to yum.postgresql.org|174.143.35.196|:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:233206 (228K) [Application/x-redhat-package-manager]
Saving to: ' postgresql94-libs-9.4.4-1pgdg.rhel5.x86_64.rpm '

100%[========================================================================================================== =========&GT] 233,206 70.3k/s in 3.2s

2015-06-16 20:51:16 (70.3 kb/s)-' postgresql94-libs-9.4.4-1pgdg.rhel5.x86_64.rpm ' saved [233206/233206]

[root@web103 pg]# ls
postgresql94-9.4.4-1pgdg.rhel5.x86_64.rpm postgresql94-libs-9.4.4-1pgdg.rhel5.x86_64.rpm
postgresql94-contrib-9.4.4-1pgdg.rhel5.x86_64.rpm postgresql94-server-9.4.4-1pgdg.rhel5.x86_64.rpm
Install PostgreSQL RPM Package
[root@web103 pg]# RPM-IVH *.rpm
Warning:postgresql94-9.4.4-1pgdg.rhel5.x86_64.rpm:header V3 DSA Signature:nokey, key ID 442df0f8
Preparing ... ########################################### [100%]
1:postgresql94-libs ########################################### [25%]
2:postgresql94 ########################################### [50%]
3:postgresql94-contrib ########################################### [75%]
4:postgresql94-server ########################################### [100%]
Create PostgreSQL Default Library
[root@web103 pg]# service postgresql-9.4 Initdb
Initializing database: [OK]
[Root@web103 data]# pwd
/var/lib/pgsql/9.4/data
[Root@web103 data]# ls-ltr
Total 120
-RW-------1 postgres postgres 21265 June 20:52 postgresql.conf
-RW-------1 postgres postgres June 20:52 postgresql.auto.conf
DRWX------3 Postgres postgres 4096 June 20:52 Pg_xlog
-RW-------1 postgres postgres 4 June 20:52 Pg_version
DRWX------2 postgres postgres 4096 June 20:52 Pg_twophase
DRWX------2 postgres postgres 4096 June 20:52 PG_TBLSPC
DRWX------2 postgres postgres 4096 June 20:52 Pg_subtrans
DRWX------2 postgres postgres 4096 June 20:52 Pg_snapshots
DRWX------2 postgres postgres 4096 June 20:52 pg_serial
DRWX------2 postgres postgres 4096 June 20:52 Pg_replslot
DRWX------4 Postgres postgres 4096 June 20:52 Pg_multixact
DRWX------4 Postgres postgres 4096 June 20:52 pg_logical
-RW-------1 postgres postgres 1636 June 20:52 pg_ident.conf
-RW-------1 postgres postgres 4224 June 20:52 pg_hba.conf
DRWX------2 postgres postgres 4096 June 20:52 Pg_dynshmem
DRWX------2 postgres postgres 4096 June 20:52 Pg_clog
DRWX------5 Postgres postgres 4096 June 20:52 Base
DRWX------2 postgres postgres 4096 June 21:16 Pg_log
DRWX------2 postgres postgres 4096 June 21:16 Global
-RW-------1 postgres postgres June 21:39 Postmaster.pid
-RW-------1 postgres postgres June 21:39 postmaster.opts
DRWX------2 postgres postgres 4096 June 21:39 Pg_stat
DRWX------2 postgres postgres 4096 June 21:39 pg_notify
DRWX------2 postgres postgres 4096 June 22:00 pg_stat_tmp
In addition, you can create the following two different ways
Initdb-d/var/lib/pgsql/9.4/data
Pg_ctl-d/var/lib/pgsql/9.4/data
Set PostgreSQL to boot automatically
[root@web103 pg]# chkconfig postgresql-9.4 on
[root@web103 pg]# chkconfig--list|grep Post
postgresql-9.4 0:off 1:off 2:on 3:on 4:on 5:on 6:off
View default Create PostgreSQL user
[root@web103 data]# More/etc/passwd|grep Post
Postgres:x:26:26:postgresql Server:/var/lib/pgsql:/bin/bash
Add PATH environment variable
-bash-3.2$echo "path= $PATH:/usr/pgsql-9.4/bin;export PATH" >>~/.bash_profile
Start the PostgreSQL database
--Method 1
-bash-3.2$ postgres-d/var/lib/pgsql/9.4/data
----OR
-bash-3.2$ postgres-d/var/lib/pgsql/9.4/data >~/pg.log 2>&1 &

Method 2
Pg_ctl start-l ~/pg.log-d/var/lib/pgsql/9.4/data
Here if Pgdata is configured in the environment variable, then-D can also not specify,-l for the specified log directory, recommend the use of Encapsulated Method 2 start PG

View PostgreSQL Process Information
[root@web103 data]# ps-ef|grep post|grep-v grep
Postgres 4432 1 0 21:39? 00:00:00/usr/pgsql-9.4/bin/postgres-d/var/lib/pgsql/9.4/data
Postgres 4433 4432 0 21:39? 00:00:00 Postgres:logger Process
Postgres 4435 4432 0 21:39? 00:00:00 Postgres:checkpointer Process
Postgres 4436 4432 0 21:39? 00:00:00 Postgres:writer Process
Postgres 4437 4432 0 21:39? 00:00:00 Postgres:wal Writer Process
Postgres 4438 4432 0 21:39? 00:00:00 postgres:autovacuum Launcher Process
Postgres 4439 4432 0 21:39? 00:00:00 postgres:stats Collector Process
Here you can see that PG is similar to Oracle, there are log processes, checkpoint processes, write processes, etc. (Specific later analysis)

Stop PostgreSQL Database
-bash-3.2$ Pg_ctl stop-d/var/lib/pgsql/9.4/data
Waiting for server to shut down ... done
Server stopped
-bash-3.2$ Ps-ef|grep post|grep-v grep
Root 6036 499 0 22:07 pts/0 00:00:00 su-postgres
Postgres 6037 6036 0 22:07 pts/0 00:00:00-bash
Postgres 6113 6037 0 22:08 pts/0 00:00:00 ps-ef
PostgreSQL Default Listening port
Further explanation of related configuration and access in subsequent chapters
[root@web103 pgsql]# Netstat-natp|grep Postgres
TCP 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN

Contact: Mobile (13429648788) QQ (107644445)
Link: http://www.xifenfei.com/5941.html

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.