一、linux版本信息
[root@localhost /]# cat /proc/version
Linux version 3.10.0-229.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Fri Mar 6 11:36:42 UTC 2015
二、安装postgresql
[root@localhost /]# yum -y install postgresql postgresql-server
Loaded plugins: fastestmirror
http://mirrors.163.com/centos/7.1.1503/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.163.com/centos/7.1.1503/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
http://ftp.sjtu.edu.cn/centos/7.1.1503/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://ftp.sjtu.edu.cn/centos/7.1.1503/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 99 kB 00:00:00
updates/7/x86_64/primary_db FAILED ] 0.0 B/s | 99 kB --:--:-- ETA
http://mirror.bit.edu.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(2/4): base/7/x86_64/group_gz | 154 kB 00:00:05
(3/4): base/7/x86_64/primary_db | 5.1 MB 00:00:08
updates/7/x86_64/primary_db FAILED
http://mirrors.zju.edu.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
updates/7/x86_64/primary_db FAILED
http://mirrors.skyshe.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
updates/7/x86_64/primary_db FAILED
http://mirrors.opencas.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
updates/7/x86_64/primary_db FAILED
http://mirrors.sina.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
updates/7/x86_64/primary_db FAILED
http://centos.ustc.edu.cn/centos/7.1.1503/updates/x86_64/repodata/21eb6e55833d648c9b5140c80b6edbcbe26b0c50bd203f06b6a5a3c3cc4a80b6-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(4/4): updates/7/x86_64/primary_db | 4.0 MB 00:00:02
Determining fastest mirrors
* base: ftp.sjtu.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package postgresql.x86_64 0:9.2.13-1.el7_1 will be installed
--> Processing Dependency: postgresql-libs(x86-64) = 9.2.13-1.el7_1 for package: postgresql-9.2.13-1.el7_1.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-9.2.13-1.el7_1.x86_64
---> Package postgresql-server.x86_64 0:9.2.13-1.el7_1 will be installed
--> Running transaction check
---> Package postgresql-libs.x86_64 0:9.2.13-1.el7_1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================
Installing:
postgresql x86_64 9.2.13-1.el7_1 updates 3.0 M
postgresql-server x86_64 9.2.13-1.el7_1 updates 3.8 M
Installing for dependencies:
postgresql-libs x86_64 9.2.13-1.el7_1 updates 230 k
Transaction Summary
==============================================================================================================================================
Install 2 Packages (+1 Dependent package)
Total download size: 7.0 M
Installed size: 33 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/postgresql-libs-9.2.13-1.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for postgresql-libs-9.2.13-1.el7_1.x86_64.rpm is not installed
(1/3): postgresql-libs-9.2.13-1.el7_1.x86_64.rpm | 230 kB 00:00:05
(2/3): postgresql-server-9.2.13-1.el7_1.x86_64.rpm | 3.8 MB 00:00:08
(3/3): postgresql-9.2.13-1.el7_1.x86_64.rpm | 3.0 MB 00:00:10
----------------------------------------------------------------------------------------------------------------------------------------------
Total 694 kB/s | 7.0 MB 00:00:10
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql-libs-9.2.13-1.el7_1.x86_64 1/3
Installing : postgresql-9.2.13-1.el7_1.x86_64 2/3
Installing : postgresql-server-9.2.13-1.el7_1.x86_64 3/3
Verifying : postgresql-9.2.13-1.el7_1.x86_64 1/3
Verifying : postgresql-libs-9.2.13-1.el7_1.x86_64 2/3
Verifying : postgresql-server-9.2.13-1.el7_1.x86_64 3/3
Installed:
postgresql.x86_64 0:9.2.13-1.el7_1 postgresql-server.x86_64 0:9.2.13-1.el7_1
Dependency Installed:
postgresql-libs.x86_64 0:9.2.13-1.el7_1
Complete!
三、初始化数据库
[root@localhost /]# /usr/bin/postgresql-setup initdb
Initializing database ... OK
四、启动并查看
[root@localhost /]# systemctl start postgresql.service
[root@localhost /]# netstat -tpnl |grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 19036/postgres
tcp6 0 0 ::1:5432 :::* LISTEN 19036/postgres
五、用postgres用户登录
[root@localhost /]# su postgres
bash-4.2$ psql -U postgres
psql (9.2.13)
Type "help" for help.
postgres=#