linux yum oracle安装,PostGresql Install For Linux YUM安装

在Red Hat, CentOS和 Fedora下可以使用yum工具来安装postgresql,在linux发行版本中自带得postgresql版本都不一样,版本情况如下表

Distribution

Version

RHEL/CentOS/SL/OL 7

9.2

RHEL/CentOS/SL/OL 6

8.4(also supplies package postgresql92)

RHEL/CentOS/SL/OL 5

8.1 (also supplies package postgresql84)

Fedora 22

9.4

Fedora 21

9.3

Fedora 20

9.3

查看系统版本:

root># uname -a

Linuxpostgresql.db.com 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

检查系统自带postgresql版本:

root># yum list|grep postgresql-server

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

Repository contrib is listed more than once in the configuration

postgresql-server.x86_64                 8.4.20-4.el6_7                 updates

可以发现自带得版本是8.4,那么我们就使用该版本来安装。

创建postgresql 用户:

root># adduser postgres

root># passwd postgres

Changing password for user postgres.

New password:

BAD PASSWORD: it is based on a dictionary word

Retype new password:

passwd: all authentication tokens updated successfully.

我们通过yum来安装,安装命令如下:

root># yum install postgresql-server.x86_64

具体安装过程如下:

root># yum install postgresql-server.x86_64

Loaded plugins: fastestmirror, refresh-packagekit, security

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

Repository contrib is listed more than once in the configuration

Loading mirror speeds from cached hostfile

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package postgresql-server.x86_64 0:8.4.20-4.el6_7 will be installed

--> Processing Dependency: postgresql-libs(x86-64) = 8.4.20-4.el6_7 for package: postgresql-server-8.4.20-4.el6_7.x86_64

--> Processing Dependency: postgresql(x86-64) = 8.4.20-4.el6_7 for package: postgresql-server-8.4.20-4.el6_7.x86_64

--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-8.4.20-4.el6_7.x86_64

--> Running transaction check

---> Package postgresql.x86_64 0:8.4.20-4.el6_7 will be installed

---> Package postgresql-libs.x86_64 0:8.4.20-4.el6_7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================

Package                                       Arch                               Version                                      Repository                           Size

=========================================================================================================================================================================

Installing:

postgresql-server                             x86_64                             8.4.20-4.el6_7                               updates                             3.4 M

Installing for dependencies:

postgresql                                    x86_64                             8.4.20-4.el6_7                               updates                             2.6 M

postgresql-libs                               x86_64                             8.4.20-4.el6_7                               updates                             202 k

Transaction Summary

=========================================================================================================================================================================

Install       3 Package(s)

Total download size: 6.2 M

Installed size: 29 M

Is this ok [y/N]: y  ---安装所需YUM依赖包,输入Y。

Downloading Packages:

(1/3): postgresql-8.4.20-4.el6_7.x86_64.rpm                                                                                                       | 2.6 MB     00:00

(2/3): postgresql-libs-8.4.20-4.el6_7.x86_64.rpm                                                                                                  | 202 kB     00:00

(3/3): postgresql-server-8.4.20-4.el6_7.x86_64.rpm                                                                                                | 3.4 MB     00:00

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                    3.0 MB/s | 6.2 MB     00:02

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:

glibc-devel-2.5-49.i386 has missing requires of glibc = ('0', '2.5', '49')

glibc-devel-2.5-49.i386 has missing requires of glibc-headers = ('0', '2.5', '49')

glibc-devel-2.12-1.166.el6_7.3.i686 is a duplicate with glibc-devel-2.5-49.i386

Installing : postgresql-libs-8.4.20-4.el6_7.x86_64                                                                                                                 1/3

Installing : postgresql-8.4.20-4.el6_7.x86_64                                                                                                                      2/3

Installing : postgresql-server-8.4.20-4.el6_7.x86_64                                                                                                               3/3

Installed:

postgresql-server.x86_64 0:8.4.20-4.el6_7

Dependency Installed:

postgresql.x86_64 0:8.4.20-4.el6_7                                               postgresql-libs.x86_64 0:8.4.20-4.el6_7

Complete!

ok,安装完成,

检查postgresql服务是否启动:

root># service postgresql status

postmaster is stopped

启动postgresql服务:

root># service postgresql start

/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first.

[FAILED]

发现启动报错,启动报错提示需要先对数据库进行初始化。

下面对数据库进行初始化,命令如下:

root># service postgresql initdb

Initializing database:                                     [  OK  ]

重新启动postgresql服务:

root># service postgresql start

Starting postgresql service:                               [  OK  ]

ok,启动成功。

将用户切换到postgres用户下:

root># su - postgres

登陆到数据库:

postgres>$ psql

psql (8.4.20)

Type "help" for help.

postgres=# \l

List of databases

Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges

-----------+----------+----------+-------------+-------------+-----------------------

postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres

: postgres=CTc/postgres

template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres

: postgres=CTc/postgres

(3 rows)

通过yum安装成功后,那么我们的默认的安装目录在那呢?

一般情况下在linux下安装,默认的postgresql的安装目录和数据目录在/var/lib/pgsql下。

安装目录下有那些文件呢!我们进入到安装目录:

postgresql.db.com<2015-11-21 23:44:22> /var/lib/pgsql

root># ls

backups  data  pgstartup.log

查看数据文件目录下有那些文件:

postgresql.db.com<2015-11-21 23:44:22> /var/lib/pgsql

root># cd data/

postgresql.db.com<2015-11-21 23:46:55> /var/lib/pgsql/data

root># ls -lth

total 80K

drwx------. 2 postgres postgres 4.0K Nov 21 23:46 pg_stat_tmp

drwx------. 2 postgres postgres 4.0K Nov 21 23:39 global

drwx------. 2 postgres postgres 4.0K Nov 21 23:39 pg_log

-rw-------. 1 postgres postgres   57 Nov 21 23:39 postmaster.opts

-rw-------. 1 postgres postgres   45 Nov 21 23:39 postmaster.pid

drwx------. 5 postgres postgres 4.0K Nov 21 23:38 base

drwx------. 2 postgres postgres 4.0K Nov 21 23:37 pg_clog

drwx------. 2 postgres postgres 4.0K Nov 21 23:37 pg_subtrans

drwx------. 3 postgres postgres 4.0K Nov 21 23:37 pg_xlog

-rw-------. 1 postgres postgres 3.4K Nov 21 23:37 pg_hba.conf

-rw-------. 1 postgres postgres 1.6K Nov 21 23:37 pg_ident.conf

-rw-------. 1 postgres postgres  17K Nov 21 23:37 postgresql.conf

-rw-------. 1 postgres postgres    4 Nov 21 23:37 PG_VERSION

drwx------. 4 postgres postgres 4.0K Nov 21 23:37 pg_multixact

drwx------. 2 postgres postgres 4.0K Nov 21 23:37 pg_tblspc

drwx------. 2 postgres postgres 4.0K Nov 21 23:37 pg_twophase

参考:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值