需要用Ubuntu1604离线安装postgresql9.5
环境准备:
- 一台离线机器
- 一台联网机器
第一步:离线机器
cd /var/tmp/
sudo apt-get --allow-unauthenticated -y install --print-uris postgresql | cut -d\' -f2 | grep http:// > /var/tmp/download-list
把这个 download-list 下载复制到联网服务器
第二步:联网服务器
拿到 download-list 后
sudo wget -i download-list
如果wget下载后提示404等,那么可能是离线服务器的源的问题,例如:
--2020-09-18 11:28:54-- http://security.ubuntu.com/ubuntu/pool/main/p/postgresql-9.5/postgresql-9.5_9.5.14-0ubuntu0.16.04_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-09-18 11:32:03-- 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
大功告成!
参考: https://techedemic.com/2014/10/01/offline-package-installs-using-dpkg-and-apt-get-ubuntudebianetc/
https://stackoom.com/question/3jLSw/Ubuntu-Postgresql-%E7%A6%BB%E7%BA%BF%E5%AE%89%E8%A3%85