1、在很多时候,服务器不能联网,需要离线安装,下面是Postgresql10离线安装的步骤:
首先进入官网:https://www.postgresql.org,然后找到Download下载
然后选择自己的服务器系统,操作系统,如下所示:
然后,选择自己的版本,如下所示:
2、在能联网的机器上下载yum源,如下所示:
1 [root@slaver1 ~]# sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2 已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
3
4 This system is not registered with an entitlement server. You can use subscription-manager to register.
5
6 pgdg-redhat-repo-latest.noarch.rpm | 6.8 kB 00:00:00
7 正在检查 /var/tmp/yum-root-pJEQZx/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-14.noarch
8 /var/tmp/yum-root-pJEQZx/pgdg-redhat-repo-latest.noarch.rpm 将被安装
9 正在解决依赖关系
10 --> 正在检查事务
11 ---> 软件包 pgdg-redhat-repo.noarch.0.42.0-14 将被 安装
12 --> 解决依赖关系完成
13 Altinity_clickhouse/x86_64/signature | 833 B 00:00:00
14 Altinity_clickhouse/x86_64/signature | 1.0 kB 00:00:00 !!!
15 Altinity_clickhouse-source/signature | 833 B 00:00:00
16 Altinity_clickhouse-source/signature | 1.0 kB 00:00:00 !!!
17 base/7/x86_64 | 3.6 kB 00:00:00
18 elrepo | 3.0 kB 00:00:00
19 extras/7/x86_64 | 2.9 kB 00:00:00
20 updates/7/x86_64 | 2.9 kB 00:00:00
21 updates/7/x86_64/primary_db | 5.7 MB 00:00:09
22
23 依赖关系解决
24
25 =========================================================================================================================================================
26 Package 架构 版本 源 大小
27 =========================================================================================================================================================
28 正在安装:
29 pgdg-redhat-repo noarch 42.0-14 /pgdg-redhat-repo-latest.noarch 11 k
30
31 事务概要
32 =========================================================================================================================================================
33 安装 1 软件包
34
35 总计:11 k
36 安装大小:11 k
37 Downloading packages:
38 Running transaction check
39 Running transaction test
40 Transaction test succeeded
41 Running transaction
42 正在安装 : pgdg-redhat-repo-42.0-14.noarch 1/1
43 验证中 : pgdg-redhat-repo-42.0-14.noarch 1/1
44
45 已安装:
46 pgdg-redhat-repo.noarch 0:42.0-14
47
48 完毕!
49 [root@slaver1 ~]#
开始下载postgresql软件,如下所示:
1 [root@slaver1 yum-root-pJEQZx]# yum search postgres
创建psql10目录,如下所示:
1 [root@slaver1 local]# mkdir /root/psql10
2 [root@slaver1 local]# cd /root/psql10/
3 [root@slaver1 psql10]# ll
4 总用量 0
5 [root@slaver1 psql10]#
安装依赖,如下所示:
1 [root@slaver1 psql10]# yum install --downloadonly --downloaddir=psql10 libicu postgresql10-libs
2 已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
3
4 This system is not registered with an entitlement server. You can use subscription-manager to register.
5
6 Loading mirror speeds from cached hostfile
7 * base: mirrors.huaweicloud.com
8 * elrepo: mirrors.tuna.tsinghua.edu.cn
9 * extras: mirrors.huaweicloud.com
10 * updates: mirrors.bfsu.edu.cn
11 Altinity_clickhouse/x86_64/signature | 833 B 00:00:00
12 Altinity_clickhouse/x86_64/signature | 1.0 kB 00:00:00 !!!
13 Altinity_clickhouse-source/signature | 833 B 00:00:00
14 Altinity_clickhouse-source/signature | 1.0 kB 00:00:00 !!!
15 软件包 libicu-50.2-4.el7_7.x86_64 已安装并且是最新版本
16 正在解决依赖关系
17 --> 正在检查事务
18 ---> 软件包 postgresql10-libs.x86_64.0.10.16-1PGDG.rhel7 将被 安装
19 --> 解决依赖关系完成
20
21 依赖关系解决
22
23 =========================================================================================================================================================
24 Package 架构 版本 源 大小
25 =========================================================================================================================================================
26 正在安装:
27 postgresql10-libs x86_64 10.16-1PGDG.rhel7 pgdg10 358 k
28
29 事务概要
30 =========================================================================================================================================================
31 安装 1 软件包
32
33 总下载量:358 k
34 安装大小:1.3 M
35 Background downloading packages, then exiting:
36 警告:/root/psql10/psql10/postgresql10-libs-10.16-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY17 kB/s | 336 kB 00:00:01 ETA
37 postgresql10-libs-10.16-1PGDG.rhel7.x86_64.rpm 的公钥尚未安装
38 postgresql10-libs-10.16-1PGDG.rhel7.x86_64.rpm | 358 kB 00:00:17
39 exiting because "Download Only" specified
40 [root@slaver1 psql10]#
41 [root@slaver1 psql10]#
安装软件包,如下所示:
1 [root@slaver1 psql10]# yum install --downloadonly --downloaddir=psql10 postgresql10 postgresql10-server
2 已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
3
4 This system is not registered with an entitlement server. You can use subscription-manager to register.
5
6 Loading mirror speeds from cached hostfile
7 * base: mirrors.huaweicloud.com
8 * elrepo: mirrors.tuna.tsinghua.edu.cn
9 * extras: mirrors.huaweicloud.com
10 * updates: mirrors.bfsu.edu.cn
11 正在解决依赖关系
12 --> 正在检查事务
13 ---> 软件包 postgresql10.x86_64.0.10.16-1PGDG.rhel7 将被 安装
14 --> 正在处理依赖关系 postgresql10-libs(x86-64) = 10.16-1PGDG.rhel7,它被软件包 postgresql10-10.16-1PGDG.rhel7.x86_64 需要
15 --> 正在处理依赖关系 libpq.so.5()(64bit),它被软件包 postgresql10-10.16-1PGDG.rhel7.x86_64 需要
16 ---> 软件包 postgresql10-server.x86_64.0.10.16-1PGDG.rhel7 将被 安装
17 --> 正在检查事务
18 ---> 软件包 postgresql10-libs.x86_64.0.10.16-1PGDG.rhel7 将被 安装
19 --> 解决依赖关系完成
20
21 依赖关系解决
22
23 =========================================================================================================================================================
24 Package 架构 版本 源 大小
25 =========================================================================================================================================================
26 正在安装:
27 postgresql10 x86_64 10.16-1PGDG.rhel7 pgdg10 1.6 M
28 postgresql10-server x86_64 10.16-1PGDG.rhel7 pgdg10 4.5 M
29 为依赖而安装:
30 postgresql10-libs x86_64 10.16-1PGDG.rhel7 pgdg10 358 k
31
32 事务概要
33 =========================================================================================================================================================
34 安装 2 软件包 (+1 依赖软件包)
35
36 总计:6.5 M
37 总下载量:6.2 M
38 安装大小:28 M
39 Background downloading packages, then exiting:
40 警告:/root/psql10/psql10/postgresql10-10.16-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY ] 58 kB/s | 2.5 MB 00:01:05 ETA
41 postgresql10-10.16-1PGDG.rhel7.x86_64.rpm 的公钥尚未安装
42 (1/2): postgresql10-10.16-1PGDG.rhel7.x86_64.rpm | 1.6 MB 00:00:44
43 (2/2): postgresql10-server-10.16-1PGDG.rhel7.x86_64.rpm | 4.5 MB 00:03:07
44 ---------------------------------------------------------------------------------------------------------------------------------------------------------
45 总计 34 kB/s | 6.2 MB 00:03:07
46 exiting because "Download Only" specified
47 [root@slaver1 psql10]#
至此,你已经拿到了这三个安装包,打包下载,然后上传到自己的服务器,如下所示:
1 [root@slaver1 psql10]# ll
2 总用量 6668
3 -rw-r--r-- 1 root root 1685364 2月 11 08:36 postgresql10-10.16-1PGDG.rhel7.x86_64.rpm
4 -rw-r--r-- 1 root root 366440 2月 11 08:36 postgresql10-libs-10.16-1PGDG.rhel7.x86_64.rpm
5 -rw-r--r-- 1 root root 4769224 2月 11 08:36 postgresql10-server-10.16-1PGDG.rhel7.x86_64.rpm
6 [root@slaver1 psql10]#
3、如果,你有这三个安装包,可以直接上传到服务器,忽略上面的步骤,开始进行安装,开始进行离线安装,如下所示:
1 [root@slaver1 psql10]# rpm -ivh postgresql10-*
2 警告:postgresql10-10.16-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
3 准备中... ################################# [100%]
4 正在升级/安装...
5 1:postgresql10-libs-10.16-1PGDG.rhe################################# [ 33%]
6 2:postgresql10-10.16-1PGDG.rhel7 ################################# [ 67%]
7 3:postgresql10-server-10.16-1PGDG.r################################# [100%]
8 [root@slaver1 psql10]#
初始化数据,启动服务,如下所示:
1 [root@slaver1 psql10]#
2 [root@slaver1 psql10]# /usr/pgsql-10/bin/postgresql-10-setup initdb
3 Initializing database ... OK
4
5 [root@slaver1 psql10]#
执行postgresql开机自启动,启动postgresql,如下所示:
1 [root@slaver1 psql10]#
2 [root@slaver1 psql10]# systemctl enable postgresql-10
3 Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-10.service to /usr/lib/systemd/system/postgresql-10.service.
4 [root@slaver1 psql10]# systemctl start postgresql-10
5 [root@slaver1 psql10]#
6 [root@slaver1 psql10]#
7 [root@slaver1 psql10]#
连接postgresql,如下所示:
1 [root@slaver1 psql10]# su - postgres
2 -bash-4.2$ psql
3 psql (10.16)
4 输入 "help" 来获取帮助信息.
5
6 postgres=# \q
7 -bash-4.2$ exit
8 登出
9 [root@slaver1 psql10]#
可以查看数据库,如下所示: