CentOS 安装PostgreSQL 9.1
PostgreSQL通常也简称Postgres,是一个关系型数据库管理系统,适用于各种Linux操作系统、Windows、Solaris、BSD和Mac OS X。PostgreSQL遵循PostgreSQL许可,是一个开源软件。PostgreSQL由PostgreSQL全球开发组开发,由极少数的公司志愿组成并进行监督管理,这些公司有红帽、EnterpriseDB等。
PostgreSQL的知名度越来越大,这是理所当然的:它是如此可靠、高效。与传统企业级关系型数据库相比,PostgreSQL完全基于社区驱动,有着丰富的工具和文档,形成了一个完善的生态系统。
下面记录的是CentOS上安装PostgreSQL 9.1的过程:
1.添加PosgreSQL Yum Repository,访问http://yum.pgrpms.org/reporpms/repoview/letter_p.group.html,下载并安装和当前系统对应的rpm文件。
[root@SNDA-192-168-15-161 src]# wget http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm
--2012-08-25 16:56:19-- http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm
Resolving yum.pgrpms.org... 98.129.198.114
Connecting to yum.pgrpms.org|98.129.198.114|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5124 (5.0K) [application/x-redhat-package-manager]
Saving to: “pgdg-centos91-9.1-4.noarch.rpmâ€
100%[======================================>] 5,124 18.7K/s in 0.3s
2012-08-25 16:56:19 (18.7 KB/s) - “pgdg-centos91-9.1-4.noarch.rpmâ€
[root@SNDA-192-168-15-161 src]# ls -l
total 17644
drwxr-xr-x 9 1001 1001 4096 Aug 18 19:47 nginx-1.2.1
-rw-r--r-- 1 root root 718161 Jun 5 22:10 nginx-1.2.1.tar.gz
drwxr-xr-x 8 root root 4096 Aug 18 19:44 nginx_tcp_proxy_module
-rw-r--r-- 1 root root 4164 Dec 19 2011 nodejs-stable-release.noarch.rpm
-rw-r--r-- 1 root root 1484480 Aug 18 21:37 node-v0.9.0.tar.gz
drwxr-xr-x 7 1169 1169 4096 Aug 18 20:11 pcre-8.20
drwxr-xr-x 8 1169 1169 12288 Aug 18 20:14 pcre-8.30
-rw-r--r-- 1 root root 1635262 Aug 18 20:13 pcre-8.30.tar.gz
-rw-r--r-- 1 root root 5124 Sep 26 2011 pgdg-centos91-9.1-4.noarch.rpm
drwxr-x--- 18 1000 1002 4096 Aug 18 20:58 Python-2.7.3
-rw-r--r-- 1 root root 14135620 Apr 10 07:28 Python-2.7.3.tgz
-rw-r--r-- 1 root root 539 Aug 18 21:37 wget-log
[root@SNDA-192-168-15-161 src]# rpm -Uvh pgdg-centos91-9.1-4.noarch.rpm
warning: pgdg-centos91-9.1-4.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:pgdg-centos91 ########################################### [100%]
修改原始的yum仓库配置,在[base]和[updates]部分的尾部追加exclude=postgresql*用以取消从默认仓库安装和更新PostgreSQL。
[root@SNDA-192-168-15-161 src]# cd /etc/yum.repos.d
[root@SNDA-192-168-15-161 yum.repos.d]# vi CentOS-Base.repo
安装或者升级postgresql-libs
[root@SNDA-192-168-15-161 yum.repos.d]# yum upgrade postgresql-libs
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
base | 3.7 kB 00:00
extras | 3.0 kB 00:00
nodejs-stable | 2.9 kB 00:00
pgdg91 | 2.8 kB 00:00
pgdg91/primary_db | 119 kB 00:01
updates | 3.5 kB 00:00
updates/primary_db | 2.3 MB 00:09
Setting up Upgrade Process
No Match for argument: postgresql-libs
No package postgresql-libs available.
No Packages marked for Update
安装PostgreSQL Server
[root@SNDA-192-168-15-161 yum.repos.d]# yum install postgresql91-server
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql91-server.x86_64 0:9.1.5-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql91 = 9.1.5-1PGDG.rhel6 for package: postgresql91-server-9.1.5-1PGDG.rhel6.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql91-server-9.1.5-1PGDG.rhel6.x86_64
--> Running transaction check
---> Package postgresql91.x86_64 0:9.1.5-1PGDG.rhel6 will be installed
---> Package postgresql91-libs.x86_64 0:9.1.5-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql91-server x86_64 9.1.5-1PGDG.rhel6 pgdg91 3.6 M
Installing for dependencies:
postgresql91 x86_64 9.1.5-1PGDG.rhel6 pgdg91 990 k
postgresql91-libs x86_64 9.1.5-1PGDG.rhel6 pgdg91 188 k
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 4.7 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql91-9.1.5-1PGDG.rhel6.x86_64.rpm | 990 kB 00:06
(2/3): postgresql91-libs-9.1.5-1PGDG.rhel6.x86_64.rpm | 188 kB 00:02
(3/3): postgresql91-server-9.1.5-1PGDG.rhel6.x86_64.rpm | 3.6 MB 00:43
--------------------------------------------------------------------------------
Total 90 kB/s | 4.7 MB 00:54
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : postgresql91-libs-9.1.5-1PGDG.rhel6.x86_64 1/3
Installing : postgresql91-9.1.5-1PGDG.rhel6.x86_64 2/3
Installing : postgresql91-server-9.1.5-1PGDG.rhel6.x86_64 3/3
Verifying : postgresql91-libs-9.1.5-1PGDG.rhel6.x86_64 1/3
Verifying : postgresql91-server-9.1.5-1PGDG.rhel6.x86_64 2/3
Verifying : postgresql91-9.1.5-1PGDG.rhel6.x86_64 3/3
Installed:
postgresql91-server.x86_64 0:9.1.5-1PGDG.rhel6
Dependency Installed:
postgresql91.x86_64 0:9.1.5-1PGDG.rhel6
postgresql91-libs.x86_64 0:9.1.5-1PGDG.rhel6
Complete!
初始化数据库,默认路径为/var/lib/pgsql/9.1/data
[root@SNDA-192-168-15-161 yum.repos.d]# service postgresql-9.1 initdb
Initializing database: [ OK ]
启动服务
[root@SNDA-192-168-15-161 yum.repos.d]# service postgresql-9.1 start
Starting postgresql-9.1 service: [ OK ]
[root@SNDA-192-168-15-161 yum.repos.d]# vi /var/lib/pgsql/9.1/data/pg_hba.conf
[root@SNDA-192-168-15-161 yum.repos.d]# psql -U postgres
psql: FATAL: Peer authentication failed for user "postgres"
重启服务
[root@SNDA-192-168-15-161 yum.repos.d]# service postgresql-9.1 restart
Stopping postgresql-9.1 service: [ OK ]
Starting postgresql-9.1 service: [ OK ]
(这里需要先修改配置文件/var/lib/pgsql/9.1/data/pg_hba.conf 将peer或别的改为trust,否则会提示错误Peer authentication failed for user “postgres”),修改客户端认证配置文件,将METHOD由默认的ident改为md5
[root@SNDA-192-168-15-161 yum.repos.d]# psql -U postgres
psql (9.1.5)
Type "help" for help.
postgres=# ALTER USER postgres WITH PASSWORD 'admin'
postgres-# \q
Engine Yard:PostgreSQL是我们的第一选择
PostgreSQL接口编程二:.NetDataProvider--Npgsql驱动
http://blog.csdn.net/beiigang/article/details/7051625
http://www.codeproject.com/Articles/30989/Using-PostgreSQL-in-your-C-NET-application-An-intr
http://datachomp.com/archives/getting-started-with-postgres-and-mvc3/
出处:https://www.cnblogs.com/shanyou/archive/2012/08/25/2656783.html
关注我】。(●'◡'●)
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的【因为,我的写作热情也离不开您的肯定与支持,感谢您的阅读,我是【Jack_孟】!
本文来自博客园,作者:jack_Meng,转载请注明原文链接:https://www.cnblogs.com/mq0036/p/17474254.html
【免责声明】本文来自源于网络,如涉及版权或侵权问题,请及时联系我们,我们将第一时间删除或更改!