【CDH5】-001CentOS6.5 下yum安装PostgreSQL

来源:互联网 发布:上山下乡知乎 编辑:程序博客网 时间:2024/05/20 02:23

1、下载 pgdg-centos93-9.3-1.noarch.rpm
地址: http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm


2、安装pgdg-centos93-9.3-1.noarch.rpm


安装前,配置YUM repository
vim /etc/yum.repos.d/CentOS-Base.repo

在[base] and [updates] sections末尾添加:
exclude=postgresql*

2.1 设置可执行权限
chmod +x pgdg-centos93-9.3-1.noarch.rpm

2.2 通过rpm命令本地安装
rpm -ivh pgdg-centos93-9.3-1.noarch.rpm


3、安装 PostgreSQL
3.1 列出有效安装包
命令: yum list postgres*

[root@flxy31 hadoop]# yum list postgres*

3.2 安装PostgreSQL 9.3 server

命令:yum install postgresql93-server

[root@flxy31 hadoop]# yum install postgresql93-server

4、初始化Postgreql数据库
第一次安装postgreql数据库安装包后,那么需要对数据数据库进行初始化和配置,PostgreSQL 数据目录(/var/lib/pgsql/9.3/data) 含有所有数据文件

4.1 初始化命令: service postgresql-9.3 initdb

[root@flxy31 data]# service postgresql-9.3 initdb
Initializing database: [  OK  ]

4.2 初始化后验证data下的目录文件

[root@flxy31 data]# pwd
/var/lib/pgsql/9.3/data
[root@flxy31 data]# ll
total 96
drwx------ 5 postgres postgres  4096 Jul 19 00:22 base
drwx------ 2 postgres postgres  4096 Jul 19 00:22 global
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_clog
-rw------- 1 postgres postgres  4232 Jul 19 00:22 pg_hba.conf
-rw------- 1 postgres postgres  1636 Jul 19 00:22 pg_ident.conf
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_log
drwx------ 4 postgres postgres  4096 Jul 19 00:22 pg_multixact
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_notify
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_serial
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_snapshots
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_stat
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_stat_tmp
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_subtrans
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_tblspc
drwx------ 2 postgres postgres  4096 Jul 19 00:22 pg_twophase
-rw------- 1 postgres postgres     4 Jul 19 00:22 PG_VERSION
drwx------ 3 postgres postgres  4096 Jul 19 00:22 pg_xlog
-rw------- 1 postgres postgres 20558 Jul 19 00:22 postgresql.conf

5、设置开机启动
chkconfig postgresql-9.3 on
service postgresql-9.3 start



参考文章:
【CentOS6.5下安装PostgreSQL】http://www.centoscn.com/CentosServer/sql/2014/0923/3821.html
【CentOS6.5下安装PostgreSQL】http://www.centoscn.com/image-text/install/2014/0804/3412.html
【官方】http://wiki.postgresql.org/wiki/YUM_Installation
【博客】http://www.cnblogs.com/shanyou/archive/2012/08/25/2656783.html

常见问题:
问题1:yum使用过程中的常见错误
解决方案: http://myceo.blog.51cto.com/2340655/755896
注意两点:
(1) yum 的缓存问题,查看目录 /var/cache/yum
(2) 有的公司是通过代理连接外网的,必须vim /etc/yum.conf ,添加对应的公司的代理。无代理的话这个必须删除
说明:
该块内容可以解决yum使用过程中大部分的问题

问题2: 出现下面的问题
http://mirror.centos.org/centos/6/updates/x86_64/repodata/9d30f891e424e1868a40809f5c1e66dc5ceadb2a70160a23d9d945246d80ddcf-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: failure: repodata/9d30f891e424e1868a40809f5c1e66dc5ceadb2a70160a23d9d945246d80ddcf-primary.sqlite.bz2 from updates: [Errno 256] No more mirrors to try.


解决方案: 可以考虑开启baseurl,例如:
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
0 0
原创粉丝点击