Advertisement

ubuntu 安裝deb_Ubuntu离线安装deb包和依赖

阅读量:

需要用Ubuntu1604离线安装postgresql9.5

环境准备:

一台离线机器

一台联网机器

第一步:离线机器

cd /var/tmp/

通过sudo apt-get安装PostgreSQL包并打印URIS字段;然后使用cut命令切分第二列;接着使用grep命令匹配http://并将结果导出到-var/tmp/download-list目录中

把这个 download-list 下载复制到联网服务器

第二步:联网服务器

拿到 download-list 后

sudo wget -i download-list

如果wget下载后提示404等,那么可能是离线服务器的源的问题,例如:

发布日期:2020年9月18日 11:28:54;该链接提供了Ubuntu 20.04 LTS下 PostgreSQL 9.5版本的安装包:http://security.../postgresql-9.5_9.5.14-amd64.deb

Reusing existing connection to security.ubuntu.com:80.

HTTP request sent, awaiting response... 404 Not Found

2020-09-18 11:28:54 ERROR 404: Not Found.

把离线服务器换成阿里云源就可以了

--2020年9月18日 11时32分3秒-- 访问源地址http://mirrors.aliyun.com/ubuntu/pool/main/p/postgresql-common/postgresql-client-common_173ubuntu0.3_all.deb

Reusing existing connection to mirrors.aliyun.com:80.

HTTP request sent, awaiting response... 200 OK

Length: 28374 (28K) [application/octet-stream]

Saving to: ‘postgresql-client-common_173ubuntu0.3_all.deb’

postgresql-client-c 100%[===================>] 27.71K 62.8KB/s in 0.4s

然后把下载好的这些包们上传到离线服务器。

第三步:批量安装deb包

sudo dpkg -i *.deb

[sudo] password for finch:

Selecting previously unselected package libpq5:amd64.

(Reading database ... 177097 files and directories currently installed.)

Preparing to unpack libpq5_9.5.23-0ubuntu0.16.04.1_amd64.deb ...

Unpacking libpq5:amd64 (9.5.23-0ubuntu0.16.04.1) ...

······

Setting up postgresql-contrib-9.5 (9.5.23-0ubuntu0.16.04.1) ...

Setting up postgresql (9.5+173ubuntu0.3) ...

Processing triggers for libc-bin (2.23-0ubuntu11) ...

Processing triggers for man-db (2.7.5-1) ...

Processing triggers for systemd (229-4ubuntu21.16) ...

Processing triggers for ureadahead (0.100.0-19) ...

Processing triggers for doc-base (0.10.7) ...

Processing 1 added doc-base file...

以离线安装postgresql9.5为例

finch@finch:~/Desktop/apttmp$ sudo su postgres

postgres@finch:/home/finch/Desktop/apttmp$ psql

psql (9.5.23)

Type "help" for help.

postgres-# \q

大功告成!

全部评论 (0)

还没有任何评论哟~