RHEL6.4安装PostgreSQL10

由于项目中需要对Mysql、Oracle、PostgreSQL进行兼容,那么mysql与oracle已经安装完成,接着我们就开始安装PostgreSQL。

环境

  • 操作系统 : RHEL6.4(Final)
  • 防火墙 : 关闭
  • SELINUX : disabled
  • Nexus 3

安装PostgreSQL 10

配置Yum代理仓库

打开Nexus 3,新建yum(proxy)仓库,名称随意,本篇为post-repo,地址就填写为https://download.postgresql.org/pub/repos/yum/,点击保存。
点击copy按钮,获取地址为:http://10.10.202.157:8081/repository/post-repo/

下载pgdg-redhat10-10-1.noarch.rpm

1
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-1.noarch.rpm

下载好以后,上传到目标机器进行安装,执行下面的代码:

1
yum install rhel-6-x86_64/pgdg-redhat10-10-1.noarch.rpm

至此,pgdg的仓库就已经安装完成,该仓库路径为/etc/yum.repo.d下面,名为pgdg-10-redhat.repo
打开该yum源仓库的配置,就可以看到如下内容:

1
vim pgdg-10-redhat.repo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[pgdg10]
name=PostgreSQL 10 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-updates-testing]
name=PostgreSQL 10 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/testing/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source-updates-testing]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

由于我们的机器所在的机房不允许机房的机器访问公网,那么此时只能与之前搭建的Nexus 3来实现了。此时第一步配置的代理仓库就发挥了作用。
根据我们获取的链接:

1
http://10.10.202.157:8081/repository/post-repo/

实际上对应的源链接为:

1
https://download.postgresql.org/pub/repos/yum/

那么我们就可以将pgdg-10-redhat.repo的内容修改为如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[pgdg10]
name=PostgreSQL 10 $releasever - $basearch
baseurl=http://10.10.202.157:8081/repository/post-repo/10/redhat/rhel-6.4-x86_64/
enabled=0
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=http://10.10.202.157:8081/repository/post-repo/srpms/10/redhat/rhel-6.4-x86_64/
enabled=0
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-updates-testing]
name=PostgreSQL 10 $releasever - $basearch
baseurl=http://10.10.202.157:8081/repository/post-repo/testing/10/redhat/rhel-6.4-x86_64/
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source-updates-testing]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=http://10.10.202.157:8081/repository/post-repo/srpms/testing/10/redhat/rhel-6.4-x86_64/
enabled=0
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

此时,执行yum update

1
2
3
4
5
6
7
yum update
Loaded plugins: fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Update Process
Loading mirror speeds from cached hostfile
pgdg10-updates-testing | 2.7 kB 00:00
No Packages marked for Update

安装PostgreSQL

1
yum install postgresql10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
yum install postgresql10

Loaded plugins: fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package postgresql10.x86_64 0:10.1-5PGDG.rhel6 will be installed
--> Processing Dependency: postgresql10-libs(x86-64) = 10.1-5PGDG.rhel6 for package: postgresql10-10.1-5PGDG.rhel6.x86_64
--> Processing Dependency: libicu for package: postgresql10-10.1-5PGDG.rhel6.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql10-10.1-5PGDG.rhel6.x86_64
--> Running transaction check
---> Package libicu.x86_64 0:4.2.1-14.el6 will be installed
---> Package postgresql10-libs.x86_64 0:10.1-5PGDG.rhel6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

安装postgresql10-server

1
yum install postgresql10-server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
yum install postgresql10-server
Loaded plugins: fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package postgresql10-server.x86_64 0:10.1-5PGDG.rhel6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================================
Installing:
postgresql10-server x86_64 10.1-5PGDG.rhel6 pgdg10-updates-testing 4.6 M

Transaction Summary
==================================================================================================================================================================================================================================
Install 1 Package(s)

Total download size: 4.6 M
Installed size: 16 M
Is this ok [y/N]: y
Downloading Packages:
postgresql10-server-10.1-5PGDG.rhel6.x86_64.rpm | 4.6 MB 00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : postgresql10-server-10.1-5PGDG.rhel6.x86_64 1/1
Verifying : postgresql10-server-10.1-5PGDG.rhel6.x86_64 1/1

Installed:
postgresql10-server.x86_64 0:10.1-5PGDG.rhel6

Complete!

初始化PostgreSQL

1
service postgresql-10 initdb
1
Initializing database:                                     [  OK  ]
1
chkconfig postgresql-10 on

启动PostgreSQL

1
service postgresql-10 start
1
Starting postgresql-10 service:                            [  OK  ]

至此,PostgreSQL就已经安装完成,可以切换到postgres去登录PostgreSQL了。

Cco.Xyz wechat
坚持原创技术分享,您的支持将鼓励我继续创作!
0%